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 Average Widget
85 loadwidget = widget({ type = 'textbox' })
86 load_update = function()
87 -- Use /proc/loadavg to get the average system load on 1, 5 and 15 minute intervals
88 local f = io.open('/proc/loadavg')
92 -- Find the third space
93 local pos = n:find(' ', n:find(' ', n:find(' ')+1)+1)
95 loadwidget.text = heading('Load')..': '..n:sub(1,pos-1)
99 t = timer { timeout = 10 }
100 t:add_signal("timeout", load_update)
104 -- {{{ CPU Usage Widget
106 cputextwidget = widget({ type = 'textbox' })
107 cpugraphwidget = awful.widget.graph{
108 width = 40, height = 16,
109 layout = awful.widget.layout.horizontal.rightleft
111 cpugraphwidget:set_background_color('#333333')
112 cpugraphwidget:set_border_color('#0a0a0a')
113 cpugraphwidget:set_gradient_colors({ '#285577', '#285577', '#AEC6D8' })
115 vicious.register(cputextwidget, vicious.widgets.cpu,
116 function (widget, args)
117 local r = tonumber(args[1])
118 local percent = args[1]..'%'
120 percent = '0'..percent
123 percent = fg('green', percent)
125 percent = fg('yellow', percent)
127 percent = fg('orange', percent)
129 percent = fg('red', percent)
131 cpugraphwidget:add_value(r / 100)
132 return heading('CPU')..': '..percent..' '
136 -- {{{ CPU Graph Widget
139 -- {{{ Memory Usage Widget
141 memtextwidget = widget({ type = 'textbox' })
143 memtextwidget.text = heading('MEM')..': '
144 vicious.register(memtextwidget, vicious.widgets.mem, function (widget, args)
145 -- Add extra preceding zeroes when needed
146 local r = tonumber(args[1])
147 local percent = args[1]..'%'
149 percent = '0'..percent
152 percent = fg('green', percent)
154 percent = fg('orange', percent)
156 percent = fg('red', percent)
158 return heading('MEM')..': '..percent..' '..args[2]..'M'
164 rspacer = widget({ type = 'textbox' })
170 clockwidget = widget({ type = "textbox" })
171 vicious.register(clockwidget, vicious.widgets.date, fg("#dddddd", "%a %d %b - %H:%M"), 10)
175 mymenubox = widget{ type = "textbox" }
181 for s = 1, screen.count() do
182 mainstatusbar[s] = awful.wibox{ position = "top", height = 18, screen = s }
184 mainstatusbar[s].widgets = {
186 awful.widget.taglist(s, awful.widget.taglist.label.noempty, maintaglist.buttons),
188 awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright }),
189 layout = awful.widget.layout.horizontal.leftright
191 clockwidget, rspacer,
192 memtextwidget, rspacer,
193 cpugraphwidget, cputextwidget, rspacer,
195 layout = awful.widget.layout.horizontal.rightleft
205 local hist = os.getenv("HOME") .. "/.cache/awesome/history"
206 globalkeys = awful.util.table.join(
207 -- Mod+{A/S}: Switch to prev/next tag
208 awful.key(k_m, "Left", eminent.tag.prev),
209 awful.key(k_m, "Right", eminent.tag.next),
211 -- Mod+Shift+{A/S}: Move window to Prev/Next tag
212 awful.key(k_ms, "Left", function()
213 awful.client.movetotag(eminent.tag.getprev())
216 awful.key(k_ms, "Right", function()
217 awful.client.movetotag(eminent.tag.getnext())
221 -- Mod+Shift_{E/D}: move window to next/prev screen
222 awful.key(k_mc, "Right", function()
223 local s = getscreen() + 1
224 while s > screen.count() do
227 client_movetoscreen(s)
229 awful.key(k_mc, "Left", function()
230 local s = getscreen() - 1
234 client_movetoscreen(s)
238 -- Focus Prev/Next window
241 awful.client.focus.byidx(1)
242 if client.focus then client.focus:raise() end
246 awful.client.focus.byidx(-1)
247 if client.focus then client.focus:raise() end
250 -- Swap window with the Prev/Next one
251 awful.key(k_ms, "j", function () awful.client.swap.byidx(1) end),
252 awful.key(k_ms, "k", function () awful.client.swap.byidx(-1) end),
254 -- Mod+{E/D}: Switch to next/previous screen
255 awful.key(k_m, "Tab", function () awful.screen.focus(1) end),
256 awful.key(k_ms, "Tab", function () awful.screen.focus(-1) end),
258 -- Mod+Enter: Launch a new terminal
259 awful.key(k_m, "e", function() awful.util.spawn("firefox") end),
260 awful.key(k_m, "Return", function() awful.util.spawn(terminal) end),
261 awful.key(k_ac, "r", awesome.restart),
262 awful.key(k_m, "F12", function() awful.util.spawn(lock) end),
263 awful.key({}, "#148", function() awful.util.spawn("kcalc") end),
265 -- Layout manipulation
266 awful.key(k_m, "l", function () awful.tag.incmwfact(0.05) end),
267 awful.key(k_m, "h", function () awful.tag.incmwfact(-0.05) end),
268 awful.key(k_ms, "h", function () awful.tag.incnmaster(1) end),
269 awful.key(k_ms, "l", function () awful.tag.incnmaster(-1) end),
270 awful.key(k_mc, "h", function () awful.tag.incncol(1) end),
271 awful.key(k_mc, "l", function () awful.tag.incncol(-1) end),
276 awful.prompt.run({ prompt = "Run: " },
279 awful.completion.shell,
280 awful.util.getdir("cache").."/commands")
284 awful.prompt.run({ prompt = "Run Lua code: " },
288 awful.util.getdir("cache").."/lua_commands")
291 awful.key({}, "#192", function() eminent.tag.goto(1, nil, true) end),
292 awful.key({}, "#193", function() eminent.tag.goto(2, nil, true) end),
293 awful.key({}, "#194", function() eminent.tag.goto(3, nil, true) end),
294 awful.key({}, "#195", function() eminent.tag.goto(4, nil, true) end),
295 awful.key({}, "#196", function() eminent.tag.goto(5, nil, true) end)
298 -- Mod+#: Switch to tag
299 -- Mod+Shift+#: Toggle tag display
300 -- Mod+Control+#: Move client to tag
301 -- Mod+Alt+#: Toggle client on tag
304 globalkeys = awful.util.table.join(
306 awful.key(k_m, i % 10,
308 eminent.tag.goto(i, nil, true)
311 awful.key(k_ms, i % 10,
313 local t = eminent.tag.getn(i, nil, true)
314 if t ~= nil then t.selected = not t.selected end
316 awful.key(k_mc, i % 10,
318 local t = eminent.tag.getn(i, nil, true)
319 if t ~= nil then awful.client.movetotag(t) end
325 ---- {{{ Client hotkeys
327 clientkeys = awful.util.table.join(
328 awful.key(k_m, "i", function (c)
329 if mymenubox.text then
332 mymenubox.text = "Class: " .. c.class .. " Instance: ".. c.instance
336 -- Client manipulation
337 awful.key(k_m, "c", function (c) c:kill() end),
338 awful.key(k_m, "o", awful.client.floating.toggle),
339 awful.key(k_m, "t", awful.client.togglemarked),
340 awful.key(k_m, "F11", function (c) c.fullscreen = not c.fullscreen end)
345 root.keys(globalkeys)
349 client.add_signal("focus", function (c)
350 if not awful.client.ismarked(c) then
351 c.border_color = beautiful.border_focus
355 client.add_signal("unfocus", function (c)
356 if not awful.client.ismarked(c) then
357 c.border_color = beautiful.border_normal
361 client.add_signal("marked", function (c)
362 c.border_color = beautiful.border_marked
365 client.add_signal("unmarked", function (c)
366 c.border_color = beautiful.border_focus
369 client.add_signal("manage", function (c, startup)
370 if not startup and awful.client.focus.filter(c) then
371 c.screen = mouse.screen
374 -- Add mouse bindings
375 c:buttons(awful.util.table.join(
376 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
377 awful.button(k_a, 1, awful.mouse.client.move),
378 awful.button(k_a, 3, awful.mouse.client.resize)
381 -- Enable sloppy focus
382 c:add_signal("mouse::enter", function(c)
387 c.border_width = beautiful.border_width
388 c.border_color = beautiful.border_normal
390 -- Make certain windows floating
391 local class = c.class:lower()
392 if class:find('pinentry')
393 or class:find('kcalc')
394 or class:find('gajim')
402 c.size_hints_honor = false
405 -- Hook function to execute when arranging the screen
406 -- (tag switch, new client, etc)
407 client.add_signal("arrange", function (screen)
408 local sel = client.focus
411 sel = awful.client.focus.history.get(screen, 0)
412 if not sel then return end
416 local o = mouse.object_under_pointer()
417 if not o or (type(o) == "client" and o ~= sel) then
418 local g = sel:geometry()
420 mouse.coords { x = g.x + 5, y = g.y + 5 }
426 awful.util.spawn("xkbcomp -w 0 -R/usr/share/X11/xkb /home/madcoder/.Xkeyboard :0")