From e295d9bc136599af7f6efd18f55a8a9274669edf Mon Sep 17 00:00:00 2001 From: Ein Verne Date: Sun, 10 Oct 2021 13:53:24 +0800 Subject: [PATCH] Update hammerspoon --- hammerspoon/autoscript.lua | 30 +++++++++++++++--------------- hammerspoon/init.lua | 20 +++++++++++++------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/hammerspoon/autoscript.lua b/hammerspoon/autoscript.lua index b58c10d..0476406 100644 --- a/hammerspoon/autoscript.lua +++ b/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() diff --git a/hammerspoon/init.lua b/hammerspoon/init.lua index 537356a..aca2b1c 100644 --- a/hammerspoon/init.lua +++ b/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()