bling/module/flash_focus.lua

45 lines
1.0 KiB
Lua
Raw Normal View History

2020-10-28 23:23:47 +01:00
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 flashfocus = function(c)
if c then
c.opacity = op
local q = op
2021-08-27 20:01:22 +02:00
local g = gears.timer({
2020-10-28 23:23:47 +01:00
timeout = stp,
call_now = false,
2021-08-27 20:01:22 +02:00
autostart = true,
})
2020-10-28 23:23:47 +01:00
g:connect_signal("timeout", function()
2021-08-27 20:01:22 +02:00
if not c.valid then
return
end
2020-10-28 23:23:47 +01:00
if q >= 1 then
c.opacity = 1
g:stop()
else
c.opacity = q
q = q + stp
end
end)
end
2021-02-04 02:50:18 +01:00
-- Bring the focused client to the top
2021-08-27 20:01:22 +02:00
if c then
c:raise()
end
2020-10-28 23:23:47 +01:00
end
2021-08-27 20:01:22 +02:00
local enable = function()
client.connect_signal("focus", flashfocus)
end
local disable = function()
client.disconnect_signal("focus", flashfocus)
end
2020-10-28 23:23:47 +01:00
2021-08-27 20:01:22 +02:00
return { enable = enable, disable = disable, flashfocus = flashfocus }