I'm trying to refine the code. Any idea why neither of these two (jumpto or history.previous) work?

Thanks.

local snapback_window = nil
client.connect_signal("unfocus",
              function(c)
             if snapback_window == nil then
                snapback_window = c
             end
            
             if snapback_window.window == c.window then
                naughty.notify({ preset = naughty.config.presets.normal,
                         text = "unfocus " .. c.name .. "::" .. c.window .. " but locked on " .. snapback_window.name})
                -- awful.client.jumpto(snapback_window,true)
                awful.client.focus.history.previous()
             end
              end)
 
Gesendet: Samstag, 24. August 2013 um 17:58 Uhr
Von: "Kasimir Knallkopf" <[email protected]>
An: awesome <[email protected]>
Betreff: snapback, first try
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.

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 })
mytimer:connect_signal("timeout", function ()
              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)
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)
 
-- To unsubscribe, send mail to [email protected].
-- To unsubscribe, send mail to [email protected].

Reply via email to