mirror of
https://github.com/vincentbernat/i3wm-configuration.git
synced 2025-06-30 13:24:21 +02:00
bindings: try to be smarter with Mod+u to choose Pidgin window
We try to handle the case where we have several Pidgin conversation windows. Not perfect since it is not possible to remove them all.
This commit is contained in:
parent
9de7485159
commit
8bce8a5528
1 changed files with 28 additions and 4 deletions
|
@ -81,10 +81,34 @@ end
|
||||||
-- Toggle pidgin conversation window
|
-- Toggle pidgin conversation window
|
||||||
local toggle_pidgin = toggle_window(
|
local toggle_pidgin = toggle_window(
|
||||||
function ()
|
function ()
|
||||||
return awful.client.cycle(function(c)
|
local cls = client.get()
|
||||||
return awful.rules.match(c, { class = "Pidgin",
|
local focus = client.focus
|
||||||
role = "conversation" })
|
local rule = { class = "Pidgin",
|
||||||
end)()
|
role = "conversation" }
|
||||||
|
-- Score. We want a Pidgin window. Then:
|
||||||
|
-- 1. Urgent, visible, not focused
|
||||||
|
-- 2. Urgent, not visible, not focused.
|
||||||
|
-- 3. Not urgent, not visible, not focused
|
||||||
|
-- 4. Focused
|
||||||
|
-- 5. Visible, not focused
|
||||||
|
local function score(cl)
|
||||||
|
if not awful.rules.match(cl, rule) then return -10 end
|
||||||
|
|
||||||
|
local urgent = cl.urgent
|
||||||
|
local focused = (focus == cl)
|
||||||
|
local visible = cl:isvisible()
|
||||||
|
if urgent and visible and not focused then return 100 end
|
||||||
|
if urgent and not visible and not focused then return 90 end
|
||||||
|
if not urgent and not visible then return 80 end
|
||||||
|
if focused then return 50 end
|
||||||
|
return 10
|
||||||
|
end
|
||||||
|
table.sort(cls, function(c1, c2)
|
||||||
|
local s1 = score(c1)
|
||||||
|
local s2 = score(c2)
|
||||||
|
return s1 > s2
|
||||||
|
end)
|
||||||
|
if awful.rules.match(cls[1], rule) then return cls[1] end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Toggle urgent window
|
-- Toggle urgent window
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue