From b848f94c8fc70d1a89417e9ea8e5b2ae8a656822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sun, 21 May 2023 00:35:23 +0200 Subject: [PATCH] Awesome fixes --- awesome/keys.lua | 12 ++++----- awesome/rc.lua | 50 ++++++++++++++++++++++++----------- awesome/widgets/task-list.lua | 6 +++-- 3 files changed, 45 insertions(+), 23 deletions(-) diff --git a/awesome/keys.lua b/awesome/keys.lua index bd58dc2..c5df12f 100644 --- a/awesome/keys.lua +++ b/awesome/keys.lua @@ -202,10 +202,10 @@ keys.globalkeys = gears.table.join( -- Brightness awful.key({ }, "XF86MonBrightnessDown", function () - awful.util.spawn("xbacklight -dec 15") end), + awful.spawn("xbacklight -dec 15") end), awful.key({ }, "XF86MonBrightnessUp", function () - awful.util.spawn("xbacklight -inc 15") end), + awful.spawn("xbacklight -inc 15") end), -- ALSA volume control awful.key({}, "XF86AudioRaiseVolume", @@ -266,7 +266,7 @@ keys.globalkeys = gears.table.join( -- Screenshot on prtscn using scrot awful.key({}, "Print", function() - awful.util.spawn(apps.screenshot, false) + awful.spawn(apps.screenshot, false) end ), @@ -284,7 +284,7 @@ keys.globalkeys = gears.table.join( awful.key({modkey}, "Escape", function() -- emit signal to show the exit screen - awful.util.spawn("rofi -show power-menu -modi power-menu:" .. os.getenv("XDG_CONFIG_HOME") .. "/awesome/scripts/rofi-power-menu") + awful.spawn("rofi -show power-menu -modi power-menu:" .. os.getenv("XDG_CONFIG_HOME") .. "/awesome/scripts/rofi-power-menu") end, {description = "toggle exit screen", group = "hotkeys"} ), @@ -292,14 +292,14 @@ keys.globalkeys = gears.table.join( awful.key({}, "XF86PowerOff", function() -- emit signal to show the exit screen - awful.util.spawn("rofi -show power-menu -modi power-menu:~/.config/awesome/scripts/rofi-power-menu") + awful.spawn("rofi -show power-menu -modi power-menu:~/.config/awesome/scripts/rofi-power-menu") end, {description = "toggle exit screen", group = "hotkeys"} ), awful.key({}, "XF86Calculator", function() - awful.util.spawn("rofi -show calc -modi calc -no-show-match -no-sort -calc-command \"echo -n '{result}' | xsel --clipboard\"") + awful.spawn("rofi -show calc -modi calc -no-show-match -no-sort -calc-command \"echo -n '{result}' | xsel --clipboard\"") end, {description = "Launch the calculator", group = "hotkeys"} ), diff --git a/awesome/rc.lua b/awesome/rc.lua index af957ec..683058c 100644 --- a/awesome/rc.lua +++ b/awesome/rc.lua @@ -79,21 +79,6 @@ awful.layout.layouts = { awful.layout.suit.tile.top, } --- Signal function to execute when a new client appears. -client.connect_signal("manage", function (c) - -- Set the window as a slave (put it at the end of others instead of setting it as master) - if not awesome.startup then - awful.client.setslave(c) - end - - 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) - end - gears.timer.delayed_call(function() awful.placement.centered(mouse, {parent=c}) end) -end) - - -- =================================================================== -- Client Focusing -- =================================================================== @@ -107,6 +92,27 @@ client.connect_signal("mouse::enter", function(c) c:emit_signal("request::activate", "mouse_enter", {raise = false}) end) + +-- Signal function to execute when a new client appears. +client.connect_signal("manage", function (c) + -- Set the window as a slave (put it at the end of others instead of setting it as master) + if not awesome.startup then + awful.client.setslave(c) + end + + 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) + end + + gears.timer.delayed_call(function() + local geometry = c:geometry() + local x = geometry.x + geometry.width/2 + local y = geometry.y + geometry.height/2 + mouse.coords({x = x, y = y}, true) + end) +end) + -- =================================================================== -- Screen Change Functions (ie multi monitor) -- =================================================================== @@ -134,6 +140,17 @@ require("awesomewm-vim-tmux-navigator") { experimental = true } +local function move_mouse_onto_focused_client() + local c = client.focus + if c then + local geometry = c:geometry() + local x = geometry.x + geometry.width/2 + local y = geometry.y + geometry.height/2 + mouse.coords({x = x, y = y}, true) + end +end + + client.connect_signal("property::maximized", function(focused) local hide = focused.maximized or focused.fullscreen for i, c in ipairs(client.get()) do @@ -162,3 +179,6 @@ end) client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) + +client.connect_signal("focus", move_mouse_onto_focused_client) +client.connect_signal("swapped", move_mouse_onto_focused_client) diff --git a/awesome/widgets/task-list.lua b/awesome/widgets/task-list.lua index ee0d698..53ba774 100644 --- a/awesome/widgets/task-list.lua +++ b/awesome/widgets/task-list.lua @@ -62,7 +62,9 @@ local function list_update(w, buttons, label, _, objects) local static_length = 16 * count local total_text_length = 0 for _, o in ipairs(objects) do - total_text_length = total_text_length + o.name:len() + if o.name then + total_text_length = total_text_length + o.name:len() + end end local truncate = (total_text_length + static_length) > 170 @@ -198,7 +200,7 @@ local filter = function(c, _) if t.selected then local ctags = c:tags() for _, v in ipairs(ctags) do - if v == t and c.screen == client.focus.screen then + if v == t and client.focus and c.screen == client.focus.screen then return true end end