Compare commits

..

3 Commits

  1. 64
      hammerspoon/Spoons/PomodoroTimer.spoon/init.lua
  2. 11
      hammerspoon/ime.lua
  3. 17
      hammerspoon/init.lua

64
hammerspoon/Spoons/PomodoroTimer.spoon/init.lua

@ -0,0 +1,64 @@
local obj = {}
obj.__index = obj
-- Metadata
obj.name = "PomodoroTimer"
obj.version = "1.0"
obj.author = "Ein Verne"
obj.homepage = "https://github.com/einverne/dotfiles"
obj.license = "MIT - https://opensource.org/licenses/MIT"
-- 设置默认值
obj.workDuration = 25 * 60 -- 25分钟工作时间
obj.breakDuration = 5 * 60 -- 5分钟休息时间
obj.timer = nil
obj.isWorking = true
obj.startSound = hs.sound.getByName("Submarine") -- 开始声音
obj.endSound = hs.sound.getByName("Glass") -- 结束声音
function obj:toggle()
if self.timer == nil then
self:start()
log.d("PomodoroTimer started")
else
self:stop()
log.d("PomodoroTimer stopped")
end
end
function obj:start()
log.d("PomodoroTimer start")
hs.alert.show("番茄时钟已启动", 2)
self.startSound:play() -- 播放开始声音
self:startTimer()
end
function obj:startTimer()
local duration = self.isWorking and self.workDuration or self.breakDuration
self.timer = hs.timer.doAfter(duration, function()
self.endSound:play() -- 播放结束声音
if self.isWorking then
hs.alert.show("工作时间结束,开始休息!", 5)
hs.notify.new({title="番茄时钟", informativeText="工作时间结束,开始休息!"}):send()
self.isWorking = false
else
hs.alert.show("休息时间结束,开始工作!", 5)
hs.notify.new({title="番茄时钟", informativeText="休息时间结束,开始工作!"}):send()
self.isWorking = true
end
self:startTimer() -- 开始下一个计时周期
end)
end
function obj:stop()
if self.timer then
self.timer:stop()
self.timer = nil
end
self.isWorking = true -- 重置为工作状态
hs.alert.show("番茄时钟已停止", 2)
self.endSound:play() -- 播放结束声音
end
return obj

11
hammerspoon/ime.lua

@ -12,6 +12,10 @@ local function ko()
hs.keycodes.currentSourceID("com.apple.inputmethod.Korean.HNCRomaja") hs.keycodes.currentSourceID("com.apple.inputmethod.Korean.HNCRomaja")
end end
local function jp()
hs.keycodes.currentSourceID("com.apple.inputmethod.Japanese.Japanese")
end
-- app to expected ime config -- app to expected ime config
local app2Ime = { local app2Ime = {
{'/System/Library/CoreServices/Finder.app', 'zh'}, {'/System/Library/CoreServices/Finder.app', 'zh'},
@ -19,20 +23,17 @@ local app2Ime = {
{'/Applications/Bitwarden.app', 'zh'}, {'/Applications/Bitwarden.app', 'zh'},
{'/Applications/Dash.app', 'zh'}, {'/Applications/Dash.app', 'zh'},
{'/Applications/iTerm.app', 'zh'}, {'/Applications/iTerm.app', 'zh'},
{'/Applications/Lark.app', 'zh'},
{'/Applications/Xcode.app', 'zh'}, {'/Applications/Xcode.app', 'zh'},
{'/Applications/GoldenDict.app', 'zh'}, {'/Applications/GoldenDict.app', 'zh'},
{'/Applications/Google Chrome.app', 'zh'}, {'/Applications/Google Chrome.app', 'zh'},
{'/Applications/DingTalk.app', 'zh'},
{'/Applications/KakaoTalk.app', 'zh'}, {'/Applications/KakaoTalk.app', 'zh'},
{'/Applications/kitty.app', 'zh'}, {'/Applications/kitty.app', 'zh'},
{'/Applications/NeteaseMusic.app', 'zh'}, {'/Applications/NeteaseMusic.app', 'zh'},
{'/Applications/System Preferences.app', 'zh'}, {'/Applications/System Preferences.app', 'zh'},
{'/Applications/MindNode.app', 'zh'}, {'/Applications/MindNode.app', 'zh'},
{'/Applications/Obsidian.app', 'zh'}, {'/Applications/Obsidian.app', 'zh'},
{'/Applications/Preview.app', 'zh'},
{'/Applications/Sketch.app', 'zh'},
{'/Applications/wechatwebdevtools.app', 'zh'}, {'/Applications/wechatwebdevtools.app', 'zh'},
{'/Applications/Warp.app', 'en'}, -- 添加这一行
{'/Applications/WeChat.app', 'zh'}, {'/Applications/WeChat.app', 'zh'},
{'/Users/einverne/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app', 'zh'}, {'/Users/einverne/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app', 'zh'},
{'/Users/einverne/Applications/JetBrains Toolbox/PyCharm Professional.app', 'zh'}, {'/Users/einverne/Applications/JetBrains Toolbox/PyCharm Professional.app', 'zh'},
@ -51,6 +52,8 @@ function updateFocusAppInputMethod()
en() en()
elseif expectedIme == 'zh' then elseif expectedIme == 'zh' then
zh() zh()
elseif expectedIme == 'jp' then
jp()
else else
ko() ko()
end end

17
hammerspoon/init.lua

@ -243,6 +243,7 @@ if not hspoon_list then
"WifiNotifier", "WifiNotifier",
"WinRectangle", "WinRectangle",
"Caffeine", "Caffeine",
"PomodoroTimer",
} }
end end
@ -252,10 +253,10 @@ for _, v in pairs(hspoon_list) do
end end
hs.hotkey.bind({}, "F12", function() hs.hotkey.bind({}, "F12", function()
local app = hs.application.get("net.kovidgoyal.kitty") local app = hs.application.get("dev.warp.Warp-Stable")
if app then if app then
if not app:mainWindow() then if not app:mainWindow() then
app:selectMenuItem({"kitty", "New OS window"}) app:selectMenuItem({"Warp", "New Window"})
elseif app:isFrontmost() then elseif app:isFrontmost() then
app:hide() app:hide()
else else
@ -263,8 +264,8 @@ hs.hotkey.bind({}, "F12", function()
end end
app:mainWindow():moveToUnit'[100, 80, 0, 0]' app:mainWindow():moveToUnit'[100, 80, 0, 0]'
else else
hs.application.launchOrFocus("/Applications/kitty.app") hs.application.launchOrFocus("/Applications/Warp.app")
app = hs.application.get("net.kovidgoyal.kitty") app = hs.application.get("dev.warp.Warp-Stable")
end end
end) end)
@ -543,6 +544,14 @@ if spoon.wifiNotifier then
spoon.wifiNotifier:start() spoon.wifiNotifier:start()
end end
log.d("PomodoroTimer Spoon loaded successfully")
if spoon.PomodoroTimer then
hs.hotkey.bind({"cmd", "ctrl"}, "0", function()
log.d("PomodoroTimer hotkey pressed")
spoon.PomodoroTimer:toggle()
end)
log.d("PomodoroTimer hotkey bound")
end
---------------------------------------------------------------------------------------------------- ----------------------------------------------------------------------------------------------------
-- Register browser tab typist: Type URL of current tab of running browser in markdown format. i.e. [title](link) -- Register browser tab typist: Type URL of current tab of running browser in markdown format. i.e. [title](link)

Loading…
Cancel
Save