Skip to content
This repository was archived by the owner on Dec 18, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions module/flash_focus.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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 }
3 changes: 2 additions & 1 deletion theme-var-template.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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