From b8fbeb95c648a5c9ac9b24db520d97015f98761c Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 6 Oct 2019 19:03:47 -0400 Subject: [PATCH] rc.lua: Switch from `awful.rules` to `ruled.client`. It's the same module, but with a new name. The commit also switches from the "one off" rule write to the incremental and signal based one. This allows modules to add their own rules without having a race condition against `rc.lua` and other modules. Previously, if a module wasn't designed to prevent it, rules got destroyed each time. --- awesomerc.lua | 88 ++++++++++++++++++++++++++------------------------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/awesomerc.lua b/awesomerc.lua index 578a9a37f..65e48b4d6 100644 --- a/awesomerc.lua +++ b/awesomerc.lua @@ -13,6 +13,8 @@ local wibox = require("wibox") local beautiful = require("beautiful") -- Notification library local naughty = require("naughty") +-- Declarative object management +local ruled = require("ruled") local menubar = require("menubar") local hotkeys_popup = require("awful.hotkeys_popup") -- Enable hotkeys help widget for VIM and other apps @@ -439,60 +441,60 @@ end) -- {{{ Rules -- Rules to apply to new clients. -- @DOC_RULES@ -awful.rules.rules = { +ruled.client.connect_signal("request::rules", function() -- @DOC_GLOBAL_RULE@ -- All clients will match this rule. - { rule = { }, - properties = { focus = awful.client.focus.filter, - raise = true, - screen = awful.screen.preferred, - placement = awful.placement.no_overlap+awful.placement.no_offscreen - } - }, + ruled.client.append_rule { + id = "global", + rule = { }, + properties = { + focus = awful.client.focus.filter, + raise = true, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap+awful.placement.no_offscreen + } + } -- @DOC_FLOATING_RULE@ -- Floating clients. - { rule_any = { - instance = { - "DTA", -- Firefox addon DownThemAll. - "copyq", -- Includes session name in class. - "pinentry", + ruled.client.append_rule { + id = "floating", + rule_any = { + instance = { "copyq", "pinentry" }, + class = { + "Arandr", "Blueman-manager", "Gpick", "Kruler", "Sxiv", + "Tor Browser", "Wpa_gui", "veromix", "xtightvncviewer" + }, + -- 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. + } }, - 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"}, - - -- 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 }}, + properties = { floating = true } + } -- @DOC_DIALOG_RULE@ -- Add titlebars to normal clients and dialogs - { rule_any = {type = { "normal", "dialog" } - -- @DOC_CSD_TITLEBARS@ - }, properties = { titlebars_enabled = true } - }, + ruled.client.append_rule { + -- @DOC_CSD_TITLEBARS@ + id = "titlebars", + 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" } }, -} + -- ruled.tag.append_rule { + -- rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } + -- } +end) + -- }}} -- {{{ Titlebars