All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
8 -- {{{ Variable definitions
9 -- This is a file path to a theme file which will defines colors.
10 theme_path = "/home/madduck/code/awesome/share/awesome/themes/default"
12 -- This is used later as the default terminal and editor to run.
13 terminal = "x-terminal-emulator"
14 editor = "sensible-editor"
15 editor_cmd = terminal .. " -e " .. editor
18 -- Usually, Mod4 is the key with a logo between Control and Alt.
19 -- If you do not like this or do not have such a key,
20 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
21 -- However, you can use another modifier like Mod1, but it may interact with others.
24 -- Table of layouts to cover with awful.layout.inc, order matters.
40 -- Table of clients that should be set floating. The index may be either
41 -- the application class or instance. The instance is useful when running
42 -- a console app in a terminal like (Music on Console)
43 -- xterm -name mocp -e mocp
44 -- OVERRULED BY TILEDAPPS BELOW
53 ["Play stream"] = true
56 -- Applications that should never float, assuming everything else floats
63 -- Applications that should be maximised
74 -- Applications to be moved to a pre-defined tag by class or instance.
75 -- Use the screen and tags indices.
78 ["Navigator"] = { screen = 1, tag = 9 },
80 ["-v"] = { screen = 1, tag = 8 },
83 -- Define if we want to use titlebar on all applications.
88 -- Initialize theme (colors).
89 beautiful.init(theme_path)
91 -- Register theme in awful.
92 -- This allows to not pass plenty of arguments to each function
93 -- to inform it about colors we want it to draw.
94 awful.beautiful.register(beautiful)
96 -- Uncomment this to activate autotabbing
97 -- tabulous.autotab_start()
101 -- Define tags table.
103 for s = 1, screen.count() do
104 -- Each screen has its own tag table.
106 -- Create 9 tags per screen.
107 for tagnumber = 1, 9 do
108 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[6] })
109 -- Add tags to screen one by one
110 -- split at 0.5/50% exactly
111 -- tags[s][tagnumber].mwfact = 0.5
112 tags[s][tagnumber].screen = s
114 -- I'm sure you want to see at least one tag.
115 tags[s][1].selected = true
120 -- Create a textbox widget
121 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
122 -- Set the default text in textbox
123 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
125 -- Create a laucher widget and a main menu
127 {"manual", terminal .. " -e man awesome" },
128 {"edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
129 {"restart", awesome.restart },
130 {"quit", awesome.quit }
134 {"awesome", myawesomemenu, "/home/madduck/code/awesome/share/awesome/icons/awesome16.png" },
135 {"open terminal", terminal }
138 mylauncher = awful.widget.launcher({ name = "mylauncher",
139 image = "/home/madduck/code/awesome/share/awesome/icons/awesome16.png",
140 menu = { id="mymainmenu", items=mymainmenu } })
143 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
145 -- Create a wibox for each screen and add it
150 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
151 button({ modkey }, 1, awful.client.movetotag),
152 button({ }, 3, function (tag) tag.selected = not tag.selected end),
153 button({ modkey }, 3, awful.client.toggletag),
154 button({ }, 4, awful.tag.viewnext),
155 button({ }, 5, awful.tag.viewprev) }
157 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
158 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
159 button({ }, 4, function () awful.client.focus.byidx(1) end),
160 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
162 for s = 1, screen.count() do
163 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
164 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
165 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
166 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
167 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
168 -- Create a taglist widget
169 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
171 -- Create a tasklist widget
172 mytasklist[s] = awful.widget.tasklist.new(function(c)
173 return awful.widget.tasklist.label.currenttags(c, s)
174 end, mytasklist.buttons)
177 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
178 -- Add widgets to the wibox - order matters
179 mywibox[s].widgets = { mylauncher,
185 s == 1 and mysystray or nil }
186 mywibox[s].screen = s
190 -- Create a textbox widget
191 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
192 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
195 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
196 batterywidget.width = 100
197 batterywidget.height = 0.8
198 batterywidget.gap = 1
199 batterywidget.border_padding = 1
200 batterywidget.border_width = 1
201 batterywidget.ticks_count = 10
202 batterywidget.ticks_gap = 1
203 batterywidget.vertical = false
204 batterywidget:bar_properties_set('bat', {
215 -- {{{ Mouse bindings
217 button({ }, 3, function () awful.menu.new({ id="mymainmenu", items=mymainmenu }) end),
218 button({ }, 4, awful.tag.viewnext),
219 button({ }, 5, awful.tag.viewprev)
225 -- Bind keyboard digits
226 -- Compute the maximum number of digit we need, limited to 9
228 for s = 1, screen.count() do
229 keynumber = math.min(9, math.max(#tags[s], keynumber));
232 for i = 1, keynumber do
233 keybinding({ modkey }, i,
235 local screen = mouse.screen
236 if tags[screen][i] then
237 awful.tag.viewonly(tags[screen][i])
240 keybinding({ modkey, "Control" }, i,
242 local screen = mouse.screen
243 if tags[screen][i] then
244 tags[screen][i].selected = not tags[screen][i].selected
247 keybinding({ modkey, "Shift" }, i,
250 if tags[client.focus.screen][i] then
251 awful.client.movetotag(tags[client.focus.screen][i])
255 keybinding({ modkey, "Control", "Shift" }, i,
258 if tags[client.focus.screen][i] then
259 awful.client.toggletag(tags[client.focus.screen][i])
265 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
266 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
267 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
270 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
272 keybinding({ modkey, "Control" }, "r", function ()
273 mypromptbox[mouse.screen].text =
274 awful.util.escape(awful.util.restart())
276 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
278 -- Client manipulation
279 keybinding({ modkey }, "m", awful.client.maximize):add()
280 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
281 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
282 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
283 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
284 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
285 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
286 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
287 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
288 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
289 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
290 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
291 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
292 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
293 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
295 -- Layout manipulation
296 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
297 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
298 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
299 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
300 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
301 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
302 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
303 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
306 keybinding({ modkey }, "F1", function ()
307 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
308 awful.util.getdir("cache") .. "/history")
310 keybinding({ modkey }, "F4", function ()
311 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
312 awful.util.getdir("cache") .. "/history_eval")
315 keybinding({ modkey, "Ctrl" }, "i", function ()
316 local s = mouse.screen
317 if mypromptbox[s].text then
318 mypromptbox[s].text = nil
320 mypromptbox[s].text = nil
321 if client.focus.class then
322 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
324 if client.focus.instance then
325 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
327 if client.focus.role then
328 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
333 --- Tabulous, tab manipulation
334 keybinding({ modkey, "Control" }, "y", function ()
335 local tabbedview = tabulous.tabindex_get()
336 local nextclient = awful.client.next(1)
338 if not tabbedview then
339 tabbedview = tabulous.tabindex_get(nextclient)
341 if not tabbedview then
342 tabbedview = tabulous.tab_create()
343 tabulous.tab(tabbedview, nextclient)
345 tabulous.tab(tabbedview, client.focus)
348 tabulous.tab(tabbedview, nextclient)
352 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
354 keybinding({ modkey }, "y", function ()
355 local tabbedview = tabulous.tabindex_get()
358 local n = tabulous.next(tabbedview)
359 tabulous.display(tabbedview, n)
363 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
364 keybinding({ modkey }, "t", awful.client.togglemarked):add()
365 keybinding({ modkey, 'Shift' }, "t", function ()
366 local tabbedview = tabulous.tabindex_get()
367 local clients = awful.client.getmarked()
369 if not tabbedview then
370 tabbedview = tabulous.tab_create(clients[1])
371 table.remove(clients, 1)
374 for k,c in pairs(clients) do
375 tabulous.tab(tabbedview, c)
380 for i = 1, keynumber do
381 keybinding({ modkey, "Shift" }, "F" .. i,
383 local screen = mouse.screen
384 if tags[screen][i] then
385 for k, c in pairs(awful.client.getmarked()) do
386 awful.client.movetotag(tags[screen][i], c)
394 -- Hook function to execute when focusing a client.
395 awful.hooks.focus.register(function (c)
396 if not awful.client.ismarked(c) then
397 c.border_color = beautiful.border_focus
401 -- Hook function to execute when unfocusing a client.
402 awful.hooks.unfocus.register(function (c)
403 if not awful.client.ismarked(c) then
404 c.border_color = beautiful.border_normal
408 -- Hook function to execute when marking a client
409 awful.hooks.marked.register(function (c)
410 c.border_color = beautiful.border_marked
413 -- Hook function to execute when unmarking a client.
414 awful.hooks.unmarked.register(function (c)
415 c.border_color = beautiful.border_focus
418 -- Hook function to execute when the mouse enters a client.
419 awful.hooks.mouse_enter.register(function (c)
420 -- Sloppy focus, but disabled for magnifier layout
421 if awful.layout.get(c.screen) ~= "magnifier"
422 and awful.client.focus.filter(c) then
427 -- Hook function to execute when a new client appears.
428 awful.hooks.manage.register(function (c)
431 awful.titlebar.add(c, { modkey = modkey })
433 -- Add mouse bindings
435 button({ }, 1, function (c) client.focus = c; c:raise() end),
436 button({ modkey }, 1, function (c) c:mouse_move() end),
437 button({ modkey }, 3, function (c) c:mouse_resize() end)
439 -- New client may not receive focus
440 -- if they're not focusable, so set border anyway.
441 c.border_width = beautiful.border_width
442 c.border_color = beautiful.border_normal
445 -- Check if the application should be floating.
446 -- OVERRIDDEN, SEE tiledapps BELOW
448 local inst = c.instance
449 if floatapps[cls] then
450 c.floating = floatapps[cls]
451 elseif floatapps[inst] then
452 c.floating = floatapps[inst]
455 -- Override with tiledapps
456 c.floating = not (tiledapps[inst] or tiledapps[cls])
458 -- Check application->screen/tag mappings.
461 target = apptags[cls]
462 elseif apptags[inst] then
463 target = apptags[inst]
466 c.screen = target.screen
467 awful.client.movetotag(tags[target.screen][target.tag], c)
470 -- Set the windows at the slave,
471 -- i.e. put it at the end of others instead of setting it master.
472 -- awful.client.setslave(c)
474 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
475 c.honorsizehints = true
478 if maxapps[inst] or maxapps[cls] then
479 awful.client.maximize(c)
483 -- Hook function to execute when arranging the screen.
484 -- (tag switch, new client, etc)
485 awful.hooks.arrange.register(function (screen)
486 local layout = awful.layout.get(screen)
488 mylayoutbox[screen].image = image("/home/madduck/code/awesome/share/awesome/icons/layouts/" .. layout .. "w.png")
490 mylayoutbox[screen].image = nil
493 -- Give focus to the latest client in history if no window has focus
494 -- or if the current window is a desktop or a dock one.
495 if not client.focus then
496 local c = awful.client.focus.history.get(screen, 0)
497 if c then client.focus = c end
500 -- Uncomment if you want mouse warping
503 local c_c = client.focus:geometry()
504 local m_c = mouse.coords()
506 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
507 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
508 if table.maxn(m_c.buttons) == 0 then
509 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
516 -- Hook called every second
517 awful.hooks.timer.register(1, function ()
518 -- For unix time_t lovers
519 -- mytextbox.text = " " .. os.time() .. " time_t "
521 mytimebox.text = " " .. os.date() .. " "
524 -- Hook called every sixty seconds
525 function hook_battery()
526 mybatterybox.text = " " .. get_acpibatt() .. " "
529 -- {{{ Statusbar battery
531 function get_acpibatt()
533 local f = io.popen('acpi -b', 'r')
535 return "acpi -b failed"
538 local s = f:read('*l')
544 -- Battery 0: Discharging, 89%, 00:02:14 remaining
545 -- Battery 0: Charging, 58%, 00:02:14 until charged
546 -- Battery 0: Full, 100%
547 -- so find the first bit first and then go look for the time
548 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
549 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
551 if not status or not percent then -- time can be empty if we're full
552 return "couldn't parse line " .. s
559 if status == 'Charging' then
561 elseif status == 'Discarching' then
567 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
572 local function get_bat()
573 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
574 for line in a:lines() do
578 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
579 for line in b:lines() do
583 batt=math.floor(now*100/full)
584 batterywidget:bar_data_add("bat",batt )
589 awful.hooks.timer.register(120, hook_battery)
590 -- awful.hooks.timer.register(5, get_bat)
596 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
597 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
598 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
599 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
600 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
601 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
602 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
603 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
604 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
605 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
606 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
609 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
610 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
611 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
612 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
613 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
614 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
615 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
616 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
618 -- Highlight statusbars on the screen that has focus,
619 -- set this to false if you only have one screen or
620 -- you don't like it :P
621 if screen.count() > 1 then
622 statusbar_highlight_focus = true
624 statusbar_highlight_focus = false