1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
9 terminal = "x-terminal-emulator"
10 lock = 'xscreensaver-command -lock'
11 beautiful.init(awful.util.getdir("config").."/theme")
21 k_ms = {modkey, shift}
23 k_mc = {modkey, control}
27 k_cs = {control, shift}
32 -- {{{ Markup helper functions
33 -- Inline markup is a tad ugly, so use these functions
34 -- to dynamically create markup.
35 function fg(color, text)
36 return '<span color="'..color..'">'..text..'</span>'
39 function heading(text)
40 return fg(beautiful.fg_focus, text)
45 -- Toggle whether we're viewing a tag
46 function tag_toggleview(tag)
47 tag:view(not tag:isselected())
50 -- Get the screen number we're on
52 local sel = client.focus
53 return (sel and sel.screen) or mouse.screen
56 -- Move current client to a specific screen
57 function client_movetoscreen(i)
58 client.focus.screen = i
64 for s = 1, screen.count() do
67 eminent.tag.name(i, s, 'work-'..i)
75 maintaglist.buttons = awful.util.table.join(
76 awful.button(k_n, 1, awful.tag.viewonly),
77 awful.button(k_s, 1, awful.client.toggletag)
83 -- {{{ Load Averages Widget
91 wicked.register(loadwidget, 'function', function (widget, args)
92 -- Use /proc/loadavg to get the average system load on 1, 5 and 15 minute intervals
93 local f = io.open('/proc/loadavg')
97 -- Find the third space
98 local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1)
100 return heading('Load')..': '..n:sub(1,pos-1)
105 -- {{{ CPU Usage Widget
107 cputextwidget = widget({
109 name = 'cputextwidget',
113 cputextwidget.text = heading('CPU')..': 00% '
114 wicked.register(cputextwidget, 'cpu', function (widget, args)
115 local r = tonumber(args[1])
116 local percent = args[1]..'%'
118 percent = '0'..percent
121 percent = fg('green', percent)
123 percent = fg('yellow', percent)
125 percent = fg('orange', percent)
127 percent = fg('red', percent)
129 return heading('CPU')..': '..percent..' '
133 -- {{{ CPU Graph Widget
135 cpugraphwidget = widget({
137 name = 'cpugraphwidget',
141 cpugraphwidget.height = 0.85
142 cpugraphwidget.width = 45
143 cpugraphwidget.bg = '#333333'
144 cpugraphwidget.border_color = '#0a0a0a'
145 cpugraphwidget.grow = 'right'
147 cpugraphwidget:plot_properties_set('cpu', {
149 fg_center = '#285577',
151 vertical_gradient = false
154 wicked.register(cpugraphwidget, 'cpu', '$1', 2, 'cpu')
157 -- {{{ Memory Usage Widget
159 memtextwidget = widget({
161 name = 'memtextwidget',
165 memtextwidget.text = heading('MEM')..': '
166 wicked.register(memtextwidget, 'mem', function (widget, args)
167 -- Add extra preceding zeroes when needed
168 local r = tonumber(args[1])
169 local percent = args[1]..'%'
171 percent = '0'..percent
174 percent = fg('green', percent)
176 percent = fg('orange', percent)
178 percent = fg('red', percent)
180 return heading('MEM')..': '..percent..' '..args[2]..'M'
184 -- {{{ Battery widget
186 batterywidget = widget({
188 name = 'batterywidget',
192 function batterywidget_update()
193 local v = io.popen("powersave -b|sed -ne 's/.*Remaining percent: \\(.*\\)/\\1/p'"):read()
194 local r = tonumber(v)
198 percent = fg('red', percent)
200 percent = fg('orange', percent)
202 percent = fg('green', percent)
204 batterywidget.text = heading('BAT')..': '..percent
206 batterywidget_update()
207 awful.hooks.timer.register(30, batterywidget_update)
212 rspacer = widget({ type = 'textbox', name = 'rspacer', align = 'right' })
217 clockwidget = widget({ type = "textbox", name = "clockwidget", align = "right" })
218 clock_update = function()
219 clockwidget.text = fg("#dddddd", os.date("%a %d %b - %H:%M"))
222 awful.hooks.timer.register(10, clock_update)
226 mymenubox = widget{ type = "textbox", name = "mytextbox", align = "left" }
232 for s = 1, screen.count() do
233 mainstatusbar[s] = wibox{
236 name = "mainstatusbar" .. s,
239 mainstatusbar[s].widgets = {
240 awful.widget.taglist.new(s, awful.widget.taglist.label.noempty, maintaglist.buttons),
245 rspacer, cputextwidget, cpugraphwidget,
246 rspacer, memtextwidget,
247 rspacer, clockwidget,
249 mainstatusbar[s].screen = s
258 local hist = os.getenv("HOME") .. "/.cache/awesome/history"
259 globalkeys = awful.util.table.join(
260 -- Mod+{A/S}: Switch to prev/next tag
261 awful.key(k_m, "Left", eminent.tag.prev),
262 awful.key(k_m, "Right", eminent.tag.next),
264 -- Mod+Shift+{A/S}: Move window to Prev/Next tag
265 awful.key(k_ms, "Left", function()
266 awful.client.movetotag(eminent.tag.getprev())
269 awful.key(k_ms, "Right", function()
270 awful.client.movetotag(eminent.tag.getnext())
274 -- Mod+Shift_{E/D}: move window to next/prev screen
275 awful.key(k_mc, "Right", function()
276 local s = getscreen() + 1
277 while s > screen.count() do
280 client_movetoscreen(s)
282 awful.key(k_mc, "Left", function()
283 local s = getscreen() - 1
287 client_movetoscreen(s)
291 -- Focus Prev/Next window
294 awful.client.focus.byidx(1)
295 if client.focus then client.focus:raise() end
299 awful.client.focus.byidx(-1)
300 if client.focus then client.focus:raise() end
303 -- Swap window with the Prev/Next one
304 awful.key(k_ms, "j", function () awful.client.swap.byidx(1) end),
305 awful.key(k_ms, "k", function () awful.client.swap.byidx(-1) end),
307 -- Mod+{E/D}: Switch to next/previous screen
308 awful.key(k_m, "Tab", function () awful.screen.focus(1) end),
309 awful.key(k_ms, "Tab", function () awful.screen.focus(-1) end),
311 -- Mod+Enter: Launch a new terminal
312 awful.key(k_m, "e", function() awful.util.spawn("firefox") end),
313 awful.key(k_m, "Return", function() awful.util.spawn(terminal) end),
314 awful.key(k_ac, "r", awesome.restart),
315 awful.key(k_m, "F12", function() awful.util.spawn(lock) end),
316 awful.key({}, "#148", function() awful.util.spawn("kcalc") end),
318 -- Layout manipulation
319 awful.key(k_m, "l", function () awful.tag.incmwfact(0.05) end),
320 awful.key(k_m, "h", function () awful.tag.incmwfact(-0.05) end),
321 awful.key(k_ms, "h", function () awful.tag.incnmaster(1) end),
322 awful.key(k_ms, "l", function () awful.tag.incnmaster(-1) end),
323 awful.key(k_mc, "h", function () awful.tag.incncol(1) end),
324 awful.key(k_mc, "l", function () awful.tag.incncol(-1) end),
329 awful.prompt.run({ prompt = "Run: " },
332 awful.completion.bash,
333 awful.util.getdir("cache").."/commands")
337 awful.prompt.run({ prompt = "Run Lua code: " },
341 awful.util.getdir("cache").."/lua_commands")
344 awful.key({}, "#192", function() eminent.tag.goto(1, nil, true) end),
345 awful.key({}, "#193", function() eminent.tag.goto(2, nil, true) end),
346 awful.key({}, "#194", function() eminent.tag.goto(3, nil, true) end),
347 awful.key({}, "#195", function() eminent.tag.goto(4, nil, true) end),
348 awful.key({}, "#196", function() eminent.tag.goto(5, nil, true) end)
351 -- Mod+#: Switch to tag
352 -- Mod+Shift+#: Toggle tag display
353 -- Mod+Control+#: Move client to tag
354 -- Mod+Alt+#: Toggle client on tag
357 globalkeys = awful.util.table.join(
359 awful.key(k_m, i % 10,
361 eminent.tag.goto(i, nil, true)
364 awful.key(k_ms, i % 10,
366 local t = eminent.tag.getn(i, nil, true)
367 if t ~= nil then t.selected = not t.selected end
369 awful.key(k_mc, i % 10,
371 local t = eminent.tag.getn(i, nil, true)
372 if t ~= nil then awful.client.movetotag(t) end
378 ---- {{{ Client hotkeys
380 clientkeys = awful.util.table.join(
381 awful.key(k_m, "i", function (c)
382 if mymenubox.text then
385 mymenubox.text = "Class: " .. c.class .. " Instance: ".. c.instance
389 -- Client manipulation
390 awful.key(k_m, "c", function (c) c:kill() end),
391 awful.key(k_m, "o", awful.client.floating.toggle),
392 awful.key(k_m, "t", awful.client.togglemarked),
393 awful.key(k_m, "F11", function (c) c.fullscreen = not c.fullscreen end)
398 root.keys(globalkeys)
402 awful.hooks.focus.register(function (c)
403 if not awful.client.ismarked(c) then
404 c.border_color = beautiful.border_focus
408 awful.hooks.unfocus.register(function (c)
409 if not awful.client.ismarked(c) then
410 c.border_color = beautiful.border_normal
414 awful.hooks.marked.register(function (c)
415 c.border_color = beautiful.border_marked
418 awful.hooks.unmarked.register(function (c)
419 c.border_color = beautiful.border_focus
422 -- Hook function to execute when the mouse enters a client.
423 awful.hooks.mouse_enter.register(function (c)
428 awful.hooks.manage.register(function (c, startup)
429 if not startup and awful.client.focus.filter(c) then
430 c.screen = mouse.screen
433 -- Add mouse bindings
434 c:buttons(awful.util.table.join(
435 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
436 awful.button(k_a, 1, awful.mouse.client.move),
437 awful.button(k_a, 3, awful.mouse.client.resize)
441 c.border_width = beautiful.border_width
442 c.border_color = beautiful.border_normal
444 -- Make certain windows floating
445 local class = c.class:lower()
446 if class:find('pinentry')
447 or class:find('kcalc')
448 or class:find('gajim')
456 c.size_hints_honor = false
459 -- Hook function to execute when arranging the screen
460 -- (tag switch, new client, etc)
461 awful.hooks.arrange.register(function (screen)
462 local sel = client.focus
465 sel = awful.client.focus.history.get(screen, 0)
466 if not sel then return end
470 local o = mouse.object_under_pointer()
471 if not o or (type(o) == "client" and o ~= sel) then
472 local g = sel:geometry()
474 mouse.coords { x = g.x + 5, y = g.y + 5 }
480 awful.util.spawn("xkbcomp -w 0 -R/usr/share/X11/xkb /home/madcoder/.Xkeyboard :0")