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

20
hammerspoon/init.lua

@ -2,7 +2,7 @@ local LOGLEVEL = 'debug'
log = hs.logger.new('init', 'debug')
require 'autoscript'
-- require 'autoscript'
require 'ime'
-- require 'usb'
@ -105,7 +105,8 @@ local coding_layout = {
wifiWatcher = nil
homeSSID = "EinVerne_5G"
homeSSID = "PhRouter_5G"
homeDDID1 = "EinVerne_5G"
lastSSID = hs.wifi.currentNetwork()
workSSID = "MIOffice-5G"
@ -121,23 +122,27 @@ function ssidChangedCallback()
if newSSID == homeSSID and lastSSID ~= homeSSID then
-- 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)
-- result = hs.network.configuration:setLocation("Home")
-- hs.alert.show(result)
elseif newSSID ~= homeSSID and lastSSID == homeSSID then
-- 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)
-- result = hs.network.configuration:setLocation("Automatic")
-- hs.alert.show(result)
end
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")
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")
end
@ -173,7 +178,8 @@ hs.network.reachability.forAddress(homeDNS):setCallback(function(self, flags)
hs.alert.show("switch to Home network location")
networkConf:setLocation("Home")
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")
end
end):start()

Loading…
Cancel
Save