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 -- Load Debian menu entries
8 -- {{{ Variable definitions
9 -- Themes define colours, icons, and wallpapers
10 -- The default is a dark theme
11 theme_path = "/usr/share/awesome/themes/default/theme"
12 -- Uncommment this for a lighter theme
13 -- theme_path = "/usr/share/awesome/themes/sky/theme"
15 -- Actually load theme
16 beautiful.init(theme_path)
18 -- This is used later as the default terminal and editor to run.
19 terminal = "x-terminal-emulator"
20 editor = os.getenv("EDITOR") or "editor"
21 editor_cmd = terminal .. " -e " .. editor
24 -- Usually, Mod4 is the key with a logo between Control and Alt.
25 -- If you do not like this or do not have such a key,
26 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
27 -- However, you can use another modifier like Mod1, but it may interact with others.
30 -- Table of layouts to cover with awful.layout.inc, order matters.
47 -- Table of clients that should be set floating. The index may be either
48 -- the application class or instance. The instance is useful when running
49 -- a console app in a terminal like (Music on Console)
50 -- xterm -name mocp -e mocp
51 -- OVERRULED BY TILEDAPPS BELOW
60 ["Play stream"] = true,
63 -- Applications that should never float, assuming everything else floats
70 -- Applications that should be maximised
81 -- Applications to be moved to a pre-defined tag by class or instance.
82 -- Use the screen and tags indices.
85 ["Navigator"] = { screen = 1, tag = 9 },
87 ["-v"] = { screen = 1, tag = 8 },
90 -- Define if we want to use titlebar on all applications.
97 for s = 1, screen.count() do
98 -- Each screen has its own tag table.
100 -- Create 9 tags per screen.
101 for tagnumber = 1, 9 do
102 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[6] })
103 -- Add tags to screen one by one
104 -- split at 0.5/50% exactly
105 -- tags[s][tagnumber].mwfact = 0.5
106 tags[s][tagnumber].screen = s
108 -- I'm sure you want to see at least one tag.
109 tags[s][1].selected = true
114 -- Create a textbox widget
115 mytextbox = widget({ type = "textbox", align = "right" })
116 -- Set the default text in textbox
117 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
119 -- Create a laucher widget and a main menu
121 { "manual", terminal .. " -e man awesome" },
122 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
123 { "restart", awesome.restart },
124 { "quit", awesome.quit }
127 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
128 { "open terminal", terminal },
129 { "Debian", debian.menu.Debian_menu.Debian }
133 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
137 mysystray = widget({ type = "systray", align = "right" })
139 -- Create textbox widgets
140 mytimebox = widget({ type = "textbox", name = "mytimebox", align = "right" })
141 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
143 -- Create a wibox for each screen and add it
148 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
149 button({ modkey }, 1, awful.client.movetotag),
150 button({ }, 3, function (tag) tag.selected = not tag.selected end),
151 button({ modkey }, 3, awful.client.toggletag),
152 button({ }, 4, awful.tag.viewnext),
153 button({ }, 5, awful.tag.viewprev) }
155 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
156 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
157 button({ }, 4, function () awful.client.focus.byidx(1) end),
158 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
160 for s = 1, screen.count() do
161 -- Create a promptbox for each screen
162 mypromptbox[s] = widget({ type = "textbox", align = "left" })
163 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
164 -- We need one layoutbox per screen.
165 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
166 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
167 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
168 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
169 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
170 -- Create a taglist widget
171 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
173 -- Create a tasklist widget
174 mytasklist[s] = awful.widget.tasklist.new(function(c)
175 return awful.widget.tasklist.label.currenttags(c, s)
176 end, mytasklist.buttons)
179 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
180 -- Add widgets to the wibox - order matters
181 mywibox[s].widgets = { mytaglist[s],
187 s == screen.count() and mysystray or nil }
188 mywibox[s].screen = s
193 batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
194 batterywidget.width = 100
195 batterywidget.height = 0.8
196 batterywidget.gap = 1
197 batterywidget.border_padding = 1
198 batterywidget.border_width = 1
199 batterywidget.ticks_count = 10
200 batterywidget.ticks_gap = 1
201 batterywidget.vertical = false
202 batterywidget:bar_properties_set('bat', {
213 -- {{{ Mouse bindings
215 button({ }, 3, function () mymainmenu:toggle() end),
216 button({ }, 4, awful.tag.viewnext),
217 button({ }, 5, awful.tag.viewprev)
223 -- Bind keyboard digits
224 -- Compute the maximum number of digit we need, limited to 9
226 for s = 1, screen.count() do
227 keynumber = math.min(9, math.max(#tags[s], keynumber));
230 for i = 1, keynumber do
231 keybinding({ modkey }, i,
233 local screen = mouse.screen
234 if tags[screen][i] then
235 awful.tag.viewonly(tags[screen][i])
238 keybinding({ modkey, "Control" }, i,
240 local screen = mouse.screen
241 if tags[screen][i] then
242 tags[screen][i].selected = not tags[screen][i].selected
245 keybinding({ modkey, "Shift" }, i,
248 if tags[client.focus.screen][i] then
249 awful.client.movetotag(tags[client.focus.screen][i])
253 keybinding({ modkey, "Control", "Shift" }, i,
256 if tags[client.focus.screen][i] then
257 awful.client.toggletag(tags[client.focus.screen][i])
263 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
264 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
265 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
268 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
270 keybinding({ modkey, "Control" }, "r", function ()
271 mypromptbox[mouse.screen].text =
272 awful.util.escape(awful.util.restart())
274 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
276 -- Client manipulation
277 keybinding({ modkey }, "m", awful.client.maximize):add()
278 keybinding({ modkey }, "f", function () if client.focus then client.focus.fullscreen = not client.focus.fullscreen end end):add()
279 keybinding({ modkey, "Shift" }, "c", function () if client.focus then client.focus:kill() end end):add()
280 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end):add()
281 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); if client.focus then client.focus:raise() end end):add()
282 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end):add()
283 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-1) end):add()
284 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
285 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
286 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
287 keybinding({ modkey, "Control" }, "Return", function () if client.focus then client.focus:swap(awful.client.getmaster()) end end):add()
288 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
289 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
290 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
291 keybinding({ modkey, "Shift" }, "r", function () if client.focus then client.focus:redraw() end end):add()
293 -- Layout manipulation
294 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
295 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
296 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
297 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
298 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
299 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
300 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
301 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
304 keybinding({ modkey }, "F1", function ()
305 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
306 awful.util.getdir("cache") .. "/history")
308 keybinding({ modkey }, "F4", function ()
309 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
310 awful.util.getdir("cache") .. "/history_eval")
313 keybinding({ modkey, "Ctrl" }, "i", function ()
314 local s = mouse.screen
315 if mypromptbox[s].text then
316 mypromptbox[s].text = nil
317 elseif client.focus then
318 mypromptbox[s].text = nil
319 if client.focus.class then
320 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
322 if client.focus.instance then
323 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
325 if client.focus.role then
326 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
331 --- Tabulous, tab manipulation
333 keybinding({ modkey, "Control" }, "y", function ()
334 local tabbedview = tabulous.tabindex_get()
335 local nextclient = awful.client.next(1)
337 if not tabbedview then
338 tabbedview = tabulous.tabindex_get(nextclient)
340 if not tabbedview then
341 tabbedview = tabulous.tab_create()
342 tabulous.tab(tabbedview, nextclient)
344 tabulous.tab(tabbedview, client.focus)
347 tabulous.tab(tabbedview, nextclient)
351 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
353 keybinding({ modkey }, "y", function ()
354 local tabbedview = tabulous.tabindex_get()
357 local n = tabulous.next(tabbedview)
358 tabulous.display(tabbedview, n)
362 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
363 keybinding({ modkey }, "t", awful.client.togglemarked):add()
364 keybinding({ modkey, 'Shift' }, "t", function ()
365 local tabbedview = tabulous.tabindex_get()
366 local clients = awful.client.getmarked()
368 if not tabbedview then
369 tabbedview = tabulous.tab_create(clients[1])
370 table.remove(clients, 1)
373 for k,c in pairs(clients) do
374 tabulous.tab(tabbedview, c)
379 for i = 1, keynumber do
380 keybinding({ modkey, "Shift" }, "F" .. i,
382 local screen = mouse.screen
383 if tags[screen][i] then
384 for k, c in pairs(awful.client.getmarked()) do
385 awful.client.movetotag(tags[screen][i], c)
393 -- Hook function to execute when focusing a client.
394 awful.hooks.focus.register(function (c)
395 if not awful.client.ismarked(c) then
396 c.border_color = beautiful.border_focus
400 -- Hook function to execute when unfocusing a client.
401 awful.hooks.unfocus.register(function (c)
402 if not awful.client.ismarked(c) then
403 c.border_color = beautiful.border_normal
407 -- Hook function to execute when marking a client
408 awful.hooks.marked.register(function (c)
409 c.border_color = beautiful.border_marked
412 -- Hook function to execute when unmarking a client.
413 awful.hooks.unmarked.register(function (c)
414 c.border_color = beautiful.border_focus
417 -- Hook function to execute when the mouse enters a client.
418 awful.hooks.mouse_enter.register(function (c)
419 -- Sloppy focus, but disabled for magnifier layout
420 if awful.layout.get(c.screen) ~= "magnifier"
421 and awful.client.focus.filter(c) then
426 -- Hook function to execute when a new client appears.
427 awful.hooks.manage.register(function (c)
430 awful.titlebar.add(c, { modkey = modkey })
432 -- Add mouse bindings
434 button({ }, 1, function (c) client.focus = c; c:raise() end),
435 button({ modkey }, 1, function (c) c:mouse_move() end),
436 button({ modkey }, 3, function (c) c:mouse_resize() end)
438 -- New client may not receive focus
439 -- if they're not focusable, so set border anyway.
440 c.border_width = beautiful.border_width
441 c.border_color = beautiful.border_normal
443 -- Check if the application should be floating.
444 -- OVERRIDDEN, SEE tiledapps BELOW
446 local inst = c.instance
447 if floatapps[cls] then
448 c.floating = floatapps[cls]
449 elseif floatapps[inst] then
450 c.floating = floatapps[inst]
453 -- Override with tiledapps
454 c.floating = not (tiledapps[inst] or tiledapps[cls])
456 -- Check application->screen/tag mappings.
459 target = apptags[cls]
460 elseif apptags[inst] then
461 target = apptags[inst]
464 c.screen = target.screen
465 awful.client.movetotag(tags[target.screen][target.tag], c)
468 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
471 -- Set the windows at the slave,
472 -- i.e. put it at the end of others instead of setting it master.
473 -- awful.client.setslave(c)
475 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
476 c.honorsizehints = true
479 if maxapps[inst] or maxapps[cls] then
480 awful.client.maximize(c)
484 -- Hook function to execute when arranging the screen.
485 -- (tag switch, new client, etc)
486 awful.hooks.arrange.register(function (screen)
487 local layout = awful.layout.get(screen)
489 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
491 mylayoutbox[screen].image = nil
494 -- Give focus to the latest client in history if no window has focus
495 -- or if the current window is a desktop or a dock one.
496 if not client.focus then
497 local c = awful.client.focus.history.get(screen, 0)
498 if c then client.focus = c end
501 -- Uncomment if you want mouse warping
504 local c_c = client.focus:fullgeometry()
505 local m_c = mouse.coords()
507 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
508 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
509 if table.maxn(m_c.buttons) == 0 then
510 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
517 -- Hook called every second
518 awful.hooks.timer.register(1, function ()
519 -- For unix time_t lovers
520 -- mytextbox.text = " " .. os.time() .. " time_t "
522 mytimebox.text = " " .. os.date() .. " "
525 -- Hook called every sixty seconds
526 function hook_battery()
527 mybatterybox.text = " " .. get_acpibatt() .. " "
530 -- {{{ Statusbar battery
532 function get_acpibatt()
534 local f = io.popen('acpi -b', 'r')
536 return "acpi -b failed"
539 local s = f:read('*l')
545 -- Battery 0: Discharging, 89%, 00:02:14 remaining
546 -- Battery 0: Charging, 58%, 00:02:14 until charged
547 -- Battery 0: Full, 100%
548 -- so find the first bit first and then go look for the time
549 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
550 local st, en, time = string.find(s, ',%s(%d+:%d+:%d+)%s%a+', en);
552 if not status or not percent then -- time can be empty if we're full
553 return "couldn't parse line " .. s
560 if status == 'Charging' then
562 elseif status == 'Discarching' then
568 return percent; -- .. ' (' .. status .. ')'; -- .. ' ' .. time .. ' left';
573 local function get_bat()
574 local a = io.open("/sys/class/power_supply/BAT1/charge_full")
575 for line in a:lines() do
579 local b = io.open("/sys/class/power_supply/BAT1/charge_now")
580 for line in b:lines() do
584 batt=math.floor(now*100/full)
585 batterywidget:bar_data_add("bat",batt )
590 awful.hooks.timer.register(120, hook_battery)
591 -- awful.hooks.timer.register(5, get_bat)
597 keybinding({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end):add()
598 keybinding({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end):add()
599 keybinding({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end):add()
600 keybinding({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end):add()
601 keybinding({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end):add()
602 keybinding({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end):add()
603 keybinding({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end):add()
604 keybinding({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end):add()
605 keybinding({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end):add()
606 keybinding({ cmdmodkey }, "backslash", function () awful.util.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
607 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.util.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
610 keybinding({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end):add()
611 keybinding({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end):add()
612 keybinding({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end):add()
613 keybinding({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end):add()
614 keybinding({ cmdmodkey }, "r", function () awful.util.spawn("gmrun") end):add()
615 keybinding({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end):add()
616 keybinding({ cmdmodkey }, "x", function () awful.util.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
617 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end):add()
619 -- Highlight statusbars on the screen that has focus,
620 -- set this to false if you only have one screen or
621 -- you don't like it :P
622 if screen.count() > 1 then
623 statusbar_highlight_focus = true
625 statusbar_highlight_focus = false