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 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
12 require("obvious.battery")
13 require("obvious.clock")
15 --require("bashets.bashets")
17 -- Load Debian menu entries
18 require("debian.menu")
20 -- {{{ Variable definitions
21 -- Themes define colours, icons, and wallpapers
22 beautiful.init(theme_path)
24 -- This is used later as the default terminal and editor to run.
25 terminal = "x-terminal-emulator"
26 editor = os.getenv("EDITOR") or "editor"
27 editor_cmd = terminal .. " -e " .. editor
30 -- Usually, Mod4 is the key with a logo between Control and Alt.
31 -- If you do not like this or do not have such a key,
32 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
33 -- However, you can use another modifier like Mod1, but it may interact with others.
36 -- Table of layouts to cover with awful.layout.inc, order matters.
39 -- awful.layout.suit.tile,
40 -- awful.layout.suit.tile.left,
41 -- awful.layout.suit.tile.bottom,
42 -- awful.layout.suit.tile.top,
43 awful.layout.suit.fair,
44 awful.layout.suit.fair.horizontal,
45 -- awful.layout.suit.spiral,
46 -- awful.layout.suit.spiral.dwindle,
47 awful.layout.suit.max,
48 -- awful.layout.suit.max.fullscreen,
49 awful.layout.suit.magnifier,
50 awful.layout.suit.floating
53 ---- Table of clients that should be set floating. The index may be either
54 ---- the application class or instance. The instance is useful when running
55 ---- a console app in a terminal like (Music on Console)
56 ---- xterm -name mocp -e mocp
57 ---- OVERRULED BY TILEDAPPS BELOW
61 -- ["MPlayer"] = true,
62 -- ["pinentry"] = true,
64 -- ["twinkle"] = true,
65 -- ["Add-ons"] = true,
66 -- ["Play stream"] = true,
67 -- ["gscan2pdf"] = true,
70 ---- Applications that should never float, assuming everything else floats
77 ---- Applications that should be maximised
81 -- ["Navigator"] = true,
85 -- ["gscan2pdf"] = true
88 ---- Applications to be moved to a pre-defined tag by class or instance.
89 ---- Use the screen and tags indices.
92 -- ["Navigator"] = { screen = 1, tag = 9 },
94 -- ["-v"] = { screen = 1, tag = 8 },
97 -- Define if we want to use titlebar on all applications.
104 { name = "1", layout = layouts[1] },
105 { name = "2", layout = layouts[1] },
106 { name = "3", layout = layouts[1] },
107 { name = "4", layout = layouts[1] },
108 { name = "5", layout = layouts[1] },
109 { name = "6", layout = layouts[1] },
110 { name = "7", layout = layouts[3] },
111 { name = "8", layout = layouts[3] },
112 { name = "9", layout = layouts[3] },
115 -- Define a tag table which hold all screen tags.
116 for s = 1, screen.count() do
118 for i, v in ipairs(tags.settings) do
119 tags[s][i] = tag({ name = v.name })
120 tags[s][i].screen = s
121 awful.tag.setproperty(tags[s][i], "layout", v.layout)
122 awful.tag.setproperty(tags[s][i], "mwfact", v.mwfact)
123 awful.tag.setproperty(tags[s][i], "hide", v.hide)
125 tags[s][1].selected = true
128 if screen.count() == 3 then
129 tags[2][1].selected = false
130 tags[2][9].selected = true
135 -- Create a laucher widget and a main menu
137 { "manual", terminal .. " -e man awesome" },
138 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
139 { "restart", awesome.restart },
140 { "quit", awesome.quit }
143 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
144 { "Debian", debian.menu.Debian_menu.Debian },
145 { "open terminal", terminal }
149 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
155 -- {{{ Reusable separators
156 spacer = widget({ type = "textbox", name = "spacer" })
157 separator = widget({ type = "textbox", name = "separator" })
162 ---- {{{ CPU usage and temperature
164 --cpuicon = widget({ type = "imagebox", name = "cpuicon" })
165 --cpuicon.image = image(beautiful.widget_cpu)
166 ---- Initialize widgets
167 --thermalwidget = widget({ type = "textbox", name = "thermalwidget" })
168 --cpuwidget = awful.widget.graph({ layout = awful.widget.layout.horizontal.rightleft })
169 ---- Graph properties
170 --cpuwidget:set_width(50)
171 ----cpuwidget:set_scale(false)
172 --cpuwidget:set_max_value(100)
173 --cpuwidget:set_background_color(beautiful.fg_off_widget)
174 --cpuwidget:set_border_color(beautiful.border_widget)
175 --cpuwidget:set_color(beautiful.fg_end_widget)
176 --cpuwidget:set_gradient_angle(0)
177 --cpuwidget:set_gradient_colors({
178 -- beautiful.fg_end_widget,
179 -- beautiful.fg_center_widget,
180 -- beautiful.fg_widget })
181 ---- Register widgets
182 --vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
183 --vicious.register(thermalwidget, vicious.widgets.thermal, "CPU: $1°C", 19, "hwmon0")
187 --batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
188 --batterywidget.width = 100
189 --batterywidget.height = 0.8
190 --batterywidget.gap = 1
191 --batterywidget.border_padding = 1
192 --batterywidget.border_width = 1
193 --batterywidget.ticks_count = 10
194 --batterywidget.ticks_gap = 1
195 --batterywidget.vertical = false
196 --batterywidget:bar_properties_set('bat', {
205 -- Create a textclock widget
206 mytextclock = awful.widget.textclock({ align = "right" }, "%a %d %b %H:%M:%S", 1)
209 mysystray = widget({ type = "systray", align = "right" })
211 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
213 -- Create a wibox for each screen and add it
218 mytaglist.buttons = awful.util.table.join(
219 awful.button({ }, 1, awful.tag.viewonly),
220 awful.button({ modkey }, 1, awful.client.movetotag),
221 awful.button({ }, 3, awful.tag.viewtoggle),
222 awful.button({ modkey }, 3, awful.client.toggletag),
223 awful.button({ }, 4, awful.tag.viewnext),
224 awful.button({ }, 5, awful.tag.viewprev)
227 mytasklist.buttons = awful.util.table.join(
228 awful.button({ }, 1, function (c)
229 if not c:isvisible() then
230 awful.tag.viewonly(c:tags()[1])
235 awful.button({ }, 3, function ()
240 instance = awful.menu.clients({ width=250 })
243 awful.button({ }, 4, function ()
244 awful.client.focus.byidx(1)
245 if client.focus then client.focus:raise() end
247 awful.button({ }, 5, function ()
248 awful.client.focus.byidx(-1)
249 if client.focus then client.focus:raise() end
252 for s = 1, screen.count() do
253 -- Create a promptbox for each screen
254 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
255 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
256 -- We need one layoutbox per screen.
257 mylayoutbox[s] = awful.widget.layoutbox(s)
258 mylayoutbox[s]:buttons(awful.util.table.join(
259 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
260 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
261 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
262 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
263 -- Create a taglist widget
264 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
266 -- Create a tasklist widget
267 mytasklist[s] = awful.widget.tasklist(function(c)
268 return awful.widget.tasklist.label.currenttags(c, s)
269 end, mytasklist.buttons)
272 mywibox[s] = awful.wibox({ position = "top", screen = s })
273 -- Add widgets to the wibox - order matters
274 mywibox[s].widgets = {
279 layout = awful.widget.layout.horizontal.leftright
284 spacer, separator, spacer,
285 obvious.battery.widget,
288 -- spacer, separator, spacer,
290 -- spacer, separator, spacer,
291 -- thermalwidget.widget,
293 s == screen.count() and mysystray or nil,
295 layout = awful.widget.layout.horizontal.rightleft
301 -- {{{ Mouse bindings
302 root.buttons(awful.util.table.join(
303 awful.button({ }, 3, function () mymainmenu:toggle() end),
304 awful.button({ }, 4, awful.tag.viewnext),
305 awful.button({ }, 5, awful.tag.viewprev)
310 globalkeys = awful.util.table.join(
311 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
312 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
313 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
314 awful.key({ modkey, "Shift" }, "Right", function () awful.screen.focus_relative( 1) end),
315 awful.key({ modkey, "Shift" }, "Left", function () awful.screen.focus_relative(-1) end),
317 awful.key({ modkey, }, "k",
319 awful.client.focus.byidx( 1)
320 if client.focus then client.focus:raise() end
322 awful.key({ modkey, }, "j",
324 awful.client.focus.byidx(-1)
325 if client.focus then client.focus:raise() end
327 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
329 -- Layout manipulation
330 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( 1) end),
331 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( -1) end),
332 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus( 1) end),
333 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end),
334 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
335 awful.key({ modkey, }, "Tab",
337 awful.client.focus.history.previous()
344 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
345 awful.key({ modkey, "Control" }, "r", awesome.restart),
346 awful.key({ modkey, "Shift" }, "q", awesome.quit),
348 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
349 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
350 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
351 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
352 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
353 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
354 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
355 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
358 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
360 awful.key({ modkey }, "x",
362 awful.prompt.run({ prompt = "Run Lua code: " },
363 mypromptbox[mouse.screen].widget,
364 awful.util.eval, nil,
365 awful.util.getdir("cache") .. "/history_eval")
367 awful.key({ modkey }, "F1", function () awful.screen.focus(1) end),
368 awful.key({ modkey }, "F2", function () awful.screen.focus(2) end),
369 awful.key({ modkey }, "F3", function () awful.screen.focus(3) end),
370 awful.key({ modkey, "Shift" }, "F1", function () awful.client.movetoscreen(c, 1) end),
371 awful.key({ modkey, "Shift" }, "F2", function () awful.client.movetoscreen(c, 2) end),
372 awful.key({ modkey, "Shift" }, "F3", function () awful.client.movetoscreen(c, 3) end)
375 clientkeys = awful.util.table.join(
376 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
377 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
378 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
379 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
380 awful.key({ modkey, }, "o", function (c) awful.client.movetoscreen(c, c.screen-1) end),
381 awful.key({ modkey, }, "p", function (c) awful.client.movetoscreen(c, c.screen+1) end),
382 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
383 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
384 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
385 awful.key({ modkey, }, "m",
387 -- silly lua can't do bitwise operations
388 if not c.maximized_horizontal and not c.maximized_vertical then
389 c.maximized_horizontal = true
390 c.maximized_vertical = true
391 elseif c.maximized_horizontal and c.maximized_vertical then
392 c.maximized_horizontal = false
393 c.maximized_vertical = true
394 elseif not c.maximized_horizontal and c.maximized_vertical then
395 c.maximized_horizontal = true
396 c.maximized_vertical = false
397 elseif c.maximized_horizontal and not c.maximized_vertical then
398 c.maximized_horizontal = false
399 c.maximized_vertical = false
404 -- Compute the maximum number of digit we need, limited to 9
406 for s = 1, screen.count() do
407 keynumber = math.min(9, math.max(#tags[s], keynumber));
410 -- Bind all key numbers to tags.
411 -- Be careful: we use keycodes to make it works on any keyboard layout.
412 -- This should map on the top row of your keyboard, usually 1 to 9.
413 for i = 1, keynumber do
414 globalkeys = awful.util.table.join(globalkeys,
415 awful.key({ modkey }, "#" .. i + 9,
417 local screen = mouse.screen
418 if tags[screen][i] then
419 awful.tag.viewonly(tags[screen][i])
422 awful.key({ modkey, "Control" }, "#" .. i + 9,
424 local screen = mouse.screen
425 if tags[screen][i] then
426 awful.tag.viewtoggle(tags[screen][i])
429 awful.key({ modkey, "Shift" }, "#" .. i + 9,
431 if client.focus and tags[client.focus.screen][i] then
432 awful.client.movetotag(tags[client.focus.screen][i])
435 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
437 if client.focus and tags[client.focus.screen][i] then
438 awful.client.toggletag(tags[client.focus.screen][i])
443 clientbuttons = awful.util.table.join(
444 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
445 awful.button({ modkey }, 1, awful.mouse.client.move),
446 awful.button({ modkey }, 3, awful.mouse.client.resize))
451 globalkeys = awful.util.table.join(globalkeys,
452 awful.key({ cmdmodkey }, "Prior", function () awful.util.spawn("pactl set-sink-volume 0 +2%") end),
453 awful.key({ cmdmodkey }, "Next", function () awful.util.spawn("pactl set-sink-volume 0 -2%") end),
454 awful.key({ cmdmodkey }, "Home", function () awful.util.spawn("pactl set-source-mute 1 toggle") end),
455 awful.key({ cmdmodkey }, "End", function () awful.util.spawn("pactl set-sink-mute 0 toggle") end),
456 awful.key({ cmdmodkey }, "Left", function () awful.util.spawn("nyxmms2 prev") end),
457 awful.key({ cmdmodkey }, "Right", function () awful.util.spawn("nyxmms2 next") end),
458 awful.key({ cmdmodkey }, "space", function () awful.util.spawn("nyxmms2 toggle") end),
459 awful.key({ cmdmodkey }, "backslash", function ()
460 local f = io.popen('nyxmms2 current', 'r')
461 for s, t in string.gmatch(f:read(), '(%w+):%s+([^:]+)') do
462 naughty.notify({ title = s, text = t, timeout = 5 })
466 awful.key({ cmdmodkey, "Shift" }, "backslash", function ()
467 local f = io.popen('nyxmms2 list', 'r')
468 naughty.notify({ title = "Playlist", text = f:read("*a"), timeout = 15 })
474 globalkeys = awful.util.table.join(globalkeys,
475 awful.key({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end),
476 awful.key({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end),
477 awful.key({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end),
478 awful.key({ cmdmodkey }, "y", function () awful.util.spawn(terminal .. " -e python") end),
479 awful.key({ cmdmodkey }, "c", function () awful.util.spawn("icedove") end),
480 awful.key({ cmdmodkey }, "r", function () mypromptbox[mouse.screen]:run() end),
481 awful.key({ cmdmodkey }, "g", function () awful.util.spawn("gscan2pdf") end),
482 awful.key({ cmdmodkey }, "v", function () awful.util.spawn("virt-manager") end),
483 awful.key({ cmdmodkey }, "o", function () awful.util.spawn("okular") end),
484 awful.key({ cmdmodkey }, "l", function () awful.util.spawn("libreoffice") end),
485 awful.key({ cmdmodkey }, "i", function () awful.util.spawn(terminal .. " -title irc -name irc -e env MOSH_TITLE_NOPREFIX=true mosh -4 -- irc-host screen -dr irc") end),
486 awful.key({ cmdmodkey }, "x", function () awful.util.spawn_with_shell("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver -- -no-capture-stderr -log ~/.tmp/xscreensaver.log; xscreensaver-command -lock") end),
487 awful.key({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end),
488 awful.key(nil, "XF86ScreenSaver", function () awful.util.spawn("xset dpms force off") end)
492 root.keys(globalkeys)
496 awful.rules.rules = {
497 -- All clients will match this rule.
499 properties = { border_width = beautiful.border_width,
500 border_color = beautiful.border_normal,
504 buttons = clientbuttons },
505 callback = awful.placement.centered
507 { rule = { class = "URxvt" },
508 properties = { floating = false } },
509 { rule = { class = "URxvt", instance = "irc" },
510 properties = { floating = false, tag = tags[screen.count()][screen.count() == 1 and 2 or 1], switchtotag = true } },
511 { rule = { class = "Firefox", instance = "Navigator" },
512 properties = { tag = tags[screen.count() == 3 and 2 or screen.count()][9], switchtotag = false, floating = false } },
513 { rule = { class = "Icedove", instance = "Mail" },
514 properties = { tag = tags[screen.count() == 3 and 2 or screen.count()][8], switchtotag = false, floating = false } },
515 { rule = { class = "chromium" },
516 properties = { tag = tags[screen.count() == 3 and 2 or screen.count()][9], switchtotag = false, floating = false } },
521 -- Signal function to execute when a new client appears.
522 client.add_signal("manage", function (c, startup)
524 -- awful.titlebar.add(c, { modkey = modkey })
526 -- Enable sloppy focus
527 c:add_signal("mouse::enter", function(c)
528 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
529 and awful.client.focus.filter(c) then
535 -- Set the windows at the slave,
536 -- i.e. put it at the end of others instead of setting it master.
537 -- awful.client.setslave(c)
539 -- Put windows in a smart way, only if they does not set an initial position.
540 if not c.size_hints.user_position and not c.size_hints.program_position then
541 --awful.placement.center_vertical(c)
542 --awful.placement.center_horizontal(c)
543 awful.placement.no_overlap(c)
544 awful.placement.no_offscreen(c)
547 c.size_hints_honor = false
550 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
551 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
553 function clear_urgency_flag(c)
554 print("property::urgent received for client: ", c)
561 client.add_signal("new", function (c)
562 c:add_signal("property::urgent", clear_urgency_flag)
565 -- Hook called every sixty seconds
566 function hook_battery()
567 mybatterybox.text = " " .. get_acpibatt() .. " "
571 -- from https://blog.mister-muffin.de/2014/11/07/automatically-suspending-cpu-hungry-applications/
572 --client.add_signal("focus", function(c)
573 -- if c.class == "Firefox" or c.class == "chromium" or c.class == "Icedove" then
574 -- awful.util.spawn("kill -CONT " .. c.pid)
577 --local capi = { timer = timer }
578 --client.add_signal("unfocus", function(c)
579 -- local timer_stop = capi.timer { timeout = 120 }
580 -- if c.class == "Firefox" or c.class == "chromium" or c.class == "Icedove" then
581 -- local send_sigstop = function ()
583 -- if client.focus.pid ~= c.pid then
584 -- awful.util.spawn("kill -STOP " .. c.pid)
587 -- timer_stop:add_signal("timeout", send_sigstop)
588 -- timer_stop:start()
592 -- {{{ Statusbar battery
594 function get_acpibatt()
595 local f = io.popen('acpi -b', 'r')
597 return "acpi -b failed"
600 local s = f:read('*l')
606 -- Battery 0: Discharging, 89%, 00:02:14 remaining
607 -- Battery 0: Charging, 58%, 00:02:14 until charged
608 -- Battery 0: Full, 100%
609 -- so find the first bit first and then go look for the time
610 local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
611 local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
613 if not status or not percent then -- time can be empty if we're full
614 return "couldn't parse line " .. s
621 if status == 'Charging' then
622 return '↑ ' .. percent;
623 elseif status == 'Discharging' then
629 --t = timer({ timeout = 20 })
630 --t:add_signal('timeout', hook_battery)
633 --bashets.register_lua(mybatterybox, get_acpibatt, '%1', 30)