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. --- 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) --- 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={} local obj={}
obj.__index = 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. --- 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') obj.logger = hs.logger.new('WinRectangle')
log = hs.logger.new('WinRectangle', 'debug') local log = hs.logger.new('WinRectangle', 'debug')
obj.grid = 50 obj.grid = 50

24
hammerspoon/autoscript.lua

@ -1,27 +1,15 @@
log = hs.logger.new('autoscript', 'debug') 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) function taskCallback(exitCode, stdOut, stdErr)
hs.alert.show("execute") log.i("task call back ", exitCode, stdOut, stdErr)
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)
end end
function runAutoScripts() function runAutoScripts()
for key, cmd in ipairs(cmdArr) do args = {"-c", "/Users/einverne/Sync/wiki/auto-push.sh"}
log.i("execute" .. key .. " " .. cmd) autoCommitTask = hs.task.new("/bin/bash", taskCallback, args)
shell(cmd) autoCommitTask:setWorkingDirectory("/Users/einverne/Sync/wiki/")
end autoCommitTask:start()
end end
myTimer = hs.timer.doEvery(7200, runAutoScripts) myTimer = hs.timer.doEvery(7200, runAutoScripts)
myTimer:start() myTimer:start()

4
hammerspoon/init.lua

@ -233,7 +233,6 @@ if not hspoon_list then
--"CountDown", --"CountDown",
"HCalendar", "HCalendar",
--"HSaria2", --"HSaria2",
"SpeedMenu",
"WinWin", "WinWin",
"WifiNotifier", "WifiNotifier",
"WinRectangle", "WinRectangle",
@ -256,12 +255,11 @@ hs.hotkey.bind({}, "F12", function()
else else
app:activate() app:activate()
end end
app:mainWindow():moveToUnit'[100, 80, 0, 0]'
else else
hs.application.launchOrFocus("kitty") hs.application.launchOrFocus("kitty")
app = hs.application.get("kitty") app = hs.application.get("kitty")
end end
app:mainWindow():moveToUnit'[100, 80, 0, 0]'
end) end)
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------

2
skhd/skhdrc

@ -101,7 +101,7 @@
# 0x2F = Fullstop / > # 0x2F = Fullstop / >
# 0x2C = Slash # 0x2C = Slash
# open terminal # 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 # close focused window
# alt - w : yabai -m window --close # 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 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="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="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="kitty" app="kitty" manage=off
yabai -m rule --add label="IntelliJ IDEA" app="IntelliJ IDEA" manage=off space=code 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="Preview" app="Preview" manage=off
yabai -m rule --add label="System Preferences" app="^System Preferences$" 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="SmartGit" app="SmartGit" manage=off space=git
yabai -m rule --add label="VirtualBox" app="^VirtualBox$" manage=off 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 yabai -m rule --add label="Zotero" app="^Zotero$" manage=off
# signals # signals
# focus mouse hovered window when a window is closed, minimized or terminated # 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" yabai -m signal --add event=window_destroyed action="yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"

Loading…
Cancel
Save