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.
3 -- Standard awesome library
4 local gears = require("gears")
5 local awful = require("awful")
6 require("awful.autofocus")
7 -- Widget and layout library
8 local wibox = require("wibox")
9 -- Tyrannical tab handling
10 --local tyrannical = require("tyrannical")
11 -- Theme handling library
12 local beautiful = require("beautiful")
13 local xrdb = beautiful.xresources
14 -- Notification library
15 local naughty = require("naughty")
16 local menubar = require("menubar")
17 local hotkeys_popup = require("awful.hotkeys_popup").widget
18 -- Enable hotkeys help widget for VIM and other apps
19 -- when client with a matching name is opened:
20 require("awful.hotkeys_popup.keys")
22 -- Load Debian menu entries
23 local debian = require("debian.menu")
24 local has_fdo, freedesktop = pcall(require, "freedesktop")
26 local lain = require("lain")
27 local ccwidgets = require("cryptocoin_widgets")
28 --local fxwidgets = require("forex_widgets")
29 local clocksarray = require("clocksarray")
30 local dbg = require("debugfunc")
31 local th = require("taghelpers")
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
39 preset = naughty.config.presets.critical,
40 title = "Oops, there were errors during startup!",
41 text = awesome.startup_errors,
45 -- Handle runtime errors after startup
47 local in_error = false
48 awesome.connect_signal("debug::error", function(err)
49 -- Make sure we don't go into an endless error loop
56 preset = naughty.config.presets.critical,
57 title = "Oops, an error happened!",
65 -- {{{ Variable definitions
66 --xrdb.set_dpi(95, screen[1])
67 --xrdb.set_dpi(120, screen[2])
69 -- Themes define colours, icons, font and wallpapers.
70 beautiful.init(gears.filesystem.get_configuration_dir() .. "theme/theme.lua")
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.
85 -- Table of layouts to cover with awful.layout.inc, order matters.
87 default = awful.layout.suit.fair,
88 default_horiz = awful.layout.suit.fair.horizontal,
89 tiled = awful.layout.suit.tile,
90 tiled_horiz = awful.layout.suit.tile.top,
91 floating = awful.layout.suit.floating,
92 maximised = awful.layout.suit.max,
94 awful.layout.layouts = {
99 layouts.default_horiz,
104 -- {{{ Helper functions
105 local function client_menu_toggle_fn()
109 if instance and instance.wibox.visible then
113 instance = awful.menu.clients({ theme = { width = 250 } })
118 local function set_wallpaper(s)
120 if beautiful.wallpaper then
121 local wallpaper = beautiful.wallpaper
122 -- If wallpaper is a function, call it with the screen
123 if type(wallpaper) == "function" then
124 wallpaper = wallpaper(s)
126 gears.wallpaper.maximized(wallpaper, s, true)
130 local function move_mouse_to_area(a)
131 local coords = mouse.coords()
132 if coords.x < a.x or coords.x > (a.x + a.width) or coords.y < a.y or coords.y > (a.y + a.height) then
134 x = a.x + a.width / 2,
135 y = a.y + a.height / 2,
143 -- Create a launcher widget and a main menu
148 return false, hotkeys_popup.show_help
151 { "manual", terminal .. " -e man awesome" },
152 { "edit config", editor_cmd .. " " .. awesome.conffile },
153 { "restart", awesome.restart },
162 local menu_awesome = { "awesome", myawesomemenu, beautiful.awesome_icon }
163 local menu_terminal = { "open terminal", terminal }
166 mymainmenu = freedesktop.menu.build({
167 before = { menu_awesome },
168 after = { menu_terminal },
171 mymainmenu = awful.menu({
174 { "Debian", debian.menu.Debian_menu.Debian },
180 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu })
182 -- Menubar configuration
183 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
187 --local spacer = wibox.widget {
188 -- color = beautiful.bg_minimize,
190 -- widget = wibox.widget.separator
192 local function make_spacer(text)
193 local spacer = wibox.widget.textbox()
194 spacer:set_text(text or " │ ")
198 -- Keyboard map indicator and switcher
199 mykeyboardlayout = awful.widget.keyboardlayout()
201 local lain_bat = lain.widget.bat({
202 batteries = { "BAT0", "BAT1" },
203 settings = function()
205 if bat_now.status == "Charging" then
207 elseif bat_now.status == "Unknown" then
210 widget:set_text(bat_now.perc .. "% " .. delim .. " " .. bat_now.time)
214 -- Create a textclock widget
215 clocksarray = clocksarray.get_clocksarray("%a %d %b %H:%M:%S %Z", {
216 -- ["NZ"] = "Pacific/Auckland",
217 ["DE"] = "Europe/Berlin",
220 -- Create a wibox for each screen and add it
221 local taglist_buttons = gears.table.join(
222 awful.button({}, 1, function(t)
225 awful.button({ modkey }, 1, function(t)
227 client.focus:move_to_tag(t)
230 awful.button({}, 3, awful.tag.viewtoggle),
231 awful.button({ modkey }, 3, function(t)
233 client.focus:toggle_tag(t)
236 awful.button({}, 4, function(t)
237 awful.tag.viewnext(t.screen)
239 awful.button({}, 5, function(t)
240 awful.tag.viewprev(t.screen)
244 local tasklist_buttons = gears.table.join(
245 awful.button({}, 1, function(c)
246 if c == client.focus then
247 -- I don't like click-minimising
248 -- c.minimized = true
250 -- Without this, the following
251 -- :isvisible() makes no sense
253 if not c:isvisible() and c.first_tag then
254 c.first_tag:view_only()
256 -- This will also un-minimize
257 -- the client, if needed
262 awful.button({}, 3, client_menu_toggle_fn()),
263 awful.button({}, 4, function()
264 awful.client.focus.byidx(1)
266 awful.button({}, 5, function()
267 awful.client.focus.byidx(-1)
274 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
275 screen.connect_signal("property::geometry", set_wallpaper)
277 -- {{{ Basic setup for screens
278 local function screen_set_profile(s, profile)
280 s.outputstr = table.concat(gears.table.keys(s.outputs), "+")
281 s.name = s.profile .. "/" .. s.outputstr
284 awful.screen.connect_for_each_screen(function(s)
285 s.set_profile = screen_set_profile
290 -- Create a text widget to display screen name
291 s.namebox = wibox.container.background(wibox.widget.textbox(s.name), beautiful.bg_minimize)
293 -- Create a promptbox for each screen
294 s.mypromptbox = awful.widget.prompt()
295 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
296 -- We need one layoutbox per screen.
297 s.mylayoutbox = awful.widget.layoutbox(s)
298 s.mylayoutbox:buttons(awful.util.table.join(
299 awful.button({}, 1, function()
302 awful.button({}, 3, function()
305 awful.button({}, 4, function()
308 awful.button({}, 5, function()
312 -- Create a taglist widget
313 s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
315 -- Create a tasklist widget
316 s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
318 beautiful.tasklist_disable_icon = true
320 -- Create the wibox, but only if there isn't one yet
321 if not s.mywibox then
322 s.mywibox = awful.wibar({ position = "top", screen = s })
325 -- Add widgets to the wibox
326 local right_widgets = gears.table.join(clocksarray, {
328 wibox.widget.systray(),
330 layout = wibox.layout.fixed.horizontal,
333 -- if s == screen.primary then
334 right_widgets = gears.table.join({
336 ccwidgets.btc_widget,
338 --ccwidgets.eth_widget,
340 --fxwidgets.ecb_widget,
348 layout = wibox.layout.align.horizontal,
350 layout = wibox.layout.fixed.horizontal,
356 s.mytasklist, -- Middle widget
361 -- {{{ autorandr integration
362 local function find_screen_by_pattern(pattern)
364 print(s.name .. " :: " .. pattern)
365 if s.name:match(pattern) then
371 local function get_target_screen_for_tag(tag)
372 local function primary_screen(reason)
373 local s = screen.primary
374 local msg = ' → primary screen "' .. s.name .. '"'
376 msg = msg .. " (" .. reason .. ")"
382 print("Figuring out target screen for tag " .. tag.name .. "…")
384 if type(tag.targets) == "table" then
385 for _, target in ipairs(tag.targets) do
386 local s = find_screen_by_pattern(target:gsub("%-", "%%-"))
388 print(" → screen " .. s.name)
392 elseif tag.targets == "primary" then
393 return primary_screen("explicit request")
395 return primary_screen("no matching target in " .. table.concat(tag.targets, ","))
397 return primary_screen("no targets specified")
401 local function move_tag_to_target_screen(tag)
402 tag.screen = get_target_screen_for_tag(tag)
405 local function move_tags_to_target_screens()
406 for _, tag in ipairs(root.tags()) do
407 move_tag_to_target_screen(tag)
411 tag.connect_signal("request::screen", function(t)
412 -- throw the tag onto any other screen, it'll get reassigned later when
413 -- a new profile has been processed.
415 if s ~= t.screen then
422 title = "Screen removed",
423 text = "Salvaged tab " .. t.name,
427 function handle_new_autorandr_profile(newprofile)
428 -- The main idea here is that autorandr invokes this via awesome-client
429 -- after switching to a new profile. Awesome will have already set up all
430 -- the screens long before this function is called. Therefore, we just do
431 -- the necessary modifications to the existing screens, and move tags
434 if not newprofile then
435 error("Missing new profile name")
439 preset = naughty.config.presets.low,
440 title = "New autorandr profile",
441 text = "Reconfiguring for profile <b>" .. newprofile .. "</b>",
445 s:set_profile(newprofile)
447 move_tags_to_target_screens()
450 local function initialise_to_autorandr_profile()
454 local function process_line(line)
458 local match = string.match(line, "^([^%s]+) %(detected%)")
464 local function output_done()
466 error("autorandr detected no profile")
469 handle_new_autorandr_profile(profile)
472 local function handle_exit(reason, code)
473 if not (reason == "exit" and code == 0) then
474 error("autorandr error: " .. reason .. ": " .. tostring(code))
478 awful.spawn.with_line_callback("autorandr", {
479 stdout = process_line,
480 output_done = output_done,
484 awesome.connect_signal("startup", initialise_to_autorandr_profile)
491 local default_tag = {
494 layout = layouts.default,
498 local default_tags = {}
501 for k, v in pairs(default_tag) do
502 default_tags[i][k] = v
504 default_tags[i].name = tostring(i)
506 default_tags[1].selected = true
508 default_tags = gears.table.join(default_tags, {
513 layout = layouts.maximised,
515 exec_once = { "remmina" },
516 instance = { "Remmina" },
520 "krafftwerk/DP-?1-1-5",
521 "krafftwerk/DisplayPort-2",
529 layout = layouts.tiled,
533 .. " -name irc -e env MOSH_TITLE_NOPREFIX=true mosh --family=all -- irc-host tmux new -As irc irssi",
535 instance = { "irc" },
539 "krafftwerk/DP-?1-1-5",
540 "krafftwerk/DisplayPort-2",
542 "rw-[lr]/DisplayPort-[01]",
551 layout = layouts.tiled,
556 "krafftwerk/DP-?1-1-5",
557 "krafftwerk/DisplayPort-2",
559 "rw-[lr]/DisplayPort-[01]",
566 layout = layouts.floating,
574 layout = layouts.default,
575 exec_once = { "thunderbird" },
576 class = { "thunderbird" },
580 "krafftwerk/DP-?1-1-6",
581 "krafftwerk/DisplayPort-0",
583 "rw-[lr]/DisplayPort-[01]",
590 layout = layouts.default,
591 exec_once = { "chromium" },
592 class = { "Chromium" },
596 "krafftwerk/DP-?1-1-6",
597 "krafftwerk/DisplayPort-0",
600 "rw-[lr]/DisplayPort-[01]",
608 layout = layouts.default,
609 exec_once = { "firefox" },
610 class = { "Firefox" },
614 "krafftwerk/DP-?1-1-6",
615 "krafftwerk/DisplayPort-0",
618 "rw-[lr]/DisplayPort-[01]",
623 if not tyrannical then
624 for _, t in ipairs(default_tags) do
626 t.screen = t.screen or screen.primary
627 t.layout = t.layout or layouts.default
628 local newt = th.add_tag(t.name, t, false)
631 else -- {{{ tyrannical is loaded
632 tyrannical.settings.default_layout = layouts.default
633 tyrannical.settings.master_width_factor = 0.5
634 tyrannical.settings.block_children_focus_stealing = true
635 tyrannical.settings.group_children = true
637 tyrannical.tags = default_tags
639 tyrannical.properties.size_hints_honor = { URxvt = false }
641 --XX---- Ignore the tag "exclusive" property for the following clients (matched by classes)
642 --XX--tyrannical.properties.intrusive = {
643 --XX-- "ksnapshot" , "pinentry" , "gtksu" , "kcalc" , "xcalc" ,
644 --XX-- "feh" , "Gradient editor", "About KDE" , "Paste Special", "Background color" ,
645 --XX-- "kcolorchooser" , "plasmoidviewer" , "Xephyr" , "kruler" , "plasmaengineexplorer",
648 --XX---- Ignore the tiled layout for the matching clients
649 --XX--tyrannical.properties.floating = {
650 --XX-- "MPlayer" , "pinentry" , "ksnapshot" , "pinentry" , "gtksu" ,
651 --XX-- "xine" , "feh" , "kmix" , "kcalc" , "xcalc" ,
652 --XX-- "yakuake" , "Select Color$" , "kruler" , "kcolorchooser", "Paste Special" ,
653 --XX-- "New Form" , "Insert Picture" , "kcharselect", "mythfrontend" , "plasmoidviewer"
656 --XX---- Make the matching clients (by classes) on top of the default layout
657 --XX--tyrannical.properties.ontop = {
658 --XX-- "Xephyr" , "ksnapshot" , "kruler"
661 --XX---- Force the matching clients (by classes) to be centered on the screen on init
662 --XX--tyrannical.properties.centered = {
669 -- {{{ Mouse bindings
670 root.buttons(gears.table.join(
671 awful.button({}, 3, function()
674 awful.button({}, 4, awful.tag.viewnext),
675 awful.button({}, 5, awful.tag.viewprev)
681 local function toggle_tag_by_name(tagname, exclusive)
683 local t = awful.tag.find_by_name(nil, tagname)
688 awful.tag.viewtoggle(t)
690 cf = awful.client.getmaster(t.screen)
698 local function move_tags_to_screen_relative(direction)
699 local s = awful.screen.focused()
700 local ts = screen:count() - (s.index + direction) % screen:count()
701 for _, tag in ipairs(s.selected_tags) do
702 print("index: " .. s.index .. " count: " .. screen:count() .. " target: " .. ts)
703 tag.screen = screen[ts]
705 for _, t in ipairs(tag.screen.tags) do
706 t.selected = (tag == t)
711 globalkeys = gears.table.join(
712 awful.key({ modkey }, "s", hotkeys_popup.show_help, { description = "show help", group = "awesome" }),
713 awful.key({ modkey }, "Left", awful.tag.viewprev, { description = "view previous", group = "tag" }),
714 awful.key({ modkey }, "Right", awful.tag.viewnext, { description = "view next", group = "tag" }),
715 awful.key({ modkey }, "Escape", awful.tag.history.restore, { description = "go back", group = "tag" }),
717 awful.key({ modkey }, "k", function()
718 awful.client.focus.byidx(1)
719 end, { description = "focus next by index", group = "client" }),
720 awful.key({ modkey }, "j", function()
721 awful.client.focus.byidx(-1)
722 end, { description = "focus previous by index", group = "client" }),
724 -- Layout manipulation
725 awful.key({ modkey, "Shift" }, "k", function()
726 awful.client.swap.byidx(1)
727 end, { description = "swap with next client by index", group = "client" }),
728 awful.key({ modkey, "Shift" }, "j", function()
729 awful.client.swap.byidx(-1)
730 end, { description = "swap with previous client by index", group = "client" }),
731 awful.key({ modkey, "Control" }, "k", function()
732 awful.screen.focus_relative(1)
733 end, { description = "focus the next screen", group = "screen" }),
734 awful.key({ modkey, "Control" }, "j", function()
735 awful.screen.focus_relative(-1)
736 end, { description = "focus the previous screen", group = "screen" }),
737 awful.key({ modkey, "Shift", "Control" }, "k", function()
738 move_tags_to_screen_relative(1)
739 end, { description = "move tags to the next screen", group = "screen" }),
740 awful.key({ modkey, "Shift", "Control" }, "j", function()
741 move_tags_to_screen_relative(-1)
742 end, { description = "move tags to the previous screen", group = "screen" }),
746 awful.client.urgent.jumpto,
747 { description = "jump to urgent client", group = "client" }
749 awful.key({ modkey }, "Tab", function()
750 awful.client.focus.history.previous()
754 end, { description = "go back", group = "client" }),
757 awful.key({ modkey }, "Return", function()
758 awful.spawn(terminal)
759 end, { description = "open a terminal", group = "launcher" }),
760 awful.key({ modkey }, "r", function()
761 package.loaded.rc = nil
763 end, { description = "reload rc.lua", group = "awesome" }),
764 awful.key({ modkey, "Control" }, "r", awesome.restart, { description = "reload awesome", group = "awesome" }),
765 awful.key({ modkey, "Shift" }, "q", awesome.quit, { description = "quit awesome", group = "awesome" }),
767 awful.key({ modkey }, "l", function()
768 awful.tag.incmwfact(0.05)
769 end, { description = "increase master width factor", group = "layout" }),
770 awful.key({ modkey }, "h", function()
771 awful.tag.incmwfact(-0.05)
772 end, { description = "decrease master width factor", group = "layout" }),
773 awful.key({ modkey, "Shift" }, "h", function()
774 awful.tag.incnmaster(1, nil, true)
775 end, { description = "increase the number of master clients", group = "layout" }),
776 awful.key({ modkey, "Shift" }, "l", function()
777 awful.tag.incnmaster(-1, nil, true)
778 end, { description = "decrease the number of master clients", group = "layout" }),
779 awful.key({ modkey, "Control" }, "h", function()
780 awful.tag.incncol(1, nil, true)
781 end, { description = "increase the number of columns", group = "layout" }),
782 awful.key({ modkey, "Control" }, "l", function()
783 awful.tag.incncol(-1, nil, true)
784 end, { description = "decrease the number of columns", group = "layout" }),
785 awful.key({ modkey }, "space", function()
787 end, { description = "select next", group = "layout" }),
788 awful.key({ modkey, "Shift" }, "space", function()
790 end, { description = "select previous", group = "layout" }),
792 awful.key({ modkey, "Control" }, "n", function()
793 local c = awful.client.restore()
794 -- Focus restored client
799 end, { description = "restore minimized", group = "client" }),
802 awful.key({ cmdkey }, "r", function()
803 local widget = awful.screen.focused().mypromptbox.widget
804 local function spawn(command, args)
805 gears.debug.dump(args)
806 awful.spawn(command, args)
811 bg_cursor = "#ff0000",
813 history_path = awful.util.get_cache_dir() .. "/history",
814 completion_callback = awful.completion.shell,
816 -- Replace the 'normal' Return with a custom one
824 -- Spawn method to spawn in the current tag
831 tag = mouse.screen.selected_tag,
835 -- Spawn in the current tag as floating and on top
843 tag = mouse.screen.selected_tag,
847 -- Spawn in a new tag
854 layout = layouts.default,
869 end, { description = "run prompt", group = "launcher" }),
871 awful.key({ modkey }, "x", function()
874 bg_cursor = "#ff0000",
875 textbox = awful.screen.focused().mypromptbox.widget,
876 exe_callback = awful.util.eval,
877 history_path = awful.util.get_cache_dir() .. "/history_eval",
879 end, { description = "lua execute prompt", group = "awesome" }),
881 awful.key({ modkey }, "w", function()
883 end, { description = "show the menubar", group = "launcher" }),
886 awful.key({ modkey }, "a", function()
887 th.add_tag(nil, { layout = layouts.default }, true)
888 end, { description = "add a tag", group = "tag" }),
889 awful.key({ modkey }, "d", th.delete_tag, { description = "delete the current tag", group = "tag" }),
890 awful.key({ modkey, "Shift" }, "a", function()
891 th.move_to_new_tag(nil, nil, { layout = layouts.maximised }, true, true, true)
892 end, { description = "add a volatile tag with the focused client", group = "tag" }),
893 awful.key({ modkey, "Shift", "Control" }, "a", function()
894 th.move_to_new_tag(nil, nil, { layout = layouts.maximised }, false, true, true)
895 end, { description = "add a permanent tag with the focused client", group = "tag" }),
896 awful.key({ modkey, "Mod1" }, "a", th.copy_tag, { description = "create a copy of the current tag", group = "tag" }),
897 awful.key({ modkey, "Control" }, "a", th.rename_tag, { description = "rename the current tag", group = "tag" }),
899 { modkey, "Control", "Shift", "Mod1" },
901 th.collect_orphan_clients_to_tag,
902 { description = "collect all orphaned clients", group = "client" }
905 awful.key({ modkey }, "t", toggle_tag_by_name("vrt", true), { description = "view tag 'vrt'", group = "tag" }),
907 { modkey, "Control" },
909 toggle_tag_by_name("vrt"),
910 { description = "toggle tag 'vrt'", group = "tag" }
912 awful.key({ modkey }, "y", toggle_tag_by_name("irc", true), { description = "view tag 'irc'", group = "tag" }),
914 { modkey, "Control" },
916 toggle_tag_by_name("irc"),
917 { description = "toggle tag 'irc'", group = "tag" }
919 awful.key({ modkey }, "u", toggle_tag_by_name("[]", true), { description = "view tag '[]'", group = "tag" }),
920 awful.key({ modkey, "Control" }, "u", toggle_tag_by_name("[]"), { description = "toggle tag '[]'", group = "tag" }),
921 awful.key({ modkey }, "i", toggle_tag_by_name("cal", true), { description = "view tag 'cal'", group = "tag" }),
923 { modkey, "Control" },
925 toggle_tag_by_name("cal"),
926 { description = "toggle tag 'cal'", group = "tag" }
928 awful.key({ modkey }, "o", toggle_tag_by_name("chr", true), { description = "view tag 'chr'", group = "tag" }),
930 { modkey, "Control" },
932 toggle_tag_by_name("chr"),
933 { description = "toggle tag 'chr'", group = "tag" }
935 awful.key({ modkey }, "p", toggle_tag_by_name("ffx", true), { description = "view tag 'ff'", group = "tag" }),
936 awful.key({ modkey, "Control" }, "p", toggle_tag_by_name("ffx"), { description = "toggle tag 'ff'", group = "tag" }),
940 clientkeys = gears.table.join(
941 awful.key({ modkey }, "f", function(c)
942 c.fullscreen = not c.fullscreen
944 end, { description = "toggle fullscreen", group = "client" }),
945 awful.key({ modkey, "Shift" }, "c", function(c)
947 end, { description = "close", group = "client" }),
949 { modkey, "Control" },
951 awful.client.floating.toggle,
952 { description = "toggle floating", group = "client" }
954 awful.key({ modkey, "Control" }, "Return", function(c)
955 c:swap(awful.client.getmaster())
956 end, { description = "move to master", group = "client" }),
957 awful.key({ modkey }, "z", function(c)
959 end, { description = "move to screen", group = "client" }),
960 --awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
961 -- {description = "toggle keep on top", group = "client"}),
962 awful.key({ modkey }, "n", function(c)
963 -- The client currently has the input focus, so it cannot be
964 -- minimized, since minimized clients can't have the focus.
966 end, { description = "minimize", group = "client" }),
967 awful.key({ modkey }, "m", function(c)
968 c.maximized = not c.maximized
969 c.maximized_horizontal = false
970 c.maximized_vertical = false
972 end, { description = "(un)maximize", group = "client" }),
973 awful.key({ modkey, "Control" }, "m", function(c)
974 c.maximized_vertical = not c.maximized_vertical
976 end, { description = "(un)maximize vertically", group = "client" }),
977 awful.key({ modkey, "Shift" }, "m", function(c)
978 c.maximized_horizontal = not c.maximized_horizontal
980 end, { description = "(un)maximize horizontally", group = "client" })
983 -- Bind all key numbers to tags.
984 -- Be careful: we use keycodes to make it work on any keyboard layout.
985 -- This should map on the top row of your keyboard, usually 1 to 9.
987 globalkeys = gears.table.join(
993 toggle_tag_by_name(tostring(i), true),
994 { description = "view tag #" .. i, group = "tag" }
996 -- Toggle tag display.
998 { modkey, "Control" },
1000 toggle_tag_by_name(tostring(i)),
1001 { description = "toggle tag #" .. i, group = "tag" }
1003 -- Move client to tag.
1004 awful.key({ modkey, "Shift" }, "#" .. i + 9, function()
1005 if client.focus then
1006 local tag = awful.tag.find_by_name(screen.primary, tostring(i))
1008 client.focus:move_to_tag(tag)
1011 end, { description = "move focused client to tag #" .. i, group = "tag" }),
1012 -- Toggle tag on focused client.
1013 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function()
1014 if client.focus then
1015 local tag = awful.tag.find_by_name(screen.primary, tostring(i))
1017 client.focus:toggle_tag(tag)
1020 end, { description = "toggle focused client on tag #" .. i, group = "tag" })
1024 clientbuttons = gears.table.join(
1025 awful.button({}, 1, function(c)
1029 awful.button({ modkey }, 1, awful.mouse.client.move),
1030 awful.button({ modkey }, 3, awful.mouse.client.resize)
1034 globalkeys = awful.util.table.join(
1036 awful.key({ cmdkey }, "n", function()
1037 awful.spawn("firefox")
1039 awful.key({ cmdkey }, "c", function()
1040 awful.spawn("chromium --enable-remote-extensions")
1042 awful.key({ cmdkey }, "y", function()
1043 awful.spawn(terminal .. " -e ipython3")
1045 awful.key({ cmdkey }, "m", function()
1046 awful.spawn(terminal .. " -name mutt -e mutt")
1048 awful.key({ cmdkey }, "t", function()
1049 awful.spawn("thunderbird")
1051 awful.key({ cmdkey }, "g", function()
1052 awful.spawn("gscan2pdf")
1054 awful.key({ cmdkey, "Shift" }, "v", function()
1055 awful.spawn("virt-manager")
1057 awful.key({ cmdkey, "Shift" }, "r", function()
1058 awful.spawn("remmina")
1060 awful.key({ cmdkey }, "l", function()
1061 awful.spawn("libreoffice")
1063 awful.key({ cmdkey }, "v", function()
1064 awful.spawn("virt-viewer")
1066 awful.key({ cmdkey }, "p", function()
1067 awful.spawn("pavucontrol")
1069 awful.key({ cmdkey }, "i", function()
1072 .. " -name irc -e env MOSH_TITLE_NOPREFIX=true mosh --family=all -- irc-host tmux new -As irc irssi"
1075 awful.key({ cmdkey }, "x", function()
1077 "sh -c '. ~/.xsession.d/10-xautolock; echo \"Locking…\"; sleep 1; xautolock -locknow'",
1078 "Enabling xautolock"
1081 awful.key({ cmdkey, "Shift" }, "x", function()
1082 run_output_notify("pkill -e xautolock", "Disabling xautolock")
1085 awful.key({ cmdkey }, "BackSpace", function()
1086 awful.spawn("pkill -USR1 offlineimap")
1090 awful.key(nil, "XF86ScreenSaver", function()
1091 awful.spawn("xset dpms force off")
1093 awful.key(nil, "XF86AudioMute", function()
1094 awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")
1096 awful.key({ cmdkey }, "End", function()
1097 awful.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")
1099 awful.key(nil, "XF86AudioLowerVolume", function()
1100 awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ -2%")
1102 awful.key({ cmdkey }, "Next", function()
1103 awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ -2%")
1105 awful.key(nil, "XF86AudioRaiseVolume", function()
1106 awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ +2%")
1108 awful.key({ cmdkey }, "Prior", function()
1109 awful.spawn("pactl set-sink-volume @DEFAULT_SINK@ +2%")
1111 awful.key(nil, "XF86AudioMicMute", function()
1112 awful.spawn("pactl set-source-mute @DEFAULT_SOURCE@ toggle")
1114 awful.key({ cmdkey }, "Home", function()
1115 awful.spawn("pactl set-source-mute @DEFAULT_SOURCE@ toggle")
1117 awful.key({ cmdkey }, "Insert", function()
1118 awful.spawn("pa_cycle_default source")
1120 awful.key({ cmdkey }, "Delete", function()
1121 awful.spawn("pa_cycle_default sink")
1123 awful.key(nil, "XF86MonBrightnessDown", function()
1124 awful.spawn("light -U 10")
1126 awful.key(nil, "XF86MonBrightnessUp", function()
1127 awful.spawn("light -A 10")
1129 awful.key(nil, "XF86Display", function()
1130 awful.spawn("autorandr --change --force")
1131 initialise_to_autorandr_profile()
1133 awful.key(nil, "XF86AudioStop", function()
1134 awful.spawn("autorandr --change --force")
1135 initialise_to_autorandr_profile()
1137 awful.key(nil, "XF86WLAN", function()
1140 awful.key(nil, "XF86Tools", function()
1143 awful.key(nil, "XF86Search", function()
1146 awful.key(nil, "XF86LaunchA", function()
1149 awful.key(nil, "XF86Explorer", function()
1152 awful.key(nil, "XF86Calculator", function()
1153 awful.spawn(terminal .. " -e ipython3 --profile=calc")
1155 awful.key(nil, "XF86Favorites", function()
1156 awful.spawn("systemctl suspend")
1159 awful.key({ cmdkey }, "Multi_key", function()
1160 run_output_notify("flameshot gui", "Output")
1162 awful.key({ cmdkey, "Shift" }, "Multi_key", function()
1163 run_output_notify("flameshot full --delay 2000 --clipboard", "Output")
1166 awful.key({ cmdkey }, "Up", function()
1167 awful.spawn("pap prev")
1169 awful.key({ cmdkey }, "Left", function()
1170 awful.spawn("pap seek -10")
1172 awful.key({ cmdkey, "Shift" }, "Left", function()
1173 awful.spawn("pap seek -60")
1175 awful.key({ cmdkey }, "Down", function()
1176 awful.spawn("pap next")
1178 awful.key({ cmdkey }, "Right", function()
1179 awful.spawn("pap seek +10")
1181 awful.key({ cmdkey, "Shift" }, "Right", function()
1182 awful.spawn("pap seek +60")
1184 awful.key({ cmdkey }, "space", function()
1185 awful.spawn("pap pause")
1187 awful.key({ cmdkey }, "\\", function()
1188 run_output_notify("pap info", "Track info")
1190 awful.key({ cmdkey }, "]", function()
1191 run_output_notify("pap list", "Playlist")
1195 function run_output_notify(cmd, title)
1196 awful.spawn.easy_async(cmd, function(stdout, stderr, reason, exit_code)
1199 preset = naughty.config.presets.low,
1208 root.keys(globalkeys)
1212 -- Rules to apply to new clients (through the "manage" signal).
1214 local function float_client_in_the_middle_with_margins(client, leftright, topbottom)
1215 local wa = client.screen.workarea
1217 client.y = wa.y + topbottom
1218 client.height = wa.height - 2 * topbottom
1220 client.y = wa.y + (wa.height - client.height) / 2
1223 client.x = wa.x + leftright
1224 client.width = wa.width - 2 * leftright
1226 client.x = wa.x + (wa.width - client.width) / 2
1230 local function move_to_tag_by_name(s, tagname)
1232 local t = awful.tag.find_by_name(s, tagname)
1234 error("No tag by the name of " .. tagname)
1241 local function move_to_tag_or_create_volatile(s, tagname)
1243 local t = awful.tag.find_by_name(s, tagname)
1247 th.move_to_new_tag(c, tagname, {}, true, true, true)
1252 awful.rules.rules = {
1253 -- All clients will match this rule.
1257 border_width = beautiful.border_width,
1258 border_color = beautiful.border_normal,
1259 focus = awful.client.focus.filter,
1262 buttons = clientbuttons,
1263 screen = awful.screen.preferred,
1264 placement = awful.placement.no_overlap + awful.placement.no_offscreen,
1270 rule = { type = "dialog" },
1274 skip_taskbar = true,
1277 --switchtotag = true,
1278 placement = awful.placement.centered,
1281 { rule_any = { class = { "URxvt", "kitty" } }, properties = { size_hints_honor = false } },
1282 { rule = { instance = "irc" }, callback = move_to_tag_by_name(nil, "irc") },
1283 { rule = { class = "scrcpy" }, callback = move_to_tag_by_name(nil, "[]") },
1284 { rule_any = { class = { "Firefox", "firefox" } }, callback = move_to_tag_by_name(nil, "ffx") },
1288 "org.remmina.Remmina",
1293 callback = move_to_tag_by_name(nil, "vrt"),
1295 { rule = { class = "Chromium" }, callback = move_to_tag_by_name(nil, "chr") },
1296 { rule_any = { class = { "thunderbird", "Thunderbird" } }, callback = move_to_tag_by_name(nil, "cal") },
1298 rule = { instance = "mutt" },
1302 layout = awful.layout.suit.fair.horizontal,
1308 { rule_any = { class = { "zoom" } }, callback = move_to_tag_or_create_volatile(nil, "Zoom") },
1311 class = { "Ssvnc.tcl" },
1312 class = { "Ssvnc" },
1313 name = { "SSL/SSH VNC Viewer.-" },
1315 callback = move_to_tag_or_create_volatile(nil, "SSVNC"),
1318 rule_any = { class = {
1326 placement = awful.placement.centered,
1342 placement = awful.placement.centered,
1357 except_any = { type = { "dialog" } },
1360 layout = layouts.maximised,
1368 rule_any = { class = {
1371 except_any = { type = { "dialog" } },
1374 layout = layouts.default,
1380 placement = awful.placement.centered,
1385 --XX-- { rule = { class = "Gscan2pdf" },
1386 --XX-- properties = {
1387 --XX-- switchtotag = true
1389 --XX-- callback = move_to_tag(1, 5)
1391 --XX-- { rule = { name = "gscan2pdf .*" },
1392 --XX-- properties = {
1393 --XX-- floating = false,
1396 --XX-- { rule = { class = "Thunar", type = "normal" },
1397 --XX-- properties = {
1398 --XX-- floating = false,
1401 --XX-- { rule = { class = "Pinentry", instance = "pinentry" },
1402 --XX-- properties = {
1403 --XX-- floating = true,
1406 --XX-- { rule = { class = "Gxmessage" },
1407 --XX-- properties = {
1408 --XX-- floating = true,
1416 -- Signal function to execute when a new client appears.
1417 client.connect_signal("manage", function(c)
1418 -- Set the windows at the slave,
1419 -- i.e. put it at the end of others instead of setting it master.
1420 -- if not awesome.startup then awful.client.setslave(c) end
1421 --if not awesome.startup then
1422 -- local t = awful.screen.focused().selected_tag
1423 -- if t.name == "xmutt" then
1424 -- awful.client.setslave(c)
1428 if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
1429 -- Prevent clients from being unreachable after screen count changes.
1430 awful.placement.no_offscreen(c)
1433 c.maximized_horizontal = false
1434 c.maximized_vertical = false
1437 -- Add a titlebar if titlebars_enabled is set to true in the rules.
1438 client.connect_signal("request::titlebars", function(c)
1439 -- buttons for the titlebar
1440 local buttons = gears.table.join(
1441 awful.button({}, 1, function()
1444 awful.mouse.client.move(c)
1446 awful.button({}, 3, function()
1449 awful.mouse.client.resize(c)
1453 awful.titlebar(c):setup({
1454 { -- Left = "center",
1455 widget = awful.titlebar.widget.titlewidget(c),
1457 layout = wibox.layout.flex.horizontal,
1460 awful.titlebar.widget.floatingbutton(c),
1461 awful.titlebar.widget.maximizedbutton(c),
1462 awful.titlebar.widget.stickybutton(c),
1463 awful.titlebar.widget.ontopbutton(c),
1464 awful.titlebar.widget.closebutton(c),
1465 layout = wibox.layout.fixed.horizontal(),
1467 layout = wibox.layout.align.horizontal,
1471 -- Enable sloppy focus, so that focus follows mouse.
1472 client.connect_signal("mouse::enter", function(c)
1473 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier and awful.client.focus.filter(c) then
1476 --17 18:03 < psychon> madduck: yes. In the default config at the very end there is code that actives a client on mouse::enter. Just add if c.class == "whatever virt-viewer uses" then return end to that, or
1477 -- something like this
1480 client.connect_signal("focus", function(c)
1481 c.border_color = beautiful.border_focus
1483 client.connect_signal("unfocus", function(c)
1484 c.border_color = beautiful.border_normal
1487 awful.ewmh.add_activate_filter(function(c, context, hints)
1488 if context == "ewmh" then
1489 if c.class == "Firefox-esr" or c.class == "Firefox" then
1495 client.connect_signal("request::activate", function(c, context, hints)
1497 gears.table.hasitem({
1498 "client.focus.byidx",
1500 "autofocus.check_focus",
1505 gears.timer.delayed_call(function()
1506 -- we need a delayed call so that we execute *after layout changes
1507 if hints.raise and c == client.focus and client.focus:isvisible() then
1508 move_mouse_to_area(client.focus)
1514 -- vim:ft=lua:sw=4:sts=4:ts=4:et