Browse Source

Update hammerspoon

ubuntu_ci
Ein Verne 3 years ago
parent
commit
e295d9bc13
No known key found for this signature in database
GPG Key ID: 926634D64ACAD792
  1. 30
      hammerspoon/autoscript.lua
  2. 20
      hammerspoon/init.lua

30
hammerspoon/autoscript.lua

@ -1,15 +1,15 @@
log = hs.logger.new('autoscript', 'debug') -- log = hs.logger.new('autoscript', 'debug')
--
function taskCallback(exitCode, stdOut, stdErr) -- function taskCallback(exitCode, stdOut, stdErr)
log.i("task call back ", exitCode, stdOut, stdErr) -- log.i("task call back ", exitCode, stdOut, stdErr)
end -- end
--
function runAutoScripts() -- function runAutoScripts()
args = {"-c", "/Users/einverne/Sync/wiki/auto-push.sh"} -- args = {"-c", "/Users/einverne/Sync/wiki/auto-push.sh"}
autoCommitTask = hs.task.new("/bin/bash", taskCallback, args) -- autoCommitTask = hs.task.new("/bin/bash", taskCallback, args)
autoCommitTask:setWorkingDirectory("/Users/einverne/Sync/wiki/") -- autoCommitTask:setWorkingDirectory("/Users/einverne/Sync/wiki/")
autoCommitTask:start() -- autoCommitTask:start()
end -- end
--
myTimer = hs.timer.doEvery(7200, runAutoScripts) -- myTimer = hs.timer.doEvery(7200, runAutoScripts)
myTimer:start() -- myTimer:start()

20
hammerspoon/init.lua

@ -2,7 +2,7 @@ local LOGLEVEL = 'debug'
log = hs.logger.new('init', 'debug') log = hs.logger.new('init', 'debug')
require 'autoscript' -- require 'autoscript'
require 'ime' require 'ime'
-- require 'usb' -- require 'usb'
@ -105,7 +105,8 @@ local coding_layout = {
wifiWatcher = nil wifiWatcher = nil
homeSSID = "EinVerne_5G" homeSSID = "PhRouter_5G"
homeDDID1 = "EinVerne_5G"
lastSSID = hs.wifi.currentNetwork() lastSSID = hs.wifi.currentNetwork()
workSSID = "MIOffice-5G" workSSID = "MIOffice-5G"
@ -121,23 +122,27 @@ function ssidChangedCallback()
if newSSID == homeSSID and lastSSID ~= homeSSID then if newSSID == homeSSID and lastSSID ~= homeSSID then
-- We just joined our home WiFi network -- We just joined our home WiFi network
hs.alert.show("Welcome home!") -- hs.alert.show("Welcome home!")
hs.notify.new({title="Wifi", informativeText="Welcome home"}):send()
hs.audiodevice.defaultOutputDevice():setVolume(25) hs.audiodevice.defaultOutputDevice():setVolume(25)
-- result = hs.network.configuration:setLocation("Home") -- result = hs.network.configuration:setLocation("Home")
-- hs.alert.show(result) -- hs.alert.show(result)
elseif newSSID ~= homeSSID and lastSSID == homeSSID then elseif newSSID ~= homeSSID and lastSSID == homeSSID then
-- We just departed our home WiFi network -- We just departed our home WiFi network
hs.alert.show("left home!") -- hs.alert.show("left home!")
hs.notify.new({title="Wifi", informativeText="Left home"}):send()
hs.audiodevice.defaultOutputDevice():setVolume(0) hs.audiodevice.defaultOutputDevice():setVolume(0)
-- result = hs.network.configuration:setLocation("Automatic") -- result = hs.network.configuration:setLocation("Automatic")
-- hs.alert.show(result) -- hs.alert.show(result)
end end
if newSSID == workSSID then if newSSID == workSSID then
hs.alert.show("work karabiner setup") -- hs.alert.show("work karabiner setup")
hs.notify.new({title="Wifi", informativeText="work karabiner setup"}):send()
selectKarabinerProfile("goku") selectKarabinerProfile("goku")
else else
hs.alert.show("built-in karabiner setup") -- hs.alert.show("built-in karabiner setup")
hs.notify.new({title="Wifi", informativeText="built-in karabiner setup"}):send()
selectKarabinerProfile("goku") selectKarabinerProfile("goku")
end end
@ -173,7 +178,8 @@ hs.network.reachability.forAddress(homeDNS):setCallback(function(self, flags)
hs.alert.show("switch to Home network location") hs.alert.show("switch to Home network location")
networkConf:setLocation("Home") networkConf:setLocation("Home")
elseif (flags & hs.network.reachability.flags.reachable) == 0 and currentLocation ~= homeLocationUUID then elseif (flags & hs.network.reachability.flags.reachable) == 0 and currentLocation ~= homeLocationUUID then
hs.alert.show("switch back to Automatic network location") -- hs.alert.show("switch back to Automatic network location")
hs.notify.new({title="", informativeText="switch back to Automatic network location"}):send()
networkConf:setLocation("Automatic") networkConf:setLocation("Automatic")
end end
end):start() end):start()

Loading…
Cancel
Save