Browse Source

Hammerspoon: autoscript

ubuntu_ci
Ein Verne 4 years ago
parent
commit
338c73f1a1
No known key found for this signature in database
GPG Key ID: 926634D64ACAD792
  1. 2
      hammerspoon/Spoons/BingDaily.spoon/init.lua
  2. 2
      hammerspoon/Spoons/WinRectangle.spoon/init.lua
  3. 24
      hammerspoon/autoscript.lua
  4. 4
      hammerspoon/init.lua
  5. 2
      skhd/skhdrc
  6. 3
      yabai/yabairc

2
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

2
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

24
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()

4
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)
----------------------------------------------------------------------------------------------------

2
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

3
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"

Loading…
Cancel
Save