1 -- read the timezone from /etc/timezone (this doesn't work, somehow)
2 local function read_tz_file(path)
3 local file = io.open(path, "r") -- r read mode and b binary mode
4 if not file then return nil end
5 local content = file:read "*a" -- *a or *all reads the whole file
7 content = content:gsub("^%s*", "")
8 content = content:gsub("%s*$", "")
12 local tz_string = read_tz_file("/etc/timezone")
14 -- Standard awesome library
15 local gears = require("gears")
16 local awful = require("awful")
17 require("awful.autofocus")
18 -- Widget and layout library
19 local wibox = require("wibox")
20 -- Theme handling library
21 local beautiful = require("beautiful")
22 -- Notification library
23 local naughty = require("naughty")
24 local menubar = require("menubar")
25 local hotkeys_popup = require("awful.hotkeys_popup").widget
27 -- load the volume widget code and set settings
28 local volume_control = require("volume-control")
29 volumecfg = volume_control({})
31 -- Load Debian menu entries
32 require("debian.menu")
35 -- Check if awesome encountered an error during startup and fell back to
36 -- another config (This code will only ever execute for the fallback config)
37 if awesome.startup_errors then
38 naughty.notify({ preset = naughty.config.presets.critical,
39 title = "Oops, there were errors during startup!",
40 text = awesome.startup_errors })
43 -- Handle runtime errors after startup
45 local in_error = false
46 awesome.connect_signal("debug::error", function (err)
47 -- Make sure we don't go into an endless error loop
48 if in_error then return end
51 naughty.notify({ preset = naughty.config.presets.critical,
52 title = "Oops, an error happened!",
53 text = tostring(err) })
59 -- {{{ Variable definitions
60 -- Themes define colours, icons, font and wallpapers.
61 -- beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
62 beautiful.init(awful.util.get_themes_dir() .. "sky/theme.lua")
63 beautiful.wallpaper = "/home/mako/images/Flag_of_Cascadia.png"
65 -- This is used later as the default terminal and editor to run.
66 terminal = "x-terminal-emulator"
67 editor = os.getenv("EDITOR") or "editor"
68 editor_cmd = terminal .. " -e " .. editor
71 -- Usually, Mod4 is the key with a logo between Control and Alt.
72 -- If you do not like this or do not have such a key,
73 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
74 -- However, you can use another modifier like Mod1, but it may interact with others.
77 -- Table of layouts to cover with awful.layout.inc, order matters.
78 awful.layout.layouts = {
79 awful.layout.suit.tile,
80 awful.layout.suit.max,
81 awful.layout.suit.floating
85 -- {{{ Helper functions
86 local function client_menu_toggle_fn()
90 if instance and instance.wibox.visible then
94 instance = awful.menu.clients({ theme = { width = 250 } })
101 -- Create a launcher widget and a main menu
103 { "hotkeys", function() return false, hotkeys_popup.show_help end},
104 { "manual", terminal .. " -e man awesome" },
105 { "edit config", editor_cmd .. " " .. awesome.conffile },
106 { "restart", awesome.restart },
107 { "quit", function() awesome.quit() end}
110 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
111 { "Debian", debian.menu.Debian_menu.Debian },
112 { "open terminal", terminal }
116 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
119 -- Menubar configuration
120 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
123 -- Keyboard map indicator and switcher
124 mykeyboardlayout = awful.widget.keyboardlayout()
127 -- Create a textclock widget
128 mytextclock = wibox.widget.textclock("%a %m %d %H:%M", 60, tz_string)
130 -- Create a wibox for each screen and add it
131 local taglist_buttons = awful.util.table.join(
132 awful.button({ }, 1, function(t) t:view_only() end),
133 awful.button({ modkey }, 1, function(t)
135 client.focus:move_to_tag(t)
138 awful.button({ }, 3, awful.tag.viewtoggle),
139 awful.button({ modkey }, 3, function(t)
141 client.focus:toggle_tag(t)
144 awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
145 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
148 local tasklist_buttons = awful.util.table.join(
149 awful.button({ }, 1, function (c)
150 if c == client.focus then
153 -- Without this, the following
154 -- :isvisible() makes no sense
156 if not c:isvisible() and c.first_tag then
157 c.first_tag:view_only()
159 -- This will also un-minimize
160 -- the client, if needed
165 awful.button({ }, 3, client_menu_toggle_fn()),
166 awful.button({ }, 4, function ()
167 awful.client.focus.byidx(1)
169 awful.button({ }, 5, function ()
170 awful.client.focus.byidx(-1)
173 local function set_wallpaper(s)
175 if beautiful.wallpaper then
176 local wallpaper = beautiful.wallpaper
177 -- If wallpaper is a function, call it with the screen
178 if type(wallpaper) == "function" then
179 wallpaper = wallpaper(s)
181 gears.wallpaper.maximized(wallpaper, s, true)
185 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
186 screen.connect_signal("property::geometry", set_wallpaper)
188 awful.screen.connect_for_each_screen(function(s)
192 -- Each screen has its own tag table.
193 awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
195 -- Create a promptbox for each screen
196 s.mypromptbox = awful.widget.prompt()
197 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
198 -- We need one layoutbox per screen.
199 s.mylayoutbox = awful.widget.layoutbox(s)
200 s.mylayoutbox:buttons(awful.util.table.join(
201 awful.button({ }, 1, function () awful.layout.inc( 1) end),
202 awful.button({ }, 3, function () awful.layout.inc(-1) end),
203 awful.button({ }, 4, function () awful.layout.inc( 1) end),
204 awful.button({ }, 5, function () awful.layout.inc(-1) end)))
205 -- Create a taglist widget
206 s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
208 -- Create a tasklist widget
209 s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
212 s.mywibox = awful.wibar({ position = "top", screen = s })
214 -- Add widgets to the wibox
216 layout = wibox.layout.align.horizontal,
218 layout = wibox.layout.fixed.horizontal,
223 s.mytasklist, -- Middle widget
225 layout = wibox.layout.fixed.horizontal,
227 wibox.widget.systray(),
236 -- right_layout:add(volumecfg.widget)
238 -- {{{ Mouse bindings
239 root.buttons(awful.util.table.join(
240 awful.button({ }, 3, function () mymainmenu:toggle() end),
241 awful.button({ }, 4, awful.tag.viewnext),
242 awful.button({ }, 5, awful.tag.viewprev)
247 globalkeys = awful.util.table.join(
248 awful.key({ modkey, }, "s", hotkeys_popup.show_help,
249 {description="show help", group="awesome"}),
250 awful.key({ modkey, }, "Left", awful.tag.viewprev,
251 {description = "view previous", group = "tag"}),
252 awful.key({ modkey, }, "Right", awful.tag.viewnext,
253 {description = "view next", group = "tag"}),
254 awful.key({ modkey, }, "Escape", awful.tag.history.restore,
255 {description = "go back", group = "tag"}),
257 awful.key({ modkey, }, "j",
259 awful.client.focus.byidx( 1)
261 {description = "focus next by index", group = "client"}
263 awful.key({ modkey, }, "k",
265 awful.client.focus.byidx(-1)
267 {description = "focus previous by index", group = "client"}
269 awful.key({ modkey, }, "w", function () mymainmenu:show() end,
270 {description = "show main menu", group = "awesome"}),
272 -- Layout manipulation
273 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
274 {description = "swap with next client by index", group = "client"}),
275 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
276 {description = "swap with previous client by index", group = "client"}),
277 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
278 {description = "focus the next screen", group = "screen"}),
279 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
280 {description = "focus the previous screen", group = "screen"}),
281 awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
282 {description = "jump to urgent client", group = "client"}),
283 awful.key({ modkey, }, "Tab",
285 awful.client.focus.history.previous()
290 {description = "go back", group = "client"}),
293 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
294 {description = "open a terminal", group = "launcher"}),
295 awful.key({ modkey, "Control" }, "r", awesome.restart,
296 {description = "reload awesome", group = "awesome"}),
297 awful.key({ modkey, "Shift" }, "q", awesome.quit,
298 {description = "quit awesome", group = "awesome"}),
300 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
301 {description = "increase master width factor", group = "layout"}),
302 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
303 {description = "decrease master width factor", group = "layout"}),
304 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
305 {description = "increase the number of master clients", group = "layout"}),
306 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
307 {description = "decrease the number of master clients", group = "layout"}),
308 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
309 {description = "increase the number of columns", group = "layout"}),
310 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
311 {description = "decrease the number of columns", group = "layout"}),
312 awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
313 {description = "select next", group = "layout"}),
314 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
315 {description = "select previous", group = "layout"}),
317 awful.key({ modkey, "Control" }, "n",
319 local c = awful.client.restore()
320 -- Focus restored client
326 {description = "restore minimized", group = "client"}),
329 awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
330 {description = "run prompt", group = "launcher"}),
332 awful.key({ modkey, }, "x",
335 prompt = "Run in terminal: ",
336 textbox = awful.screen.focused().mypromptbox.widget,
337 exe_callback = function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end
340 {description = "terminal execute prompt", group = "awesome"}),
342 -- Mako's additional keybindings
344 awful.key({ modkey, "Shift", }, "x",
347 prompt = "Run Lua code: ",
348 textbox = awful.screen.focused().mypromptbox.widget,
349 exe_callback = awful.util.eval,
350 history_path = awful.util.get_cache_dir() .. "/history_eval"
353 {description = "lua execute prompt", group = "awesome"}),
355 awful.key({ modkey }, "q",
357 awful.tag.incnmaster(-1)
361 awful.key({ modkey, "Shift" }, "t", awful.titlebar.toggle),
366 awful.key({ modkey }, "p", function() menubar.show() end,
367 {description = "show the menubar", group = "launcher"})
370 clientkeys = awful.util.table.join(
371 awful.key({ modkey, }, "f",
373 c.fullscreen = not c.fullscreen
376 {description = "toggle fullscreen", group = "client"}),
377 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
378 {description = "close", group = "client"}),
379 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
380 {description = "toggle floating", group = "client"}),
381 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
382 {description = "move to master", group = "client"}),
383 awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
384 {description = "move to screen", group = "client"}),
385 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
386 {description = "toggle keep on top", group = "client"}),
387 awful.key({ modkey, }, "n",
389 -- The client currently has the input focus, so it cannot be
390 -- minimized, since minimized clients can't have the focus.
393 {description = "minimize", group = "client"}),
394 awful.key({ modkey, }, "m",
396 c.maximized = not c.maximized
399 {description = "maximize", group = "client"})
402 -- Bind all key numbers to tags.
403 -- Be careful: we use keycodes to make it works on any keyboard layout.
404 -- This should map on the top row of your keyboard, usually 1 to 9.
406 globalkeys = awful.util.table.join(globalkeys,
408 awful.key({ modkey }, "#" .. i + 9,
410 local screen = awful.screen.focused()
411 local tag = screen.tags[i]
416 {description = "view tag #"..i, group = "tag"}),
417 -- Toggle tag display.
418 awful.key({ modkey, "Control" }, "#" .. i + 9,
420 local screen = awful.screen.focused()
421 local tag = screen.tags[i]
423 awful.tag.viewtoggle(tag)
426 {description = "toggle tag #" .. i, group = "tag"}),
427 -- Move client to tag.
428 awful.key({ modkey, "Shift" }, "#" .. i + 9,
431 local tag = client.focus.screen.tags[i]
433 client.focus:move_to_tag(tag)
437 {description = "move focused client to tag #"..i, group = "tag"}),
438 -- Toggle tag on focused client.
439 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
442 local tag = client.focus.screen.tags[i]
444 client.focus:toggle_tag(tag)
448 {description = "toggle focused client on tag #" .. i, group = "tag"}),
449 awful.key({}, "XF86AudioRaiseVolume", function() volumecfg:up() end),
450 awful.key({}, "XF86AudioLowerVolume", function() volumecfg:down() end),
451 awful.key({}, "XF86AudioMute", function() volumecfg:toggle() end)
455 clientbuttons = awful.util.table.join(
456 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
457 awful.button({ modkey }, 1, awful.mouse.client.move),
458 awful.button({ modkey }, 3, awful.mouse.client.resize))
461 root.keys(globalkeys)
465 -- Rules to apply to new clients (through the "manage" signal).
466 awful.rules.rules = {
467 -- All clients will match this rule.
469 properties = { border_width = beautiful.border_width,
470 border_color = beautiful.border_normal,
471 focus = awful.client.focus.filter,
474 buttons = clientbuttons,
475 screen = awful.screen.preferred,
476 placement = awful.placement.no_overlap+awful.placement.no_offscreen
483 "DTA", -- Firefox addon DownThemAll.
484 "copyq", -- Includes session name in class.
490 "MessageWin", -- kalarm.
498 "Event Tester", -- xev.
501 "AlarmWindow", -- Thunderbird's calendar.
502 "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
504 }, properties = { floating = true }},
506 -- Add titlebars to normal clients and dialogs
507 { rule_any = {type = { "normal", "dialog" }
508 }, properties = { titlebars_enabled = false }
511 -- Set Firefox to always map on the tag named "2" on screen 1.
512 -- { rule = { class = "Firefox" },
513 -- properties = { screen = 1, tag = "2" } },
518 -- Signal function to execute when a new client appears.
519 client.connect_signal("manage", function (c)
520 -- Set the windows at the slave,
521 -- i.e. put it at the end of others instead of setting it master.
522 -- if not awesome.startup then awful.client.setslave(c) end
524 if awesome.startup and
525 not c.size_hints.user_position
526 and not c.size_hints.program_position then
527 -- Prevent clients from being unreachable after screen count changes.
528 awful.placement.no_offscreen(c)
532 -- Add a titlebar if titlebars_enabled is set to true in the rules.
533 client.connect_signal("request::titlebars", function(c)
534 -- buttons for the titlebar
535 local buttons = awful.util.table.join(
536 awful.button({ }, 1, function()
539 awful.mouse.client.move(c)
541 awful.button({ }, 3, function()
544 awful.mouse.client.resize(c)
548 awful.titlebar(c) : setup {
550 awful.titlebar.widget.iconwidget(c),
552 layout = wibox.layout.fixed.horizontal
557 widget = awful.titlebar.widget.titlewidget(c)
560 layout = wibox.layout.flex.horizontal
563 awful.titlebar.widget.floatingbutton (c),
564 awful.titlebar.widget.maximizedbutton(c),
565 awful.titlebar.widget.stickybutton (c),
566 awful.titlebar.widget.ontopbutton (c),
567 awful.titlebar.widget.closebutton (c),
568 layout = wibox.layout.fixed.horizontal()
570 layout = wibox.layout.align.horizontal
574 -- Enable sloppy focus, so that focus follows mouse.
575 client.connect_signal("mouse::enter", function(c)
576 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
577 and awful.client.focus.filter(c) then
582 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
583 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)