From 8543dd1a3cd1208786b43365f24f1e8624f9e08b Mon Sep 17 00:00:00 2001 From: Momin Barlas Date: Tue, 9 May 2023 17:51:49 -0400 Subject: [PATCH] Added new funtionality to flash_focus - flash_focus now accepts a table so that each window can have its own ending opacity --- module/flash_focus.lua | 40 +++++++++++++++++++++++++++++++++------- theme-var-template.lua | 3 ++- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/module/flash_focus.lua b/module/flash_focus.lua index 35f3cf01..5e495a1d 100644 --- a/module/flash_focus.lua +++ b/module/flash_focus.lua @@ -2,10 +2,26 @@ local gears = require("gears") local beautiful = require("beautiful") local op = beautiful.flash_focus_start_opacity or 0.6 -local stp = beautiful.flash_focus_step or 0.01 +local stp = beautiful.flash_focus_step or 0.02 +local transparency_rules = beautiful.flash_focus_transparency_rules or {} + +local function search_rules(c) + local found = false + local num = 0 + for _, v in pairs(transparency_rules) do + if string.match(v, c.class) or string.match(v, c.name) or string.match(v, c.type) then + found = true + num = v:match("%d+") + break + end + end + return found, num +end + local flashfocus = function(c) if c and #c.screen.clients > 1 then + local found, num = search_rules(c) c.opacity = op local q = op local g = gears.timer({ @@ -18,12 +34,22 @@ local flashfocus = function(c) if not c.valid then return end - if q >= 1 then - c.opacity = 1 - g:stop() + if found then + if q >= (tonumber(num)/100) then + c.opacity = (tonumber(num)/100) + g:stop() + else + c.opacity = q + q = q + stp + end else - c.opacity = q - q = q + stp + if q >= 1 then + c.opacity = 1 + g:stop() + else + c.opacity = q + q = q + stp + end end end) end @@ -36,4 +62,4 @@ local disable = function() client.disconnect_signal("focus", flashfocus) end -return { enable = enable, disable = disable, flashfocus = flashfocus } +return { enable = enable, disable = disable, flashfocus = flashfocus } \ No newline at end of file diff --git a/theme-var-template.lua b/theme-var-template.lua index 13d0f5ab..efc31597 100644 --- a/theme-var-template.lua +++ b/theme-var-template.lua @@ -13,6 +13,7 @@ theme.dont_swallow_filter_activated = true -- whether the filter above should be -- flash focus theme.flash_focus_start_opacity = 0.6 -- the starting opacity theme.flash_focus_step = 0.01 -- the step of animation +theme.flash_focus_transparency_rules = {"Code:70", "Alacrity:80"} -- a list of opacity rules for flash focus to use -- playerctl signal theme.playerctl_backend = "playerctl_cli" -- backend to use @@ -102,4 +103,4 @@ theme.window_switcher_name_focus_color = "#ff0000" -- The color of one title if theme.window_switcher_icon_valign = "center" -- How to vertically align the one icon theme.window_switcher_icon_width = 40 -- The width of one icon --- LuaFormatter on +-- LuaFormatter on \ No newline at end of file