From 338c73f1a1d6b4b48df9eef560e2b530e67e2349 Mon Sep 17 00:00:00 2001 From: Ein Verne Date: Fri, 23 Oct 2020 19:04:57 +0800 Subject: [PATCH] Hammerspoon: autoscript --- hammerspoon/Spoons/BingDaily.spoon/init.lua | 2 +- .../Spoons/WinRectangle.spoon/init.lua | 2 +- hammerspoon/autoscript.lua | 24 +++++-------------- hammerspoon/init.lua | 4 +--- skhd/skhdrc | 2 +- yabai/yabairc | 3 ++- 6 files changed, 12 insertions(+), 25 deletions(-) diff --git a/hammerspoon/Spoons/BingDaily.spoon/init.lua b/hammerspoon/Spoons/BingDaily.spoon/init.lua index 096e88f..bc328a1 100644 --- a/hammerspoon/Spoons/BingDaily.spoon/init.lua +++ b/hammerspoon/Spoons/BingDaily.spoon/init.lua @@ -3,7 +3,7 @@ --- Use Bing daily picture as your wallpaper, automatically. --- --- Download: [https://github.com/Hammerspoon/Spoons/raw/master/Spoons/BingDaily.spoon.zip](https://github.com/Hammerspoon/Spoons/raw/master/Spoons/BingDaily.spoon.zip) -log = hs.logger.new('BingDaily', 'debug') +local log = hs.logger.new('BingDaily', 'debug') local obj={} obj.__index = obj diff --git a/hammerspoon/Spoons/WinRectangle.spoon/init.lua b/hammerspoon/Spoons/WinRectangle.spoon/init.lua index 4b3c253..798cb28 100644 --- a/hammerspoon/Spoons/WinRectangle.spoon/init.lua +++ b/hammerspoon/Spoons/WinRectangle.spoon/init.lua @@ -19,7 +19,7 @@ obj.license = "MIT - https://opensource.org/licenses/MIT" --- Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon. obj.logger = hs.logger.new('WinRectangle') -log = hs.logger.new('WinRectangle', 'debug') +local log = hs.logger.new('WinRectangle', 'debug') obj.grid = 50 diff --git a/hammerspoon/autoscript.lua b/hammerspoon/autoscript.lua index dbf8468..b58c10d 100644 --- a/hammerspoon/autoscript.lua +++ b/hammerspoon/autoscript.lua @@ -1,27 +1,15 @@ log = hs.logger.new('autoscript', 'debug') -local cmdArr = { - "cd /Users/einverne/Sync/wiki/ && /bin/bash auto-push.sh", - "/usr/bin/rsync --remove-source-files -azvh ~/Downloads/*.torrent omv_proxy:/sharedfolders/pt/watch/ >> /tmp/rsync-bittorrent.log", -} -function shell(cmd) - hs.alert.show("execute") - log.i('execute') - output, status, t, rc = hs.execute(string.format("%s", cmd), true) - -- result, output, err = hs.osascript.applescript(string.format('do shell script "%s"', cmd)) - log.i(output) - log.i(status) - log.i(t) - log.i(rc) +function taskCallback(exitCode, stdOut, stdErr) + log.i("task call back ", exitCode, stdOut, stdErr) end function runAutoScripts() - for key, cmd in ipairs(cmdArr) do - log.i("execute" .. key .. " " .. cmd) - shell(cmd) - end + 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 d972f78..c700634 100644 --- a/hammerspoon/init.lua +++ b/hammerspoon/init.lua @@ -233,7 +233,6 @@ if not hspoon_list then --"CountDown", "HCalendar", --"HSaria2", - "SpeedMenu", "WinWin", "WifiNotifier", "WinRectangle", @@ -256,12 +255,11 @@ hs.hotkey.bind({}, "F12", function() else app:activate() end + app:mainWindow():moveToUnit'[100, 80, 0, 0]' else hs.application.launchOrFocus("kitty") app = hs.application.get("kitty") end - - app:mainWindow():moveToUnit'[100, 80, 0, 0]' end) ---------------------------------------------------------------------------------------------------- diff --git a/skhd/skhdrc b/skhd/skhdrc index c86442b..3789344 100644 --- a/skhd/skhdrc +++ b/skhd/skhdrc @@ -101,7 +101,7 @@ # 0x2F = Fullstop / > # 0x2C = Slash # open terminal -cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~ &> /dev/null +# cmd - return : /Applications/kitty.app/Contents/MacOS/kitty --single-instance -d ~ &> /dev/null # close focused window # alt - w : yabai -m window --close diff --git a/yabai/yabairc b/yabai/yabairc index 1e76b46..ca8b571 100755 --- a/yabai/yabairc +++ b/yabai/yabairc @@ -52,16 +52,17 @@ yabai -m rule --add label="Dictionary" app="^Dictionary$" manage=off yabai -m rule --add app="^Discord$" space=7 grid=1:1:0:0:1:1 manage=off yabai -m rule --add label="Finder" app="^Finder$" title="(Co(py|nnect)|Move|Info|Pref)" manage=off yabai -m rule --add label="GoldenDict" app="GoldenDict" manage=off +yabai -m rule --add label="KakaoTalk" app="KakaoTalk" manage=off yabai -m rule --add label="kitty" app="kitty" manage=off yabai -m rule --add label="IntelliJ IDEA" app="IntelliJ IDEA" manage=off space=code yabai -m rule --add label="Preview" app="Preview" manage=off yabai -m rule --add label="System Preferences" app="^System Preferences$" manage=off yabai -m rule --add label="SmartGit" app="SmartGit" manage=off space=git yabai -m rule --add label="VirtualBox" app="^VirtualBox$" manage=off +yabai -m rule --add label="WeChat" app="^WeChat$" manage=off yabai -m rule --add label="Zotero" app="^Zotero$" manage=off - # signals # focus mouse hovered window when a window is closed, minimized or terminated yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"