Hello,
This is my first try to implement the snapback function that prevents switching tags for a given time (and thus should help one to focus on a task). Naturally there still ways around it, and there always will be ways around it.
This is my first try to implement the snapback function that prevents switching tags for a given time (and thus should help one to focus on a task). Naturally there still ways around it, and there always will be ways around it.
There are also for sure bugs lurking in there. For example when multiple tags are selected. Since this is my first lua snippet, maybe a more experienced person here can help out with concrete suggestions how to clean up the code or improve it.
Thanks.
local snapback = true
local snapback_tag = awful.tag.selected()
local mytimer = timer({ timeout = 600 })
local snapback_tag = awful.tag.selected()
local mytimer = timer({ timeout = 600 })
mytimer:connect_signal("timeout", function ()
snapback = false
naughty.notify({ preset = naughty.config.presets.low,
text = "Snapback timeout!"})
mytimer:stop()
end)
snapback = false
naughty.notify({ preset = naughty.config.presets.low,
text = "Snapback timeout!"})
mytimer:stop()
end)
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "]",
function ()
snapback = true
naughty.notify({ preset = naughty.config.presets.normal,
title = "Snapback locked on " .. awful.tag.selected().name})
snapback_tag = awful.tag.selected()
mytimer:start()
end),
-- if the force is weak with you, then comment this key
awful.key({ modkey, "Shift" }, "]",
function ()
snapback = false
naughty.notify({ preset = naughty.config.presets.low,
text = "Snapback manually unlocked!"})
end)
)
root.keys(globalkeys)
end),
-- if the force is weak with you, then comment this key
awful.key({ modkey, "Shift" }, "]",
function ()
snapback = false
naughty.notify({ preset = naughty.config.presets.low,
text = "Snapback manually unlocked!"})
end)
)
root.keys(globalkeys)
tag.connect_signal("property::selected", function(c)
if c.selected and snapback and snapback_tag ~= c then
naughty.notify({ preset = naughty.config.presets.normal,
text = "Thou shall stick to tag ".. "'" .. snapback_tag.name .. "'!"})
awful.tag.viewonly(snapback_tag)
end
end)
if c.selected and snapback and snapback_tag ~= c then
naughty.notify({ preset = naughty.config.presets.normal,
text = "Thou shall stick to tag ".. "'" .. snapback_tag.name .. "'!"})
awful.tag.viewonly(snapback_tag)
end
end)