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 -- Include awesome libraries, with lots of useful function!
5 -- {{{ Variable definitions
6 -- Themes define colours, icons, and wallpapers
7 -- The default is a dark theme
8 theme_path = "/home/madduck/code/awesome/share/awesome/themes/default/theme"
9 -- Uncommment this for a lighter theme
10 -- theme_path = "/home/madduck/code/awesome/share/awesome/themes/sky/theme"
12 -- Actually load theme
13 beautiful.init(theme_path)
15 -- This is used later as the default terminal and editor to run.
16 terminal = "x-terminal-emulator"
17 editor = "sensible-editor"
18 editor_cmd = terminal .. " -e " .. editor
21 -- Usually, Mod4 is the key with a logo between Control and Alt.
22 -- If you do not like this or do not have such a key,
23 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
24 -- However, you can use another modifier like Mod1, but it may interact with others.
27 -- Table of layouts to cover with awful.layout.inc, order matters.
44 -- Table of clients that should be set floating. The index may be either
45 -- the application class or instance. The instance is useful when running
46 -- a console app in a terminal like (Music on Console)
47 -- xterm -name mocp -e mocp
48 -- OVERRULED BY TILEDAPPS BELOW
57 ["Play stream"] = true,
60 -- Applications that should never float, assuming everything else floats
67 -- Applications that should be maximised
78 -- Applications to be moved to a pre-defined tag by class or instance.
79 -- Use the screen and tags indices.
82 ["Navigator"] = { screen = 1, tag = 9 },
84 ["-v"] = { screen = 1, tag = 8 },
87 -- Define if we want to use titlebar on all applications.
94 for s = 1, screen.count() do
95 -- Each screen has its own tag table.
97 -- Create 9 tags per screen.
98 for tagnumber = 1, 9 do
99 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[6] })
100 -- Add tags to screen one by one
101 -- split at 0.5/50% exactly
102 -- tags[s][tagnumber].mwfact = 0.5
103 tags[s][tagnumber].screen = s
105 -- I'm sure you want to see at least one tag.
106 tags[s][1].selected = true
111 -- Create a textbox widget
112 mytextbox = widget({ type = "textbox", align = "right" })
113 -- Set the default text in textbox
114 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
116 -- Create a laucher widget and a main menu
118 { "manual", terminal .. " -e man awesome" },
119 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
120 { "restart", awesome.restart },
121 { "quit", awesome.quit }
124 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
125 { "open terminal", terminal }
129 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
133 mysystray = widget({ type = "systray", align = "right" })
135 -- Create textbox widgets
136 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
137 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
139 -- Create a wibox for each screen and add it
144 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
145 button({ modkey }, 1, awful.client.movetotag),
146 button({ }, 3, function (tag) tag.selected = not tag.selected end),
147 button({ modkey }, 3, awful.client.toggletag),
148 button({ }, 4, awful.tag.viewnext),
149 button({ }, 5, awful.tag.viewprev) }
151 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
152 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
153 button({ }, 4, function () awful.client.focus.byidx(1) end),
154 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
156 for s = 1, screen.count() do
157 -- Create a promptbox for each screen
158 mypromptbox[s] = widget({ type = "textbox", align = "left" })
159 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
160 -- We need one layoutbox per screen.
161 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
162 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
163 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
164 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
165 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
166 -- Create a taglist widget
167 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
169 -- Create a tasklist widget
170 mytasklist[s] = awful.widget.tasklist.new(function(c)
171 return awful.widget.tasklist.label.currenttags(c, s)
172 end, mytasklist.buttons)
175 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
176 -- Add widgets to the wibox - order matters
177 mywibox[s].widgets = { mytaglist[s],
183 s == screen.count() and mysystray or nil }
184 mywibox[s].screen = s
189 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
190 batterywidget.width = 100
191 batterywidget.height = 0.8
192 batterywidget.gap = 1
193 batterywidget.border_padding = 1
194 batterywidget.border_width = 1
195 batterywidget.ticks_count = 10
196 batterywidget.ticks_gap = 1
197 batterywidget.vertical = false
198 batterywidget:bar_properties_set('bat', {
209 -- {{{ Mouse bindings
211 button({ }, 3, function () mymainmenu:toggle() end),
212 button({ }, 4, awful.tag.viewnext),
213 button({ }, 5, awful.tag.viewprev)
219 -- Bind keyboard digits
220 -- Compute the maximum number of digit we need, limited to 9
222 for s = 1, screen.count() do
223 keynumber = math.min(9, math.max(#tags[s], keynumber));
226 for i = 1, keynumber do
227 keybinding({ modkey }, i,
229 local screen = mouse.screen
230 if tags[screen][i] then
231 awful.tag.viewonly(tags[screen][i])
234 keybinding({ modkey, "Control" }, i,
236 local screen = mouse.screen
237 if tags[screen][i] then
238 tags[screen][i].selected = not tags[screen][i].selected
241 keybinding({ modkey, "Shift" }, i,
244 if tags[client.focus.screen][i] then
245 awful.client.movetotag(tags[client.focus.screen][i])
249 keybinding({ modkey, "Control", "Shift" }, i,
252 if tags[client.focus.screen][i] then
253 awful.client.toggletag(tags[client.focus.screen][i])
259 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
260 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
261 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
264 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
266 keybinding({ modkey, "Control" }, "r", function ()
267 mypromptbox[mouse.screen].text =
268 awful.util.escape(awful.util.restart())
270 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
272 -- Client manipulation
273 keybinding({ modkey }, "m", awful.client.maximize):add()
274 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
275 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
276 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
277 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
278 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end):add()
279 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
280 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
281 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
282 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
283 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.getmaster()) end):add()
284 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
285 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
286 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
287 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
289 -- Layout manipulation
290 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
291 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
292 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
293 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
294 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
295 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
296 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
297 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
300 keybinding({ modkey }, "F1", function ()
301 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
302 awful.util.getdir("cache") .. "/history")
304 keybinding({ modkey }, "F4", function ()
305 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
306 awful.util.getdir("cache") .. "/history_eval")
309 keybinding({ modkey, "Ctrl" }, "i", function ()
310 local s = mouse.screen
311 if mypromptbox[s].text then
312 mypromptbox[s].text = nil
314 mypromptbox[s].text = nil
315 if client.focus.class then
316 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
318 if client.focus.instance then
319 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
321 if client.focus.role then
322 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
327 --- Tabulous, tab manipulation
329 keybinding({ modkey, "Control" }, "y", function ()
330 local tabbedview = tabulous.tabindex_get()
331 local nextclient = awful.client.next(1)
333 if not tabbedview then
334 tabbedview = tabulous.tabindex_get(nextclient)
336 if not tabbedview then
337 tabbedview = tabulous.tab_create()
338 tabulous.tab(tabbedview, nextclient)
340 tabulous.tab(tabbedview, client.focus)
343 tabulous.tab(tabbedview, nextclient)
347 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
349 keybinding({ modkey }, "y", function ()
350 local tabbedview = tabulous.tabindex_get()
353 local n = tabulous.next(tabbedview)
354 tabulous.display(tabbedview, n)
358 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
359 keybinding({ modkey }, "t", awful.client.togglemarked):add()
360 keybinding({ modkey, 'Shift' }, "t", function ()
361 local tabbedview = tabulous.tabindex_get()
362 local clients = awful.client.getmarked()
364 if not tabbedview then
365 tabbedview = tabulous.tab_create(clients[1])
366 table.remove(clients, 1)
369 for k,c in pairs(clients) do
370 tabulous.tab(tabbedview, c)
375 for i = 1, keynumber do
376 keybinding({ modkey, "Shift" }, "F" .. i,
378 local screen = mouse.screen
379 if tags[screen][i] then
380 for k, c in pairs(awful.client.getmarked()) do
381 awful.client.movetotag(tags[screen][i], c)
389 -- Hook function to execute when focusing a client.
390 awful.hooks.focus.register(function (c)
391 if not awful.client.ismarked(c) then
392 c.border_color = beautiful.border_focus
396 -- Hook function to execute when unfocusing a client.
397 awful.hooks.unfocus.register(function (c)
398 if not awful.client.ismarked(c) then
399 c.border_color = beautiful.border_normal
403 -- Hook function to execute when marking a client
404 awful.hooks.marked.register(function (c)
405 c.border_color = beautiful.border_marked
408 -- Hook function to execute when unmarking a client.
409 awful.hooks.unmarked.register(function (c)
410 c.border_color = beautiful.border_focus
413 -- Hook function to execute when the mouse enters a client.
414 awful.hooks.mouse_enter.register(function (c)
415 -- Sloppy focus, but disabled for magnifier layout
416 if awful.layout.get(c.screen) ~= "magnifier"
417 and awful.client.focus.filter(c) then
422 -- Hook function to execute when a new client appears.
423 awful.hooks.manage.register(function (c)
426 awful.titlebar.add(c, { modkey = modkey })
428 -- Add mouse bindings
430 button({ }, 1, function (c) client.focus = c; c:raise() end),
431 button({ modkey }, 1, function (c) c:mouse_move() end),
432 button({ modkey }, 3, function (c) c:mouse_resize() end)
434 -- New client may not receive focus
435 -- if they're not focusable, so set border anyway.
436 c.border_width = beautiful.border_width
437 c.border_color = beautiful.border_normal
439 -- Check if the application should be floating.
440 -- OVERRIDDEN, SEE tiledapps BELOW
442 local inst = c.instance
443 if floatapps[cls] then
444 c.floating = floatapps[cls]
445 elseif floatapps[inst] then
446 c.floating = floatapps[inst]
449 -- Override with tiledapps
450 c.floating = not (tiledapps[inst] or tiledapps[cls])
452 -- Check application->screen/tag mappings.
455 target = apptags[cls]
456 elseif apptags[inst] then
457 target = apptags[inst]
460 c.screen = target.screen
461 awful.client.movetotag(tags[target.screen][target.tag], c)
464 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
467 -- Set the windows at the slave,
468 -- i.e. put it at the end of others instead of setting it master.
469 -- awful.client.setslave(c)
471 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
472 c.honorsizehints = true
475 if maxapps[inst] or maxapps[cls] then
476 awful.client.maximize(c)
480 -- Hook function to execute when arranging the screen.
481 -- (tag switch, new client, etc)
482 awful.hooks.arrange.register(function (screen)
483 local layout = awful.layout.get(screen)
485 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
487 mylayoutbox[screen].image = nil
490 -- Give focus to the latest client in history if no window has focus
491 -- or if the current window is a desktop or a dock one.
492 if not client.focus then
493 local c = awful.client.focus.history.get(screen, 0)
494 if c then client.focus = c end
497 -- Uncomment if you want mouse warping
500 local c_c = client.focus:fullgeometry()
501 local m_c = mouse.coords()
503 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
504 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
505 if table.maxn(m_c.buttons) == 0 then
506 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
513 -- Hook called every second
514 awful.hooks.timer.register(1, function ()
515 -- For unix time_t lovers
516 -- mytextbox.text = " " .. os.time() .. " time_t "
518 mytimebox.text = " " .. os.date() .. " "
521 -- Hook called every sixty seconds
522 function hook_battery()
523 mybatterybox.text = " " .. get_acpibatt() .. " "
526 -- {{{ Statusbar battery
528 function get_acpibatt()
530 local f = io.popen('acpi -b', 'r')
532 return "acpi -b failed"
535 local s = f:read('*l')
541 -- Battery 0: Discharging, 89%, 00:02:14 remaining
542 -- Battery 0: Charging, 58%, 00:02:14 until charged
543 -- Battery 0: Full, 100%
544 -- so find the first bit first and then go look for the time
545 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
546 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
548 if not status or not percent then -- time can be empty if we're full
549 return "couldn't parse line " .. s
556 if status == 'Charging' then
558 elseif status == 'Discarching' then
564 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
569 local function get_bat()
570 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
571 for line in a:lines() do
575 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
576 for line in b:lines() do
580 batt=math.floor(now*100/full)
581 batterywidget:bar_data_add("bat",batt )
586 awful.hooks.timer.register(120, hook_battery)
587 -- awful.hooks.timer.register(5, get_bat)
593 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
594 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
595 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
596 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
597 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
598 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
599 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
600 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
601 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
602 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
603 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
606 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
607 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
608 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
609 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
610 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
611 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
612 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
613 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
615 -- Highlight statusbars on the screen that has focus,
616 -- set this to false if you only have one screen or
617 -- you don't like it :P
618 if screen.count() > 1 then
619 statusbar_highlight_focus = true
621 statusbar_highlight_focus = false