diff -r ffc02bf394cb -r e9e2f624cd99 awesome/my.lua --- a/awesome/my.lua Sat Jun 20 16:21:25 2015 -0400 +++ b/awesome/my.lua Sat Jun 20 20:32:45 2015 -0400 @@ -1,6 +1,7 @@ local os = require("os") local io = require("io") local debug = require("debug") +local table = require("table") local awesome = require("awesome") local naughty = require("naughty") local awful = require("awful") @@ -61,8 +62,8 @@ notify_error = mk_notify_error_dialog(3) -local function get_gradient_colors(c1, c2, c3) - return { type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, c1 }, { 0.5, c2 }, { 1, c3 } }} +local function get_gradient_colors(c1, c2) + return { type = "linear", from = { 0, 0 }, to = { 0, 20 }, stops = { { 0, c2 }, { 1, c1 } }} end function mkspawn(p) @@ -102,8 +103,8 @@ local w = awful.widget.graph() -- Graph properties w:set_width(30) - w:set_background_color("#729fcf") - w:set_color(get_gradient_colors("#729fcf", "LightBlue", "white")) + w:set_background_color(beautiful.bg_normal) + w:set_color(get_gradient_colors(beautiful.bg_focus, beautiful.bg_urgent)) -- Register widget vicious.register(w, vicious.widgets.cpu, "$1", 1) return w @@ -130,8 +131,8 @@ -- Progressbar properties w:set_width(10) w:set_vertical(true) - w:set_background_color("#729fcf") - w:set_color(get_gradient_colors("#729fcf", "LightBlue", "white")) + w:set_background_color(beautiful.bg_normal) + w:set_color(get_gradient_colors(beautiful.bg_focus, beautiful.bg_urgent)) -- Register widget vicious.register(w, vicious.widgets.mem, "$1", 5) return w @@ -223,8 +224,7 @@ if event == "release" then return true end - local theme = beautiful.get() - widgets.mode_widget_bg:set_bg(theme.bg_focus) + widgets.mode_widget_bg:set_bg(beautiful.bg_focus) if key == "Escape" then return false end @@ -239,7 +239,7 @@ end end -- notify_error("Nothing for " .. skey) - widgets.mode_widget_bg:set_bg(theme.bg_urgent) + widgets.mode_widget_bg:set_bg(beautiful.bg_urgent) return true end @@ -260,7 +260,7 @@ function run_kt(c, keytable, title) widgets.mode_widget:set_text("Mode: " .. title) -- widgets.mode_widget:show() - widgets.mode_widget_bg:set_bg("LightBlue") + widgets.mode_widget_bg:set_bg(beautiful.bg_focus) widgets.mode_widget:buttons( awful.util.table.join( awful.button({}, 1, function () show_kt(keytable, "Binding") end), @@ -353,3 +353,48 @@ end end) end + +-- theme menu +function theme_load(theme) + local cfg_path = awful.util.getdir("config") + awful.util.spawn("ln -sfn " .. cfg_path .. "/themes/" .. theme .. " " .. cfg_path .. "/current_theme") + awesome.restart() +end + +function theme_menu() + -- List your theme files and feed the menu table + local cmd = "ls -1 " .. awful.util.getdir("config") .. "/themes/" + local f = io.popen(cmd) + + local themes = {} + for l in f:lines() do + local item = { l, function () theme_load(l) end } + table.insert(themes, item) + end + + f:close() + return themes +end + +function set_wallpaper(wallpaper) + local cfg_path = awful.util.getdir("config") + local source_path = cfg_path .. "/wallpapers/" .. wallpaper + local default_path = cfg_path .. "/default" + awful.util.spawn("ln -sfn " .. source_path .. " " .. default_path ) + awful.util.spawn("fbsetbg -a " .. default_path) +end + +function wallpaper_menu() + local cmd = "ls " .. awful.util.getdir("config") .. "/wallpapers/" + local f = io.popen(cmd) + local wallpapers = {} + for l in f:lines() do + local name, ext = capi.string.match(l, "(.-)(%.[^%.]+)$") + local item = { name, function () set_wallpaper(l) end } + table.insert(wallpapers, item) + end + + f:close() + return wallpapers +end +