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 -- If LuaRocks is installed, make sure that packages installed through it are
15 -- found (e.g. lgi). If LuaRocks is not installed, do nothing.
16 pcall(require, "luarocks.loader")
18 -- Standard awesome library
19 local gears = require("gears")
20 local awful = require("awful")
21 require("awful.autofocus")
22 -- Widget and layout library
23 local wibox = require("wibox")
24 -- Theme handling library
25 local beautiful = require("beautiful")
26 -- Notification library
27 local naughty = require("naughty")
28 local menubar = require("menubar")
29 local hotkeys_popup = require("awful.hotkeys_popup")
30 -- Enable hotkeys help widget for VIM and other apps
31 -- when client with a matching name is opened:
32 require("awful.hotkeys_popup.keys")
34 -- load the volume widget code and set settings
35 local volume_control = require("volume-control")
36 volumecfg = volume_control({})
38 -- Load Debian menu entries
39 local debian = require("debian.menu")
40 local has_fdo, freedesktop = pcall(require, "freedesktop")
43 -- Check if awesome encountered an error during startup and fell back to
44 -- another config (This code will only ever execute for the fallback config)
45 if awesome.startup_errors then
46 naughty.notify({ preset = naughty.config.presets.critical,
47 title = "Oops, there were errors during startup!",
48 text = awesome.startup_errors })
51 -- Handle runtime errors after startup
53 local in_error = false
54 awesome.connect_signal("debug::error", function (err)
55 -- Make sure we don't go into an endless error loop
56 if in_error then return end
59 naughty.notify({ preset = naughty.config.presets.critical,
60 title = "Oops, an error happened!",
61 text = tostring(err) })
67 -- {{{ Variable definitions
68 -- Themes define colours, icons, font and wallpapers.
69 beautiful.init(awful.util.get_themes_dir() .. "sky/theme.lua")
70 beautiful.wallpaper = "/home/mako/images/Flag_of_Cascadia.png"
72 -- This is used later as the default terminal and editor to run.
73 terminal = "x-terminal-emulator"
74 editor = os.getenv("EDITOR") or "editor"
75 editor_cmd = terminal .. " -e " .. editor
78 -- Usually, Mod4 is the key with a logo between Control and Alt.
79 -- If you do not like this or do not have such a key,
80 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
81 -- However, you can use another modifier like Mod1, but it may interact with others.
84 -- Table of layouts to cover with awful.layout.inc, order matters.
85 awful.layout.layouts = {
86 awful.layout.suit.tile,
87 awful.layout.suit.max,
88 awful.layout.suit.floating
93 -- Create a launcher widget and a main menu
95 { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end },
96 { "manual", terminal .. " -e man awesome" },
97 { "edit config", editor_cmd .. " " .. awesome.conffile },
98 { "restart", awesome.restart },
99 { "quit", function() awesome.quit() end },
102 local menu_awesome = { "awesome", myawesomemenu, beautiful.awesome_icon }
103 local menu_terminal = { "open terminal", terminal }
106 mymainmenu = freedesktop.menu.build({
107 before = { menu_awesome },
108 after = { menu_terminal }
111 mymainmenu = awful.menu({
114 { "Debian", debian.menu.Debian_menu.Debian },
121 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
124 -- Menubar configuration
125 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
128 -- Keyboard map indicator and switcher
129 mykeyboardlayout = awful.widget.keyboardlayout()
132 -- Create a textclock widget
133 mytextclock = wibox.widget.textclock("%a %m %d %H:%M", 60, tz_string)
135 -- Create a wibox for each screen and add it
136 local taglist_buttons = gears.table.join(
137 awful.button({ }, 1, function(t) t:view_only() end),
138 awful.button({ modkey }, 1, function(t)
140 client.focus:move_to_tag(t)
143 awful.button({ }, 3, awful.tag.viewtoggle),
144 awful.button({ modkey }, 3, function(t)
146 client.focus:toggle_tag(t)
149 awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
150 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
153 local tasklist_buttons = gears.table.join(
154 awful.button({ }, 1, function (c)
155 if c == client.focus then
165 awful.button({ }, 3, function()
166 awful.menu.client_list({ theme = { width = 250 } })
168 awful.button({ }, 4, function ()
169 awful.client.focus.byidx(1)
171 awful.button({ }, 5, function ()
172 awful.client.focus.byidx(-1)
175 local function set_wallpaper(s)
177 if beautiful.wallpaper then
178 local wallpaper = beautiful.wallpaper
179 -- If wallpaper is a function, call it with the screen
180 if type(wallpaper) == "function" then
181 wallpaper = wallpaper(s)
183 gears.wallpaper.maximized(wallpaper, s, true)
187 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
188 screen.connect_signal("property::geometry", set_wallpaper)
190 awful.screen.connect_for_each_screen(function(s)
194 -- Each screen has its own tag table.
195 awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
197 -- Create a promptbox for each screen
198 s.mypromptbox = awful.widget.prompt()
199 -- Create an imagebox widget which will contain an icon indicating which layout we're using.
200 -- We need one layoutbox per screen.
201 s.mylayoutbox = awful.widget.layoutbox(s)
202 s.mylayoutbox:buttons(gears.table.join(
203 awful.button({ }, 1, function () awful.layout.inc( 1) end),
204 awful.button({ }, 3, function () awful.layout.inc(-1) end),
205 awful.button({ }, 4, function () awful.layout.inc( 1) end),
206 awful.button({ }, 5, function () awful.layout.inc(-1) end)))
207 -- Create a taglist widget
208 s.mytaglist = awful.widget.taglist {
210 filter = awful.widget.taglist.filter.all,
211 buttons = taglist_buttons
214 -- Create a tasklist widget
215 s.mytasklist = awful.widget.tasklist {
217 filter = awful.widget.tasklist.filter.currenttags,
218 buttons = tasklist_buttons
222 s.mywibox = awful.wibar({ position = "top", screen = s })
224 -- Add widgets to the wibox
226 layout = wibox.layout.align.horizontal,
228 layout = wibox.layout.fixed.horizontal,
233 s.mytasklist, -- Middle widget
235 layout = wibox.layout.fixed.horizontal,
237 wibox.widget.systray(),
246 -- right_layout:add(volumecfg.widget)
248 -- {{{ Mouse bindings
249 root.buttons(gears.table.join(
250 awful.button({ }, 3, function () mymainmenu:toggle() end),
251 awful.button({ }, 4, awful.tag.viewnext),
252 awful.button({ }, 5, awful.tag.viewprev)
257 globalkeys = gears.table.join(
258 awful.key({ modkey, }, "s", hotkeys_popup.show_help,
259 {description="show help", group="awesome"}),
260 awful.key({ modkey, }, "Left", awful.tag.viewprev,
261 {description = "view previous", group = "tag"}),
262 awful.key({ modkey, }, "Right", awful.tag.viewnext,
263 {description = "view next", group = "tag"}),
264 awful.key({ modkey, }, "Escape", awful.tag.history.restore,
265 {description = "go back", group = "tag"}),
267 awful.key({ modkey, }, "j",
269 awful.client.focus.byidx( 1)
271 {description = "focus next by index", group = "client"}
273 awful.key({ modkey, }, "k",
275 awful.client.focus.byidx(-1)
277 {description = "focus previous by index", group = "client"}
279 awful.key({ modkey, }, "w", function () mymainmenu:show() end,
280 {description = "show main menu", group = "awesome"}),
282 -- Layout manipulation
283 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
284 {description = "swap with next client by index", group = "client"}),
285 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
286 {description = "swap with previous client by index", group = "client"}),
287 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
288 {description = "focus the next screen", group = "screen"}),
289 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
290 {description = "focus the previous screen", group = "screen"}),
291 awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
292 {description = "jump to urgent client", group = "client"}),
293 awful.key({ modkey, }, "Tab",
295 awful.client.focus.history.previous()
300 {description = "go back", group = "client"}),
303 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
304 {description = "open a terminal", group = "launcher"}),
305 awful.key({ modkey, "Control" }, "r", awesome.restart,
306 {description = "reload awesome", group = "awesome"}),
307 awful.key({ modkey, "Shift" }, "q", awesome.quit,
308 {description = "quit awesome", group = "awesome"}),
310 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
311 {description = "increase master width factor", group = "layout"}),
312 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
313 {description = "decrease master width factor", group = "layout"}),
314 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
315 {description = "increase the number of master clients", group = "layout"}),
316 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
317 {description = "decrease the number of master clients", group = "layout"}),
318 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
319 {description = "increase the number of columns", group = "layout"}),
320 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
321 {description = "decrease the number of columns", group = "layout"}),
322 awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
323 {description = "select next", group = "layout"}),
324 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
325 {description = "select previous", group = "layout"}),
327 awful.key({ modkey, "Control" }, "n",
329 local c = awful.client.restore()
330 -- Focus restored client
333 "request::activate", "key.unminimize", {raise = true}
337 {description = "restore minimized", group = "client"}),
340 awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
341 {description = "run prompt", group = "launcher"}),
343 awful.key({ modkey, }, "x",
346 prompt = "Run in terminal: ",
347 textbox = awful.screen.focused().mypromptbox.widget,
348 exe_callback = function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end
351 {description = "terminal execute prompt", group = "awesome"}),
353 -- Mako's additional keybindings
355 awful.key({ modkey, "Shift", }, "x",
358 prompt = "Run Lua code: ",
359 textbox = awful.screen.focused().mypromptbox.widget,
360 exe_callback = awful.util.eval,
361 history_path = awful.util.get_cache_dir() .. "/history_eval"
364 {description = "lua execute prompt", group = "awesome"}),
366 awful.key({ modkey }, "q",
368 awful.tag.incnmaster(-1)
372 awful.key({ modkey, "Shift" }, "t", awful.titlebar.toggle),
377 awful.key({ modkey }, "p", function() menubar.show() end,
378 {description = "show the menubar", group = "launcher"})
381 clientkeys = gears.table.join(
382 awful.key({ modkey, }, "f",
384 c.fullscreen = not c.fullscreen
387 {description = "toggle fullscreen", group = "client"}),
388 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
389 {description = "close", group = "client"}),
390 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
391 {description = "toggle floating", group = "client"}),
392 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
393 {description = "move to master", group = "client"}),
394 awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
395 {description = "move to screen", group = "client"}),
396 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
397 {description = "toggle keep on top", group = "client"}),
398 awful.key({ modkey, }, "n",
400 -- The client currently has the input focus, so it cannot be
401 -- minimized, since minimized clients can't have the focus.
404 {description = "minimize", group = "client"}),
405 awful.key({ modkey, }, "m",
407 c.maximized = not c.maximized
410 {description = "(un)maximize", group = "client"}),
411 awful.key({ modkey, "Control" }, "m",
413 c.maximized_vertical = not c.maximized_vertical
416 {description = "(un)maximize vertically", group = "client"}),
417 awful.key({ modkey, "Shift" }, "m",
419 c.maximized_horizontal = not c.maximized_horizontal
422 {description = "(un)maximize horizontally", group = "client"})
425 -- Bind all key numbers to tags.
426 -- Be careful: we use keycodes to make it work on any keyboard layout.
427 -- This should map on the top row of your keyboard, usually 1 to 9.
429 globalkeys = gears.table.join(globalkeys,
431 awful.key({ modkey }, "#" .. i + 9,
433 local screen = awful.screen.focused()
434 local tag = screen.tags[i]
439 {description = "view tag #"..i, group = "tag"}),
440 -- Toggle tag display.
441 awful.key({ modkey, "Control" }, "#" .. i + 9,
443 local screen = awful.screen.focused()
444 local tag = screen.tags[i]
446 awful.tag.viewtoggle(tag)
449 {description = "toggle tag #" .. i, group = "tag"}),
450 -- Move client to tag.
451 awful.key({ modkey, "Shift" }, "#" .. i + 9,
454 local tag = client.focus.screen.tags[i]
456 client.focus:move_to_tag(tag)
460 {description = "move focused client to tag #"..i, group = "tag"}),
461 -- Toggle tag on focused client.
462 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
465 local tag = client.focus.screen.tags[i]
467 client.focus:toggle_tag(tag)
471 {description = "toggle focused client on tag #" .. i, group = "tag"}),
472 awful.key({}, "XF86AudioRaiseVolume", function() volumecfg:up() end),
473 awful.key({}, "XF86AudioLowerVolume", function() volumecfg:down() end),
474 awful.key({}, "XF86AudioMute", function() volumecfg:toggle() end)
478 clientbuttons = gears.table.join(
479 awful.button({ }, 1, function (c)
480 c:emit_signal("request::activate", "mouse_click", {raise = true})
482 awful.button({ modkey }, 1, function (c)
483 c:emit_signal("request::activate", "mouse_click", {raise = true})
484 awful.mouse.client.move(c)
486 awful.button({ modkey }, 3, function (c)
487 c:emit_signal("request::activate", "mouse_click", {raise = true})
488 awful.mouse.client.resize(c)
493 root.keys(globalkeys)
497 -- Rules to apply to new clients (through the "manage" signal).
498 awful.rules.rules = {
499 -- All clients will match this rule.
501 properties = { border_width = beautiful.border_width,
502 border_color = beautiful.border_normal,
503 focus = awful.client.focus.filter,
506 buttons = clientbuttons,
507 screen = awful.screen.preferred,
508 placement = awful.placement.no_overlap+awful.placement.no_offscreen
514 "DTA", -- Firefox addon DownThemAll.
515 "copyq", -- Includes session name in class.
523 "MessageWin", -- kalarm.
525 "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size.
530 -- Note that the name property shown in xprop might be set slightly after creation of the client
531 -- and the name shown there might not match defined rules here.
533 "Event Tester", -- xev.
536 "AlarmWindow", -- Thunderbird's calendar.
537 "ConfigManager", -- Thunderbird's about:config.
538 -- this is commented out to try to keep all chrom(e|ium) apps from being floating
539 -- "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
541 }, properties = { floating = true }},
543 -- Add titlebars to normal clients and dialogs
544 -- { rule_any = {type = { "normal", "dialog" }
545 -- }, properties = { titlebars_enabled = true }
547 -- make so that overleaf is not floating
548 { rule = { class = "crx_gjoaplgcpnmemdaklplebdapjihcoibe" },
549 properties = {floating = false}
552 -- Set Firefox to always map on the tag named "2" on screen 1.
553 -- { rule = { class = "Firefox" },
554 -- properties = { screen = 1, tag = "2" } },
559 -- Signal function to execute when a new client appears.
560 client.connect_signal("manage", function (c)
561 -- Set the windows at the slave,
562 -- i.e. put it at the end of others instead of setting it master.
563 -- if not awesome.startup then awful.client.setslave(c) end
566 and not c.size_hints.user_position
567 and not c.size_hints.program_position then
568 -- Prevent clients from being unreachable after screen count changes.
569 awful.placement.no_offscreen(c)
573 -- Add a titlebar if titlebars_enabled is set to true in the rules.
574 client.connect_signal("request::titlebars", function(c)
575 -- buttons for the titlebar
576 local buttons = gears.table.join(
577 awful.button({ }, 1, function()
578 c:emit_signal("request::activate", "titlebar", {raise = true})
579 awful.mouse.client.move(c)
581 awful.button({ }, 3, function()
582 c:emit_signal("request::activate", "titlebar", {raise = true})
583 awful.mouse.client.resize(c)
587 awful.titlebar(c) : setup {
589 awful.titlebar.widget.iconwidget(c),
591 layout = wibox.layout.fixed.horizontal
596 widget = awful.titlebar.widget.titlewidget(c)
599 layout = wibox.layout.flex.horizontal
602 awful.titlebar.widget.floatingbutton (c),
603 awful.titlebar.widget.maximizedbutton(c),
604 awful.titlebar.widget.stickybutton (c),
605 awful.titlebar.widget.ontopbutton (c),
606 awful.titlebar.widget.closebutton (c),
607 layout = wibox.layout.fixed.horizontal()
609 layout = wibox.layout.align.horizontal
613 -- Enable sloppy focus, so that focus follows mouse.
614 client.connect_signal("mouse::enter", function(c)
615 c:emit_signal("request::activate", "mouse_enter", {raise = false})
618 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
619 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)