-- Standard awesome library require("awful") require("awful.autofocus") require("awful.rules") -- Theme handling library require("beautiful") -- Notification library require("naughty") -- Load Debian menu entries require("debian.menu") -- functions {{{1 -- status {{{2 cardid = 0 channel = "Master" function volume (mode, widget) if mode == "update" then local pvol = io.popen("amixer -c " .. cardid .. " -- sget " .. channel) local status = pvol:read("*all") local volume = string.match(status, "(%d?%d?%d)%%") volume = string.format("% 3d", volume) status = string.match(status, "%[(o[^%]]*)%]") if string.find(status, "on", 1, true) then -- widget:bar_properties_set("vol", {["bg"] = "#000000"}) else -- widget:bar_properties_set("vol", {["bg"] = "#333333"}) end widget:bar_data_add("vol", volume) io.close(pvol) elseif mode == "up" then awful.util.spawn("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%+") volume("update", widget) elseif mode == "down" then awful.util.spawn("amixer -q -c " .. cardid .. " sset " .. channel .. " 5%-") volume("update", widget) else awful.util.spawn("amixer -c " .. cardid .. " sset " .. channel .. " toggle") volume("update", widget) end end function ibmVolume() local curvol, mute fvol = io.open("/proc/acpi/ibm/volume") local line = fvol:read() while line do if line:match("^level:") then curvol = string.match(line, "%d+") elseif line:match("^mute:") then mute = string.match(line, "%w+$") end line = fvol:read() end io.close(fvol) if mute == 'on' then return 0 else return curvol / 15 * 100 end end function battRemaining() fh = io.popen("acpi -b") local line = fh:read() io.close(fh) local rem = string.match(line, " %d%d:%d%d") local perc = string.match(line, "%d+%%") if rem then return rem.."h ("..perc..")" end return "(Full)" end function batteryInfo(adapter, widget) local fcur = io.open("/sys/class/power_supply/"..adapter.."/energy_now") local fcap = io.open("/sys/class/power_supply/"..adapter.."/energy_full") local fsta = io.open("/sys/class/power_supply/"..adapter.."/status") local cur = fcur:read() local cap = fcap:read() local sta = fsta:read() local spacer = " " local battery = math.floor(cur * 100 / cap) if sta:match("Charging") then dir = "+" battery = battery.."%" elseif sta:match("Discharging") then dir = "-" if tonumber(battery) < 10 then naughty.notify({ title = "Battery Warning" , text = "Battery low!"..spacer..battery.."%"..spacer.."left!" , timeout = 5 , position = "top_right" , fg = beautiful.fg_focus , bg = beautiful.bg_focus }) end battery = battery.."%" else dir = "" battery = "A/C" end widget.text = " "..adapter..": "..dir..battery fcur:close() fcap:close() fsta:close() end ---------------------------------------------------- -- cpu -> cpu_percent -- user + nice + system + idle = 100/second) -- so diffs of: $2+$3+$4 / all-together * 100 = % -- or: 100 - ( $5 / all-together) * 100 = % -- or: 100 - 100 * ( $5 / all-together)= % ---------------------------------------------------- cpu_old_sum = 0 cpu_old_user = 0 cpu_old_nice = 0 cpu_old_system = 0 cpu_old_iowait = 0 cpu_old_idle = 0 function cpu(cpuid) local line, cpu_new_sum, user, nice, system, idle, iowait, diff, fh local cpu_user, cpu_nice, cpu_iowait, cpu_total, cpu_system fh = io.open("/proc/stat") line = fh:read() while line do if string.match(line, cpuid) then -- user, nice, system, idle, iowait = string.match(line, "%w+%s+(%d+)%s+(%d+)%s+(%d+)%s+(%d+)%s+(%d+)") cpu_new_sum = user + nice + system + idle + iowait -- all-together diff = cpu_new_sum - cpu_old_sum; if diff > 0 then -- should be always true - but on heavy load no update is possible cpu_user = 100 * (user - cpu_old_user) / diff; cpu_nice = 100 * (nice - cpu_old_nice) / diff; cpu_system = 100 * (system - cpu_old_system) / diff; cpu_iowait = 100 * (iowait - cpu_old_iowait) / diff; cpu_total = 100 - 100 * (idle - cpu_old_idle) / diff; else cpu_user = 100 cpu_nice = 100 cpu_iowait = 100 cpu_total = 100 cpu_system = 100 end cpu_old_sum = cpu_new_sum; cpu_old_user = user; cpu_old_nice = nice; cpu_old_system = system; cpu_old_iowait = iowait; cpu_old_idle = idle; io.close(fh); return {cpu_user, cpu_nice, cpu_iowait, cpu_system, cpu_total} end line = fh:read() end io.close(fh); end ---------------------------------------------------- -- DF (disk-free) bar ---------------------------------------------------- function diskfree(cmd) local z, line, ph, df df = {} z = 1 ph = io.popen(cmd) line = ph:read() -- skip first line line = ph:read() while line do if string.match(line, '%%') then perc = string.gsub(line, "^[^%s]+%s+[^%s]+%s+[^%s]+%s+[^%s]+%s+(%w+).+$", "%1") perc = tonumber(perc) if (perc == nil or perc < 0) then perc = 0; end df[z] = perc; z = z + 1 end line = ph:read() end io.close(ph); return df end ---------------------------------------------------- -- memory ---------------------------------------------------- -- todo: Mem{Swap}Total would be needed only once! function memory(proc) local mem_free, mem_total, swap_free, swap_total local mem_percent, swap_percent, line, fh, count local buffers, cached count = 0 fh = io.open(proc) line = fh:read() while line and count < 7 do if line:match("^MemTotal:") then mem_total = string.match(line, "%d+") count = count + 1; elseif line:match("^MemFree:") then mem_free = string.match(line, "%d+") count = count + 1; elseif line:match("^Buffers:") then buffers = string.match(line, "%d+") count = count + 1; elseif line:match("^Cached:") then cached = string.match(line, "%d+") count = count + 1; elseif line:match("^SwapFree:") then swap_free = string.match(line, "%d+") count = count + 1; elseif line:match("^SwapTotal:") then swap_total = string.match(line, "%d+") count = count + 1; end line = fh:read() end io.close(fh) -- mem_percent = 100 * (mem_free + buffers + cached) / mem_total; mem_percent = 100 * (mem_total - mem_free - buffers - cached) / mem_total; swap_percent = 100 * (swap_total - swap_free) / swap_total; return {mem_percent, swap_percent} end function temp(zone, mintemp, maxtemp) fh = io.open("/sys/devices/platform/thinkpad_hwmon/temp"..zone.."_input") line = fh:read() io.close(fh); local curtemp = tonumber(line) / 1000 return ( tonumber(curtemp) - mintemp ) / ( maxtemp-mintemp ) * 100 end function cpufreq(cpuid, minfreq, maxfreq) fh = io.open('/sys/devices/system/cpu/'..cpuid..'/cpufreq/scaling_cur_freq') curfreq = fh:read() cpufreq_perc = ( tonumber(curfreq) - minfreq ) / ( maxfreq - minfreq ) * 100 io.close(fh); return cpufreq_perc end function ibmfan(min, max) local speed = 0 fh = io.open('/proc/acpi/ibm/fan') line = fh:read() while line do if line:match("^speed:") then io.close(fh) speed = string.match(line, "%d+") --return perc(min, max, tonumber(cur)) return ( tonumber(speed) - min ) / ( max-min ) * 100 end line = fh:read() end io.close(fh) return 0 end ---------------------------------------------------- -- ethernet (in kb/update-interval) ---------------------------------------------------- ethernet_total_in_old = { wlan0 = 0, eth0 = 0 } ethernet_total_out_old = { wlan0 = 0, eth0 = 0 } function ethernet(eth) local tot_eth_in, tot_eth_out, tmp, fh local eth_in, eth_out fh = io.open("/proc/net/dev") line = fh:read() while line do if string.match(line, eth) then tmp = string.find (line,":") -- e.g. skip the 0 on eth0 tot_eth_in = string.match(line, "%s*%d+", tmp) -- first decimal number are total bytes tot_eth_out = string.gsub(line,"^.*:%s*%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+%d+%s+(%d+).*$", "%1") eth_in = (tot_eth_in - ethernet_total_in_old[eth]) / 1024 -- / INTERVAL eth_out = (tot_eth_out - ethernet_total_out_old[eth]) / 1024 -- / INTERVAL ethernet_total_in_old[eth] = tot_eth_in ethernet_total_out_old[eth] = tot_eth_out --tot_eth_in_old = tot_eth_in --tot_eth_out_old = tot_eth_out if eth_in < 0 then eth_in = 0 end if eth_out < 0 then eth_out = 0 end eth_in = string.format("%5.0f", eth_in) eth_out = string.format("%5.0f", eth_out) io.close(fh); return {eth_in, eth_out} end line = fh:read() end io.close(fh); return {"n/a", ""} end -- utility {{{2 function perc(min, max, cur) return ( cur - min ) / ( max - min ) * 100 end --- Spawns cmd if no client can be found matching properties -- If such a client can be found, pop to first tag where it is visible, and give it focus -- @param cmd the command to execute -- @param properties a table of properties to match against clients. Possible entries: any properties of the client object function run_or_raise(cmd, properties) local clients = client.get() for i, c in pairs(clients) do if match(properties, c) then local ctags = c:tags() if table.getn(ctags) == 0 then -- ctags is empty, show client on current tag local curtag = awful.tag.selected() awful.client.movetotag(curtag, c) else -- Otherwise, pop to first tag client is visible on awful.tag.viewonly(ctags[1]) end -- And then focus the client client.focus = c c:raise() return end end awful.util.spawn(cmd) end -- Returns true if all pairs in table1 are present in table2 function match (table1, table2) for k, v in pairs(table1) do if table2[k] ~= v then return false end end return true end function dec2hex(s) s = string.format("%02x", s) return s end function gradient(min, max, val) if (val > max) then val = max end if (val < min) then val = min end local v = val - min local d = (max - min) * 0.5 local r, g if (v <= d) then r = (255 * v) / d g = 255 else r = 255 g = 255 - (255 * (v-d)) / (max - min - d) end return "#"..dec2hex(tostring(r))..dec2hex(tostring(g)).."00" end -- Variable definitions {{{1 -- This is a file path to a theme file which will defines colors. theme_path = os.getenv("HOME") .. "/.config/awesome/theme.lua" -- Uncommment this for a lighter theme -- theme_path = "/usr/share/awesome/themes/sky/theme" -- Actually load theme beautiful.init(theme_path) -- This is used later as the default terminal and editor to run. terminal = "x-terminal-emulator" editor = os.getenv("EDITOR") or "vim" editor_cmd = terminal .. " -e " .. editor -- Default modkey. -- Usually, Mod4 is the key with a logo between Control and Alt. -- If you do not like this or do not have such a key, -- I suggest you to remap Mod4 to another key using xmodmap or other tools. -- However, you can use another modifier like Mod1, but it may interact with others. modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. layouts = { awful.layout.suit.max, awful.layout.suit.max.fullscreen, awful.layout.suit.fair, awful.layout.suit.magnifier, awful.layout.suit.tile.bottom, awful.layout.suit.tile.left } -- Define if we want to use titlebar on all applications. --use_titlebar = true -- }}} -- {{{ Tags -- Define a tag table which hold all screen tags. tags = {} for s = 1, screen.count() do -- Each screen has its own tag table. tags[s] = awful.tag({ 1, 2, 3, 4, 5 }, s) -- awful.tag.setproperty(tags[s], "layout", layouts[1]) end -- }}} -- {{{ Menu -- Create a laucher widget and a main menu myawesomemenu = { { "manual", terminal .. " -e man awesome" }, { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/awesomerc.lua" }, { "restart", awesome.restart }, { "quit", awesome.quit } } mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "Debian", debian.menu.Debian_menu.Debian }, { "open terminal", terminal } } }) mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon), menu = mymainmenu }) -- Create a systray mysystray = widget({ type = "systray" }) -- Create a wibox for each screen and add it mywibox = {} infobox = {} mypromptbox = {} mylayoutbox = {} mytaglist = {} mytaglist.buttons = awful.util.table.join( awful.button({ }, 1, awful.tag.viewonly), awful.button({ modkey }, 1, awful.client.movetotag), awful.button({ }, 3, awful.tag.viewtoggle), awful.button({ modkey }, 3, awful.client.toggletag), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) ) mytasklist = {} mytasklist.buttons = awful.util.table.join( awful.button({ }, 1, function (c) if not c:isvisible() then awful.tag.viewonly(c:tags()[1]) end client.focus = c c:raise() end), awful.button({ }, 3, function () if instance then instance:hide() instance = nil else instance = awful.menu.clients({ width=250 }) end end), awful.button({ }, 4, function () awful.client.focus.byidx(1) if client.focus then client.focus:raise() end end), awful.button({ }, 5, function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end)) for s = 1, screen.count() do -- Create a promptbox for each screen mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }) -- Create an imagebox widget which will contains an icon indicating which layout we're using. -- We need one layoutbox per screen. mylayoutbox[s] = awful.widget.layoutbox(s) mylayoutbox[s]:buttons(awful.util.table.join( awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end), awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end), awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end))) -- Create a taglist widget mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons) -- Create a tasklist widget mytasklist[s] = awful.widget.tasklist(function(c) return awful.widget.tasklist.label.currenttags(c, s) end, mytasklist.buttons) -- Create the wibox infobox[s] = awful.wibox({ position = "bottom", fg = beautiful.fg_normal, bg = beautiful.bg_normal, screen = s }) mywibox[s] = awful.wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal, screen = s }) -- {{{ Widgets -- Create a textbox widget tb_date = widget({ type = "textbox" }) tb_mem = widget( { type="textbox", name ="tb_mem" } ) tb_mem.text = " mem: " pb_mem = awful.widget.progressbar( ) pb_mem.width = 40 pb_mem.ticks_count = 10 pb_mem.border_padding = 0 -- pb_mem:bar_properties_set("mem", -- { -- ["bg"] = beautiful.pb_mem_bg, -- ["fg"] = beautiful.pb_mem_fg, -- ["border_color"] = beautiful.pb_mem_border_color, -- }) -- pb_mem:bar_properties_set("swap", -- { -- ["bg"] = beautiful.pb_mem_bg, -- ["fg"] = beautiful.pb_mem_fg, -- ["border_color"] = beautiful.pb_mem_border_color, -- }) tb_volume = widget( { type="textbox", name ="tb_volume" } ) tb_volume.text = " Vol: " pb_volume = awful.widget.progressbar() pb_volume.width = 20 pb_volume.ticks_count = 5 pb_volume.vertical = true pb_volume.border_width = 0 -- pb_volume:bar_properties_set("vol", -- { -- ["bg"] = beautiful.pb_vol_bg, -- ["fg"] = beautiful.pb_vol_fg, -- ["border_color"] = beautiful.pb_vol_border_color, -- ["max_value"] = "100.0", -- }) -- pb_volume:buttons({ -- button({ }, 1, function() awful.util.spawn("xfce4-mixer") end) -- }) tb_diskfree = widget( { type="textbox", name ="tb_diskfree" } ) tb_diskfree.text = " df: " pb_diskfree = widget( { type="progressbar", name="pb_diskfree" } ) pb_diskfree.width = 40 pb_diskfree.ticks_count = 10 -- pb_diskfree.vertical = true -- pb_diskfree:bar_properties_set("root", -- { -- ["bg"] = beautiful.pb_df_bg, -- ["fg"] = beautiful.pb_df_fg, -- ["border_color"] = beautiful.pb_df_border_color, -- }) -- pb_diskfree:bar_properties_set("home", -- { -- ["bg"] = beautiful.pb_df_bg, -- ["fg"] = beautiful.pb_df_fg, -- ["border_color"] = beautiful.pb_df_border_color, -- }) gr_thermal = widget({ type = "graph" }) gr_thermal.width = 60 gr_thermal.grow = "right" gr_thermal.bg = beautiful.gr_thermal_bg gr_thermal.border_color = beautiful.gr_thermal_border_color gr_thermal:plot_properties_set("fan", { ["bg"] = beautiful.gr_thermal_bg, ["fg"] = beautiful.gr_thermal_fan, ["scale"] = false, ["max_value"] = "100.0", }) gr_thermal:plot_properties_set("cputemp", { ["bg"] = beautiful.gr_thermal_bg, ["fg"] = beautiful.gr_thermal_cpu, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "line" }) gr_thermal:plot_properties_set("mbtemp", { ["bg"] = beautiful.gr_thermal_bg, ["fg"] = beautiful.gr_thermal_mb, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "line" }) tb_cpu = widget( { type="textbox", name ="tb_cpu" } ) tb_cpu.text = " cpu: " gr_cpu = widget({ type = "graph" }) gr_cpu.width = 60 gr_cpu.grow = "right" gr_cpu.bg = beautiful.gr_cpu_bg gr_cpu.border_color = beautiful.gr_cpu_border_color gr_cpu:plot_properties_set("iowait", { ["fg"] = beautiful.gr_cpu_iowait_fg, ["scale"] = false, ["max_value"] = "100.0", }) gr_cpu:plot_properties_set("total", { ["fg"] = beautiful.gr_cpu_total_fg, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "bottom" }) gr_cpu:plot_properties_set("user", { ["fg"] = beautiful.gr_cpu_user_fg, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "bottom" }) gr_cpu:plot_properties_set("nice", { ["fg"] = beautiful.gr_cpu_nice_fg, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "bottom" }) gr_cpu:plot_properties_set("sys", { ["fg"] = beautiful.gr_cpu_sys_fg, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "bottom" }) gr_cpu:plot_properties_set("freq", { ["fg"] = beautiful.gr_cpu_freq, ["scale"] = false, ["max_value"] = "100.0", ["style"] = "line" }) gr_cpu:buttons({ button({ }, 1, function() awful.util.spawn(terminal .. " -e top") end) }) tb_slash = widget({ type = "textbox" }) tb_slash.text = "/" tb_eth0 = widget( { type="textbox", name ="tb_eth0" } ) tb_eth0.text = " eth0: " tb_eth0_in = widget({ type = "textbox" }) tb_eth0_in.width = "70" tb_eth0_out = widget({ type = "textbox" }) tb_eth0_out.width = "70" tb_wlan0 = widget( { type="textbox", name ="tb_wlan0" } ) tb_wlan0.text = " wlan0: " tb_wlan0_in = widget({ type = "textbox" }) tb_wlan0_in.width = "70" tb_wlan0_out = widget({ type = "textbox" }) tb_wlan0_out.width = "70" tb_battery = widget({type = "textbox", name = "tb_battery" }) tb_battery.width = 110 tb_battery.font = "sans 6" -- }}} -- Add widgets to the wibox - order matters infobox[s].widgets = { { tb_diskfree, pb_diskfree, tb_mem, pb_mem, tb_wlan0, tb_wlan0_in, tb_slash, tb_wlan0_out, tb_eth0, tb_eth0_in, tb_slash, tb_eth0_out, layout = awful.widget.layout.horizontal.leftright }, { pb_volume, tb_date, gr_cpu, gr_thermal, tb_battery, layout = awful.widget.layout.horizontal.rightleft }, layout = awful.widget.layout.horizontal.leftright } infobox[s].screen = s mywibox[s].widgets = { mylauncher, mypromptbox[s], mytaglist[s], mytasklist[s], s == 1 and { mysystray } or nil, mylayoutbox[s], layout = awful.widget.layout.horizontal.leftright } end -- }}} -- {{{ Mouse bindings root.buttons(awful.util.table.join( awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) )) -- }}} -- {{{ Key bindings globalkeys = awful.util.table.join( awful.key({ modkey, }, "Left", awful.tag.viewprev ), awful.key({ modkey, }, "Right", awful.tag.viewnext ), awful.key({ modkey, }, "Escape", awful.tag.history.restore), awful.key({ }, "XF86Back", awful.tag.viewprev ), awful.key({ }, "XF86Forward", awful.tag.viewnext ), awful.key({ modkey, }, "j", function () awful.client.focus.byidx( 1) if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "k", function () awful.client.focus.byidx(-1) if client.focus then client.focus:raise() end end), awful.key({ modkey, }, "w", function () mymainmenu:show(true) end), -- Layout manipulation awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end), awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end), awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end), awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end), awful.key({ modkey, }, "u", awful.client.urgent.jumpto), awful.key({ modkey, }, "Tab", function () awful.client.focus.history.previous() if client.focus then client.focus:raise() end end), -- Standard program awful.key({ modkey, "Control" }, "r", awesome.restart), awful.key({ modkey, "Shift" }, "q", awesome.quit), awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end), awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end), awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end), awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end), awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end), awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end), awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end), awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end), -- Prompt awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end), awful.key({ modkey }, "x", function () awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen].widget, awful.util.eval, nil, awful.util.getdir("cache") .. "/history_eval") end), -- custom shortcuts awful.key({ modkey, }, "f", function () awful.util.spawn("iceweasel") end), awful.key({ modkey, }, "g", function () awful.util.spawn(terminal .. " -e ssh -t glasshouse screen -RD ") end), awful.key({ modkey, }, "e", function () awful.util.spawn("gvim") end), awful.key({ modkey, }, "n", function () awful.util.spawn("thunar") end), awful.key({ }, "XF86ScreenSaver", function () awful.util.spawn("xtrlock") end), awful.key({ modkey, }, "Return", function () local screen_cmd = terminal .. " -e screen -RD -S " .. os.getenv("USER") .. awful.tag.selected().name awful.util.spawn(screen_cmd) end) ) clientkeys = awful.util.table.join( awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end), awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end), awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ), awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end), awful.key({ modkey, }, "o", awful.client.movetoscreen ), awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end), awful.key({ modkey, }, "t", function (c) c.minimized = not c.minimized end), awful.key({ modkey, }, "m", function (c) c.maximized_horizontal = not c.maximized_horizontal c.maximized_vertical = not c.maximized_vertical end) ) -- Compute the maximum number of digit we need, limited to 9 keynumber = 0 for s = 1, screen.count() do keynumber = math.min(9, math.max(#tags[s], keynumber)); end -- Bind all key numbers to tags. -- Be careful: we use keycodes to make it works on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, keynumber do globalkeys = awful.util.table.join(globalkeys, awful.key({ modkey }, "#" .. i + 9, function () local screen = mouse.screen if tags[screen][i] then awful.tag.viewonly(tags[screen][i]) end end), awful.key({ modkey, "Control" }, "#" .. i + 9, function () local screen = mouse.screen if tags[screen][i] then awful.tag.viewtoggle(tags[screen][i]) end end), awful.key({ modkey, "Shift" }, "#" .. i + 9, function () if client.focus and tags[client.focus.screen][i] then awful.client.movetotag(tags[client.focus.screen][i]) end end), awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () if client.focus and tags[client.focus.screen][i] then awful.client.toggletag(tags[client.focus.screen][i]) end end)) end clientbuttons = awful.util.table.join( awful.button({ }, 1, function (c) client.focus = c; c:raise() end), awful.button({ modkey }, 1, awful.mouse.client.move), awful.button({ modkey }, 3, awful.mouse.client.resize)) -- Set keys root.keys(globalkeys) -- }}} -- {{{ Rules awful.rules.rules = { -- All clients will match this rule. { rule = { }, properties = { border_width = beautiful.border_width, border_color = beautiful.border_normal, focus = true, keys = clientkeys, buttons = clientbuttons } }, { rule = { class = "MPlayer" }, properties = { floating = true } }, { rule = { class = "pinentry" }, properties = { floating = true } }, { rule = { class = "gimp" }, properties = { floating = true } }, { rule = { class = "Xfce4-mixer" }, properties = { floating = true } }, { rule = { class = "mocp" }, properties = { floating = true } }, { rule = { class = "Wicd-client.py" }, properties = { floating = true } }, { rule = { class = "twitux" }, properties = { floating = true } }, { rule = { class = "glxgears" }, properties = { floating = true } }, -- Set Firefox to always map on tags number 2 of screen 1. { rule = { class = "Firefox" }, properties = { tag = tags[1][1] } }, } -- }}} -- {{{ Signals -- {{{ defaults -- Signal function to execute when a new client appears. client.add_signal("manage", function (c, startup) -- Add a titlebar -- awful.titlebar.add(c, { modkey = modkey }) -- Enable sloppy focus c:add_signal("mouse::enter", function(c) if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then client.focus = c end end) if not startup then -- Set the windows at the slave, -- i.e. put it at the end of others instead of setting it master. -- awful.client.setslave(c) -- Put windows in a smart way, only if they does not set an initial position. if not c.size_hints.user_position and not c.size_hints.program_position then awful.placement.no_overlap(c) awful.placement.no_offscreen(c) end end end) client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) -- }}} -- {{{ custom -- Hook called every second mytimer = timer { timeout = 1 } mytimer:add_signal("timeout", function() -- date / time tb_date.text = os.date(" %a, %e %b %X ") -- network in/out local data = ethernet("wlan0") tb_wlan0_in.text = " "..data[1].." " tb_wlan0_out.text = " "..data[2].." " data = ethernet("eth0") tb_eth0_in.text = " "..data[1].." " tb_eth0_out.text = " "..data[2].." " -- cpu graph local cpudata = cpu("cpu ") gr_cpu:plot_data_add('user', cpudata[1] ) gr_cpu:plot_data_add('nice', cpudata[2] ) gr_cpu:plot_data_add('iowait', cpudata[3] ) gr_cpu:plot_data_add('sys', cpudata[4] ) local curfreq = cpufreq('cpu1', 800000, 2400000) gr_cpu:plot_data_add('freq', curfreq ) -- thermal local curtemp = temp(1, 35, 70) gr_thermal:plot_data_add('cputemp', curtemp ) curtemp = temp(2, 35, 70) gr_thermal:plot_data_add('mbtemp', curtemp ) local curfan = ibmfan(0, 6000) gr_thermal:plot_data_add('fan', curfan) local volume = ibmVolume() -- pb_volume:bar_data_add('vol', volume) end) mytimer:start() -- mytimer = timer { timeout = 2 } -- mytimer:add_signal("timeout", function() -- local memdata = memory("/proc/meminfo") -- pb_mem:bar_data_add("mem", memdata[1] ) -- pb_mem:bar_data_add("swap", memdata[2] ) -- end) -- local memdata = memory("/proc/meminfo") -- pb_mem:bar_data_add("mem", memdata[1] ) -- pb_mem:bar_data_add("swap", memdata[2] ) -- mytimer:start() mytimer = timer { timeout = 30 } mytimer:add_signal("timeout", function() --batteryInfo("BAT0", tb_battery) tb_battery.text = battRemaining() local df_data = diskfree("df -P / /home") -- pb_diskfree:bar_data_add("root", df_data[1] ) -- pb_diskfree:bar_data_add("home", df_data[2] ) end) tb_battery.text = battRemaining() local df_data = diskfree("df / /home") pb_diskfree:bar_data_add("root", df_data[1] ) pb_diskfree:bar_data_add("home", df_data[2] ) mytimer:start() -- }}} -- }}} -- vim: et nu foldmethod=marker