From 3e591033e51fdb35ed2a6c5b5f712eec82750a20 Mon Sep 17 00:00:00 2001 From: Luca Capezzuto Date: Tue, 13 Apr 2021 14:21:11 +0200 Subject: [PATCH] rc.lua.template and freedesktop updated --- README.rst | 2 +- freedesktop | 2 +- lain | 2 +- rc.lua.template | 325 ++++++++++++++++++++++++++---------------------- 4 files changed, 177 insertions(+), 154 deletions(-) diff --git a/README.rst b/README.rst index 0be4783..64e9349 100644 --- a/README.rst +++ b/README.rst @@ -151,7 +151,7 @@ Every theme has a colorscheme_. Additional default software used: :: - dmenu firefox mpc mpd scrot unclutter xsel slock + amixer dmenu librewolf mpc mpd scrot unclutter xbacklight xsel slock .. _BY-NC-SA: http://creativecommons.org/licenses/by-nc-sa/4.0 .. _Awesome: http://github.com/awesomeWM/awesome diff --git a/freedesktop b/freedesktop index b77dee0..e4ac597 160000 --- a/freedesktop +++ b/freedesktop @@ -1 +1 @@ -Subproject commit b77dee0250599b2810efadf34f612f32c7ceb556 +Subproject commit e4ac597ea809cbc4b08be1d0dfdb871b6b0db9c3 diff --git a/lain b/lain index da418f2..5882000 160000 --- a/lain +++ b/lain @@ -1 +1 @@ -Subproject commit da418f2ec60672d4fa3ce3cb2087e16292fa0adf +Subproject commit 5882000904d06e2a85e11807a67990aed86b1510 diff --git a/rc.lua.template b/rc.lua.template index 3fa7b65..818526e 100644 --- a/rc.lua.template +++ b/rc.lua.template @@ -6,8 +6,10 @@ --]] -- {{{ Required libraries -local awesome, client, mouse, screen, tag = awesome, client, mouse, screen, tag -local ipairs, string, os, table, tostring, tonumber, type = ipairs, string, os, table, tostring, tonumber, type + +-- If LuaRocks is installed, make sure that packages installed through it are +-- found (e.g. lgi). If LuaRocks is not installed, do nothing. +pcall(require, "luarocks.loader") local gears = require("gears") local awful = require("awful") @@ -18,34 +20,43 @@ local naughty = require("naughty") local lain = require("lain") --local menubar = require("menubar") local freedesktop = require("freedesktop") -local hotkeys_popup = require("awful.hotkeys_popup").widget +local hotkeys_popup = require("awful.hotkeys_popup") require("awful.hotkeys_popup.keys") -local my_table = awful.util.table or gears.table -- 4.{0,1} compatibility -local dpi = require("beautiful.xresources").apply_dpi +local mytable = awful.util.table or gears.table -- 4.{0,1} compatibility + -- }}} -- {{{ Error handling + -- Check if awesome encountered an error during startup and fell back to -- another config (This code will only ever execute for the fallback config) if awesome.startup_errors then - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, there were errors during startup!", - text = awesome.startup_errors }) + naughty.notify { + preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors + } end -- Handle runtime errors after startup do local in_error = false + awesome.connect_signal("debug::error", function (err) if in_error then return end + in_error = true - naughty.notify({ preset = naughty.config.presets.critical, - title = "Oops, an error happened!", - text = tostring(err) }) + naughty.notify { + preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) + } + in_error = false end) end + -- }}} -- {{{ Autostart windowless processes @@ -57,7 +68,7 @@ local function run_once(cmd_arr) end end -run_once({ "urxvtd", "unclutter -root" }) -- entries must be separated by commas +run_once({ "urxvtd", "unclutter -root" }) -- comma-separated entries -- This function implements the XDG autostart specification --[[ @@ -83,19 +94,17 @@ local themes = { "powerarrow-dark", -- 7 "rainbow", -- 8 "steamburn", -- 9 - "vertex", -- 10 + "vertex" -- 10 } local chosen_theme = themes[5] local modkey = "Mod4" local altkey = "Mod1" local terminal = "urxvtc" -local vi_focus = false -- vi-like client focus - https://github.com/lcpz/awesome-copycats/issues/275 -local cycle_prev = true -- cycle trough all previous client or just the first -- https://github.com/lcpz/awesome-copycats/issues/274 -local editor = os.getenv("EDITOR") or "vim" -local gui_editor = os.getenv("GUI_EDITOR") or "gvim" -local browser = os.getenv("BROWSER") or "firefox" -local scrlocker = "slock" +local vi_focus = false -- vi-like client focus https://github.com/lcpz/awesome-copycats/issues/275 +local cycle_prev = true -- cycle with only the previously focused client or all https://github.com/lcpz/awesome-copycats/issues/274 +local editor = os.getenv("EDITOR") or "nvim" +local browser = "librewolf" awful.util.terminal = terminal awful.util.tagnames = { "1", "2", "3", "4", "5" } @@ -121,85 +130,63 @@ awful.layout.layouts = { --lain.layout.centerwork, --lain.layout.centerwork.horizontal, --lain.layout.termfair, - --lain.layout.termfair.center, + --lain.layout.termfair.center } -awful.util.taglist_buttons = my_table.join( - awful.button({ }, 1, function(t) t:view_only() end), - awful.button({ modkey }, 1, function(t) - if client.focus then - client.focus:move_to_tag(t) - end - end), - awful.button({ }, 3, awful.tag.viewtoggle), - awful.button({ modkey }, 3, function(t) - if client.focus then - client.focus:toggle_tag(t) - end - end), - awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), - awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) -) - -awful.util.tasklist_buttons = my_table.join( - awful.button({ }, 1, function (c) - if c == client.focus then - c.minimized = true - else - --c:emit_signal("request::activate", "tasklist", {raise = true}) - - -- Without this, the following - -- :isvisible() makes no sense - c.minimized = false - if not c:isvisible() and c.first_tag then - c.first_tag:view_only() - end - -- This will also un-minimize - -- the client, if needed - client.focus = c - c:raise() - end - end), - awful.button({ }, 2, function (c) c:kill() end), - awful.button({ }, 3, function () - local instance = nil - - return function () - if instance and instance.wibox.visible then - instance:hide() - instance = nil - else - instance = awful.menu.clients({theme = {width = dpi(250)}}) - end - end - end), - awful.button({ }, 4, function () awful.client.focus.byidx(1) end), - awful.button({ }, 5, function () awful.client.focus.byidx(-1) end) -) - lain.layout.termfair.nmaster = 3 lain.layout.termfair.ncol = 1 lain.layout.termfair.center.nmaster = 3 lain.layout.termfair.center.ncol = 1 -lain.layout.cascade.tile.offset_x = dpi(2) -lain.layout.cascade.tile.offset_y = dpi(32) -lain.layout.cascade.tile.extra_padding = dpi(5) +lain.layout.cascade.tile.offset_x = 2 +lain.layout.cascade.tile.offset_y = 32 +lain.layout.cascade.tile.extra_padding = 5 lain.layout.cascade.tile.nmaster = 5 lain.layout.cascade.tile.ncol = 2 +awful.util.taglist_buttons = mytable.join( + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then client.focus:move_to_tag(t) end + end), + awful.button({ }, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then client.focus:toggle_tag(t) end + end), + awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) +) + +awful.util.tasklist_buttons = mytable.join( + awful.button({ }, 1, function(c) + if c == client.focus then + c.minimized = true + else + c:emit_signal("request::activate", "tasklist", { raise = true }) + end + end), + awful.button({ }, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({ }, 4, function() awful.client.focus.byidx(1) end), + awful.button({ }, 5, function() awful.client.focus.byidx(-1) end) +) + beautiful.init(string.format("%s/.config/awesome/themes/%s/theme.lua", os.getenv("HOME"), chosen_theme)) + -- }}} -- {{{ Menu + +-- Create a launcher widget and a main menu local myawesomemenu = { - { "hotkeys", function() return false, hotkeys_popup.show_help end }, - { "manual", terminal .. " -e man awesome" }, - { "edit config", string.format("%s -e %s %s", terminal, editor, awesome.conffile) }, - { "restart", awesome.restart }, - { "quit", function() awesome.quit() end } + { "Hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "Manual", string.format("%s -e man awesome", terminal) }, + { "Edit config", string.format("%s -e %s %s", terminal, editor, awesome.conffile) }, + { "Restart", awesome.restart }, + { "Quit", function() awesome.quit() end }, } -awful.util.mymainmenu = freedesktop.menu.build({ - icon_size = beautiful.menu_height or dpi(16), + +local mymainmenu = freedesktop.menu.build { before = { { "Awesome", myawesomemenu, beautiful.awesome_icon }, -- other triads can be put here @@ -208,14 +195,21 @@ awful.util.mymainmenu = freedesktop.menu.build({ { "Open terminal", terminal }, -- other triads can be put here } -}) --- hide menu when mouse leaves it ---awful.util.mymainmenu.wibox:connect_signal("mouse::leave", function() awful.util.mymainmenu:hide() end) +} + +-- hide menu when mouse leaves it +--mymainmenu.wibox:connect_signal("mouse::leave", function() mymainmenu:hide() end) + +-- Set the Menubar terminal for applications that require it +--menubar.utils.terminal = terminal ---menubar.utils.terminal = terminal -- Set the Menubar terminal for applications that require it -- }}} +-- Keyboard map indicator and switcher +mykeyboardlayout = awful.widget.keyboardlayout() + -- {{{ Screen + -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) screen.connect_signal("property::geometry", function(s) -- Wallpaper @@ -240,20 +234,25 @@ screen.connect_signal("arrange", function (s) end end end) + -- Create a wibox for each screen and add it awful.screen.connect_for_each_screen(function(s) beautiful.at_screen_connect(s) end) + -- }}} -- {{{ Mouse bindings -root.buttons(my_table.join( - awful.button({ }, 3, function () awful.util.mymainmenu:toggle() end), + +root.buttons(mytable.join( + awful.button({ }, 3, function () mymainmenu:toggle() end), awful.button({ }, 4, awful.tag.viewnext), awful.button({ }, 5, awful.tag.viewprev) )) + -- }}} -- {{{ Key bindings -globalkeys = my_table.join( + +globalkeys = mytable.join( -- Take a screenshot -- https://github.com/lcpz/dots/blob/master/bin/screenshot awful.key({ altkey }, "p", function() os.execute("screenshot") end, @@ -263,9 +262,10 @@ globalkeys = my_table.join( awful.key({ altkey, "Control" }, "l", function () os.execute(scrlocker) end, {description = "lock screen", group = "hotkeys"}), - -- Hotkeys + -- Show help awful.key({ modkey, }, "s", hotkeys_popup.show_help, - {description = "show help", group="awesome"}), + {description="show help", group="awesome"}), + -- Tag browsing awful.key({ modkey, }, "Left", awful.tag.viewprev, {description = "view previous", group = "tag"}), @@ -294,7 +294,7 @@ globalkeys = my_table.join( {description = "focus previous by index", group = "client"} ), - -- By direction client focus + -- By-direction client focus awful.key({ modkey }, "j", function() awful.client.focus.global_bydirection("down") @@ -319,7 +319,9 @@ globalkeys = my_table.join( if client.focus then client.focus:raise() end end, {description = "focus right", group = "client"}), - awful.key({ modkey, }, "w", function () awful.util.mymainmenu:show() end, + + -- Menu + awful.key({ modkey, }, "w", function () mymainmenu:show() end, {description = "show main menu", group = "awesome"}), -- Layout manipulation @@ -345,18 +347,8 @@ globalkeys = my_table.join( end end, {description = "cycle with previous/go back", group = "client"}), - awful.key({ modkey, "Shift" }, "Tab", - function () - if cycle_prev then - awful.client.focus.byidx(1) - if client.focus then - client.focus:raise() - end - end - end, - {description = "go forth", group = "client"}), - -- Show/Hide Wibox + -- Show/hide wibox awful.key({ modkey }, "b", function () for s in screen do s.mywibox.visible = not s.mywibox.visible @@ -367,7 +359,7 @@ globalkeys = my_table.join( end, {description = "toggle wibox", group = "awesome"}), - -- On the fly useless gaps change + -- On-the-fly useless gaps change awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end, {description = "increment useless gaps", group = "tag"}), awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end, @@ -393,9 +385,9 @@ globalkeys = my_table.join( awful.key({ modkey, "Shift" }, "q", awesome.quit, {description = "quit awesome", group = "awesome"}), - awful.key({ altkey, "Shift" }, "l", function () awful.tag.incmwfact( 0.05) end, + awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, {description = "increase master width factor", group = "layout"}), - awful.key({ altkey, "Shift" }, "h", function () awful.tag.incmwfact(-0.05) end, + awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, {description = "decrease master width factor", group = "layout"}), awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, {description = "increase the number of master clients", group = "layout"}), @@ -410,16 +402,13 @@ globalkeys = my_table.join( awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, {description = "select previous", group = "layout"}), - awful.key({ modkey, "Control" }, "n", - function () - local c = awful.client.restore() - -- Focus restored client - if c then - client.focus = c - c:raise() - end - end, - {description = "restore minimized", group = "client"}), + awful.key({ modkey, "Control" }, "n", function () + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal("request::activate", "key.unminimize", {raise = true}) + end + end, {description = "restore minimized", group = "client"}), -- Dropdown application awful.key({ modkey, }, "z", function () awful.screen.focused().quake:toggle() end, @@ -433,7 +422,7 @@ globalkeys = my_table.join( awful.key({ altkey, }, "w", function () if beautiful.weather then beautiful.weather.show(7) end end, {description = "show weather", group = "widgets"}), - -- Brightness + -- Screen brightness awful.key({ }, "XF86MonBrightnessUp", function () os.execute("xbacklight -inc 10") end, {description = "+10%", group = "hotkeys"}), awful.key({ }, "XF86MonBrightnessDown", function () os.execute("xbacklight -dec 10") end, @@ -561,7 +550,7 @@ globalkeys = my_table.join( --]] ) -clientkeys = my_table.join( +clientkeys = mytable.join( awful.key({ altkey, "Shift" }, "m", lain.util.magnify_client, {description = "magnify client", group = "client"}), awful.key({ modkey, }, "f", @@ -592,22 +581,26 @@ clientkeys = my_table.join( c.maximized = not c.maximized c:raise() end , - {description = "maximize", group = "client"}) + {description = "(un)maximize", group = "client"}), + awful.key({ modkey, "Control" }, "m", + function (c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end , + {description = "(un)maximize vertically", group = "client"}), + awful.key({ modkey, "Shift" }, "m", + function (c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end , + {description = "(un)maximize horizontally", group = "client"}) ) -- Bind all key numbers to tags. --- Be careful: we use keycodes to make it works on any keyboard layout. +-- Be careful: we use keycodes to make it work on any keyboard layout. -- This should map on the top row of your keyboard, usually 1 to 9. for i = 1, 9 do - -- Hack to only show tags 1 and 9 in the shortcut window (mod+s) - local descr_view, descr_toggle, descr_move, descr_toggle_focus - if i == 1 or i == 9 then - descr_view = {description = "view tag #", group = "tag"} - descr_toggle = {description = "toggle tag #", group = "tag"} - descr_move = {description = "move focused client to tag #", group = "tag"} - descr_toggle_focus = {description = "toggle focused client on tag #", group = "tag"} - end - globalkeys = my_table.join(globalkeys, + globalkeys = mytable.join(globalkeys, -- View tag only. awful.key({ modkey }, "#" .. i + 9, function () @@ -617,7 +610,7 @@ for i = 1, 9 do tag:view_only() end end, - descr_view), + {description = "view tag #"..i, group = "tag"}), -- Toggle tag display. awful.key({ modkey, "Control" }, "#" .. i + 9, function () @@ -627,7 +620,7 @@ for i = 1, 9 do awful.tag.viewtoggle(tag) end end, - descr_toggle), + {description = "toggle tag #" .. i, group = "tag"}), -- Move client to tag. awful.key({ modkey, "Shift" }, "#" .. i + 9, function () @@ -638,7 +631,7 @@ for i = 1, 9 do end end end, - descr_move), + {description = "move focused client to tag #"..i, group = "tag"}), -- Toggle tag on focused client. awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, function () @@ -649,11 +642,11 @@ for i = 1, 9 do end end end, - descr_toggle_focus) + {description = "toggle focused client on tag #" .. i, group = "tag"}) ) end -clientbuttons = gears.table.join( +clientbuttons = mytable.join( awful.button({ }, 1, function (c) c:emit_signal("request::activate", "mouse_click", {raise = true}) end), @@ -669,9 +662,11 @@ clientbuttons = gears.table.join( -- Set keys root.keys(globalkeys) + -- }}} -- {{{ Rules + -- Rules to apply to new clients (through the "manage" signal). awful.rules.rules = { -- All clients will match this rule. @@ -688,28 +683,59 @@ awful.rules.rules = { } }, - -- Titlebars - { rule_any = { type = { "dialog", "normal" } }, - properties = { titlebars_enabled = true } }, + -- Floating clients. + { rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer"}, - -- Set Firefox to always map on the first tag on screen 1. - { rule = { class = "Firefox" }, - properties = { screen = 1, tag = awful.util.tagnames[1] } }, + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + } + }, properties = { floating = true }}, - { rule = { class = "Gimp", role = "gimp-image-window" }, - properties = { maximized = true } }, + -- Add titlebars to normal clients and dialogs + { rule_any = {type = { "normal", "dialog" } + }, properties = { titlebars_enabled = true } + }, + + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, } + -- }}} -- {{{ Signals + -- Signal function to execute when a new client appears. client.connect_signal("manage", function (c) -- Set the windows at the slave, -- i.e. put it at the end of others instead of setting it master. -- if not awesome.startup then awful.client.setslave(c) end - if awesome.startup and - not c.size_hints.user_position + if awesome.startup + and not c.size_hints.user_position and not c.size_hints.program_position then -- Prevent clients from being unreachable after screen count changes. awful.placement.no_offscreen(c) @@ -726,19 +752,18 @@ client.connect_signal("request::titlebars", function(c) -- Default -- buttons for the titlebar - local buttons = my_table.join( + local buttons = mytable.join( awful.button({ }, 1, function() c:emit_signal("request::activate", "titlebar", {raise = true}) awful.mouse.client.move(c) end), - awful.button({ }, 2, function() c:kill() end), awful.button({ }, 3, function() c:emit_signal("request::activate", "titlebar", {raise = true}) awful.mouse.client.resize(c) end) ) - awful.titlebar(c, {size = dpi(16)}) : setup { + awful.titlebar(c, { size = 16 }) : setup { { -- Left awful.titlebar.widget.iconwidget(c), buttons = buttons, @@ -772,6 +797,4 @@ end) client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) --- possible workaround for tag preservation when switching back to default screen: --- https://github.com/lcpz/awesome-copycats/issues/251 -- }}}