half-baked re-implementation of the major parts of sdorfehs in Hammerspoon

events: Add spoonfish.apps_to_ignore to negate apps_to_watch

This makes having a default policy of watching everything easier.

+21 -3
+18 -3
events.lua
··· 60 61 local matched = false 62 for _, p in pairs(spoonfish.apps_to_watch) do 63 if not p:find("^%^") then 64 p = spoonfish.escape_pattern(p) 65 end ··· 67 matched = true 68 break 69 end 70 - if matched then 71 break 72 end 73 end 74 if not matched then 75 return 76 end 77 ··· 98 99 -- watch a hs.window object to be notified when it is closed or moved 100 spoonfish.watch_hswindow = function(hswin) 101 - if not hswin:isStandard() then 102 - spoonfish.log.i(" ignoring non-standard window " .. hswin:title()) 103 return 104 end 105
··· 60 61 local matched = false 62 for _, p in pairs(spoonfish.apps_to_watch) do 63 + if p == "" then 64 + matched = true 65 + break 66 + end 67 if not p:find("^%^") then 68 p = spoonfish.escape_pattern(p) 69 end ··· 71 matched = true 72 break 73 end 74 + end 75 + for _, p in pairs(spoonfish.apps_to_ignore) do 76 + if p == "" then 77 + matched = false 78 + break 79 + end 80 + if not p:find("^%^") then 81 + p = spoonfish.escape_pattern(p) 82 + end 83 + if hsapp:title():find(p) then 84 + matched = false 85 break 86 end 87 end 88 if not matched then 89 + spoonfish.log.i("ignoring app[" .. hsapp:pid() .. "] " .. hsapp:title() .. 90 + " (" .. hsapp:name() .. ")") 91 return 92 end 93 ··· 114 115 -- watch a hs.window object to be notified when it is closed or moved 116 spoonfish.watch_hswindow = function(hswin) 117 + if hswin == nil or not hswin:isStandard() then 118 return 119 end 120
+3
init.lua
··· 38 "^" .. spoonfish.terminal, 39 "^Firefox", 40 } 41 spoonfish.windows_to_ignore = { 42 "Picture-in-Picture", 43 "^Open ",
··· 38 "^" .. spoonfish.terminal, 39 "^Firefox", 40 } 41 + -- these override apps_to_watch 42 + spoonfish.apps_to_ignore = { 43 + } 44 spoonfish.windows_to_ignore = { 45 "Picture-in-Picture", 46 "^Open ",