awesome/my.lua
changeset 8 0eae48be1d62
parent 7 03125e413ae3
child 9 56e80afa3e1c
equal deleted inserted replaced
7:03125e413ae3 8:0eae48be1d62
     2 require("awful")
     2 require("awful")
     3 require("debug")
     3 require("debug")
     4 require("vicious")
     4 require("vicious")
     5 require("wicked")
     5 require("wicked")
     6 require("beautiful")
     6 require("beautiful")
       
     7 require("timer")
     7 
     8 
     8 local ipairs = ipairs
     9 local ipairs = ipairs
     9 local pairs = pairs
    10 local pairs = pairs
    10 local naughty = naughty
    11 local naughty = naughty
    11 local awful = awful
    12 local awful = awful
    12 local debug = debug
    13 local debug = debug
    13 local vicious = vicious
    14 local vicious = vicious
    14 local wicked = wicked
    15 local wicked = wicked
    15 local beautiful = beautiful
    16 local beautiful = beautiful
       
    17 local timer = timer
    16 
    18 
    17 local capi = {
    19 local capi = {
    18    keygrabber = keygrabber,
    20    keygrabber = keygrabber,
    19    client = client,
    21    client = client,
    20    string = string,
    22    string = string,
   169 local keynames = {
   171 local keynames = {
   170    [" "] = "space",
   172    [" "] = "space",
   171    ["\t"] = "tab",
   173    ["\t"] = "tab",
   172 }
   174 }
   173 
   175 
       
   176 local ignored_mods = {
       
   177    ["Mod2"] = true,
       
   178 }
       
   179 
   174 local function translate_key(mod, key)
   180 local function translate_key(mod, key)
   175    local skey = ""
   181    local skey = ""
   176    for m,v in pairs(mod) do
   182    for m,v in pairs(mod) do
   177       if v then 
   183       if not ignored_mods[v] then 
   178          skey = skey .. v .. "+"
   184          skey = skey .. v .. "+"
   179       end
   185       end
   180    end
   186    end
   181    skey = skey .. (keynames[key] or key)
   187    skey = skey .. (keynames[key] or key)
   182    return skey
   188    return skey
   262       t = awful.util.table.join(t, awful.key(modifiers, k.key, k.func))
   268       t = awful.util.table.join(t, awful.key(modifiers, k.key, k.func))
   263    end
   269    end
   264    return t
   270    return t
   265 end
   271 end
   266 
   272 
       
   273 -- Install a sloppy-like focus with a timeout.
       
   274 
       
   275 function sloppy_toggle()
       
   276    sloppy = not sloppy
       
   277 end
       
   278 
       
   279 function sloppy_mouse_enter(c)
       
   280    if sloppy and
       
   281       c ~= sloppy_last_client and
       
   282       awful.client.focus.filter(c) and
       
   283       awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
       
   284    then
       
   285       sloppy_timer:again()
       
   286       sloppy_last_client = c
       
   287    end
       
   288 end
       
   289 
       
   290 function sloppy_on_timeout()
       
   291    if sloppy
       
   292    then
       
   293       local c = awful.mouse.client_under_pointer()
       
   294       if c and
       
   295          c == sloppy_last_client
       
   296       then
       
   297          capi.client.focus = c
       
   298       end
       
   299     end
       
   300 end
       
   301 
       
   302 sloppy = true
       
   303 sloppy_last_client = nil
       
   304 sloppy_timer = nil
       
   305 
       
   306 function sloppy_install(delay)
       
   307    sloppy_timer = timer({ timeout = delay })
       
   308    sloppy_timer:add_signal("timeout", sloppy_on_timeout)
       
   309    sloppy_timer:start()
       
   310    capi.client.add_signal("manage", function (c)
       
   311                              c:add_signal("mouse::enter", sloppy_mouse_enter)
       
   312    end)
       
   313 end