1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
9 function table.append(t, ...)
10 for _, v in ipairs({...}) do
15 terminal = "x-terminal-emulator"
16 lock = 'xscreensaver-command -lock'
17 beautiful.init(awful.util.getdir("config").."/theme")
27 k_ms = {modkey, shift}
29 k_mc = {modkey, control}
33 k_cs = {control, shift}
38 -- {{{ Markup helper functions
39 -- Inline markup is a tad ugly, so use these functions
40 -- to dynamically create markup.
41 function fg(color, text)
42 return '<span color="'..color..'">'..text..'</span>'
45 function heading(text)
46 return fg(beautiful.fg_focus, text)
51 -- Toggle whether we're viewing a tag
52 function tag_toggleview(tag)
53 tag:view(not tag:isselected())
56 -- Get the screen number we're on
58 local sel = client.focus
59 return (sel and sel.screen) or mouse.screen
62 -- Move current client to a specific screen
63 function client_movetoscreen(i)
64 client.focus.screen = i
70 for s = 1, screen.count() do
73 eminent.tag.name(i, s, 'work-'..i)
81 maintaglist.buttons = {
82 button(k_n, 1, awful.tag.viewonly),
83 button(k_s, 1, awful.client.toggletag)
89 -- {{{ Load Averages Widget
97 wicked.register(loadwidget, 'function', function (widget, args)
98 -- Use /proc/loadavg to get the average system load on 1, 5 and 15 minute intervals
99 local f = io.open('/proc/loadavg')
103 -- Find the third space
104 local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1)
106 return heading('Load')..': '..n:sub(1,pos-1)
111 -- {{{ CPU Usage Widget
113 cputextwidget = widget({
115 name = 'cputextwidget',
119 cputextwidget.text = heading('CPU')..': 00% '
120 wicked.register(cputextwidget, 'cpu', function (widget, args)
121 local r = tonumber(args[1])
122 local percent = args[1]..'%'
124 percent = '0'..percent
127 percent = fg('green', percent)
129 percent = fg('yellow', percent)
131 percent = fg('orange', percent)
133 percent = fg('red', percent)
135 return heading('CPU')..': '..percent..' '
139 -- {{{ CPU Graph Widget
141 cpugraphwidget = widget({
143 name = 'cpugraphwidget',
147 cpugraphwidget.height = 0.85
148 cpugraphwidget.width = 45
149 cpugraphwidget.bg = '#333333'
150 cpugraphwidget.border_color = '#0a0a0a'
151 cpugraphwidget.grow = 'right'
153 cpugraphwidget:plot_properties_set('cpu', {
155 fg_center = '#285577',
157 vertical_gradient = false
160 wicked.register(cpugraphwidget, 'cpu', '$1', 2, 'cpu')
163 -- {{{ Memory Usage Widget
165 memtextwidget = widget({
167 name = 'memtextwidget',
171 memtextwidget.text = heading('MEM')..': '
172 wicked.register(memtextwidget, 'mem', function (widget, args)
173 -- Add extra preceding zeroes when needed
174 local r = tonumber(args[1])
175 local percent = args[1]..'%'
177 percent = '0'..percent
180 percent = fg('green', percent)
182 percent = fg('orange', percent)
184 percent = fg('red', percent)
186 return heading('MEM')..': '..percent..' '..args[2]..'M'
190 -- {{{ Battery widget
192 batterywidget = widget({
194 name = 'batterywidget',
198 function batterywidget_update()
199 local v = io.popen("powersave -b|sed -ne 's/.*Remaining percent: \\(.*\\)/\\1/p'"):read()
200 local r = tonumber(v)
204 percent = fg('red', percent)
206 percent = fg('orange', percent)
208 percent = fg('green', percent)
210 batterywidget.text = heading('BAT')..': '..percent
212 batterywidget_update()
213 awful.hooks.timer.register(30, batterywidget_update)
218 rspacer = widget({ type = 'textbox', name = 'rspacer', align = 'right' })
223 clockwidget = widget({ type = "textbox", name = "clockwidget", align = "right" })
224 clock_update = function()
225 clockwidget.text = fg("#dddddd", os.date("%a %d %b - %H:%M"))
228 awful.hooks.timer.register(10, clock_update)
232 mymenubox = widget{ type = "textbox", name = "mytextbox", align = "left" }
233 -- mysystray = widget{ type = "systray", name = "mysystray", align = "right" }
239 for s = 1, screen.count() do
240 mainstatusbar[s] = wibox{
243 name = "mainstatusbar" .. s,
246 mainstatusbar[s].widgets = {
247 awful.widget.taglist.new(s, awful.widget.taglist.label.noempty, maintaglist.buttons),
252 rspacer, cputextwidget, cpugraphwidget,
253 rspacer, memtextwidget,
254 rspacer, clockwidget,
255 s == 1 and rspacer or nil,
256 s == 1 and mysystray or nil,
258 mainstatusbar[s].screen = s
267 local hist = os.getenv("HOME") .. "/.cache/awesome/history"
269 -- Mod+{A/S}: Switch to prev/next tag
270 key(k_m, "Left", eminent.tag.prev),
271 key(k_m, "Right", eminent.tag.next),
273 -- Mod+Shift+{A/S}: Move window to Prev/Next tag
274 key(k_ms, "Left", function()
275 awful.client.movetotag(eminent.tag.getprev())
278 key(k_ms, "Right", function()
279 awful.client.movetotag(eminent.tag.getnext())
283 -- Mod+Shift_{E/D}: move window to next/prev screen
284 key(k_mc, "Right", function()
285 local s = getscreen() + 1
286 while s > screen.count() do
289 client_movetoscreen(s)
291 key(k_mc, "Left", function()
292 local s = getscreen() - 1
296 client_movetoscreen(s)
300 -- Focus Prev/Next window
303 awful.client.focus.byidx(1)
304 if client.focus then client.focus:raise() end
308 awful.client.focus.byidx(-1)
309 if client.focus then client.focus:raise() end
312 -- Swap window with the Prev/Next one
313 key(k_ms, "j", function () awful.client.swap.byidx(1) end),
314 key(k_ms, "k", function () awful.client.swap.byidx(-1) end),
316 -- Mod+{E/D}: Switch to next/previous screen
317 key(k_m, "Tab", function () awful.screen.focus(1) end),
318 key(k_ms, "Tab", function () awful.screen.focus(-1) end),
320 -- Mod+Enter: Launch a new terminal
321 key(k_m, "e", function() awful.util.spawn("firefox") end),
322 key(k_m, "Return", function() awful.util.spawn(terminal) end),
323 key(k_ac, "r", awesome.restart),
324 key(k_m, "F12", function() awful.util.spawn(lock) end),
325 key({}, "#148", function() awful.util.spawn("kcalc") end),
327 -- Layout manipulation
328 key(k_m, "l", function () awful.tag.incmwfact(0.05) end),
329 key(k_m, "h", function () awful.tag.incmwfact(-0.05) end),
330 key(k_ms, "h", function () awful.tag.incnmaster(1) end),
331 key(k_ms, "l", function () awful.tag.incnmaster(-1) end),
332 key(k_mc, "h", function () awful.tag.incncol(1) end),
333 key(k_mc, "l", function () awful.tag.incncol(-1) end),
338 awful.prompt.run({ prompt = "Run: " },
341 awful.completion.bash,
342 awful.util.getdir("cache").."/commands")
346 awful.prompt.run({ prompt = "Run Lua code: " },
350 awful.util.getdir("cache").."/lua_commands")
353 key({}, "#192", function() eminent.tag.goto(1, nil, true) end),
354 key({}, "#193", function() eminent.tag.goto(2, nil, true) end),
355 key({}, "#194", function() eminent.tag.goto(3, nil, true) end),
356 key({}, "#195", function() eminent.tag.goto(4, nil, true) end),
357 key({}, "#196", function() eminent.tag.goto(5, nil, true) end),
360 -- Mod+#: Switch to tag
361 -- Mod+Shift+#: Toggle tag display
362 -- Mod+Control+#: Move client to tag
363 -- Mod+Alt+#: Toggle client on tag
366 table.append(globalkeys,
369 eminent.tag.goto(i, nil, true)
374 local t = eminent.tag.getn(i, nil, true)
375 if t ~= nil then t.selected = not t.selected end
379 local t = eminent.tag.getn(i, nil, true)
380 if t ~= nil then awful.client.movetotag(t) end
386 ---- {{{ Client hotkeys
389 key(k_m, "i", function (c)
390 if mymenubox.text then
393 mymenubox.text = "Class: " .. c.class .. " Instance: ".. c.instance
397 -- Client manipulation
398 key(k_m, "c", function (c) c:kill() end),
399 key(k_m, "o", awful.client.floating.toggle),
400 key(k_m, "t", awful.client.togglemarked),
401 key(k_m, "F11", function (c) c.fullscreen = not c.fullscreen end)
406 root.keys(globalkeys)
410 awful.hooks.focus.register(function (c)
411 if not awful.client.ismarked(c) then
412 c.border_color = beautiful.border_focus
416 awful.hooks.unfocus.register(function (c)
417 if not awful.client.ismarked(c) then
418 c.border_color = beautiful.border_normal
422 awful.hooks.marked.register(function (c)
423 c.border_color = beautiful.border_marked
426 awful.hooks.unmarked.register(function (c)
427 c.border_color = beautiful.border_focus
430 -- Hook function to execute when the mouse enters a client.
431 awful.hooks.mouse_enter.register(function (c)
436 awful.hooks.manage.register(function (c, startup)
437 if not startup and awful.client.focus.filter(c) then
438 c.screen = mouse.screen
441 -- Add mouse bindings
443 button({ }, 1, function (c) client.focus = c; c:raise() end),
444 button(k_a, 1, awful.mouse.client.move),
445 button(k_a, 3, awful.mouse.client.resize)
449 c.border_width = beautiful.border_width
450 c.border_color = beautiful.border_normal
452 -- Make certain windows floating
453 local name = c.name:lower()
454 if name:find('pinentry')
455 or name:find('kcalc')
463 c.size_hints_honor = false
466 -- Hook function to execute when arranging the screen
467 -- (tag switch, new client, etc)
468 awful.hooks.arrange.register(function (screen)
469 local sel = client.focus
472 sel = awful.client.focus.history.get(screen, 0)
473 if not sel then return end
477 local o = mouse.object_under_pointer()
478 if not o or (type(o) == "client" and o ~= sel) then
479 local g = sel:geometry()
481 mouse.coords { x = g.x + 5, y = g.y + 5 }
487 awful.util.spawn("xkbcomp -w 0 -R/usr/share/X11/xkb ~/.Xkeyboard :0")