来了来了
-- ~/.hammerspoon
-- ├── Spoons
-- │ └── CurrentInputSource.spoon
-- │ └── init.lua
-- └── init.lua ✅
local CurrentInputSource = hs.loadSpoon('CurrentInputSource')
CurrentInputSource:start()
-- ~/.hammerspoon
-- ├── Spoons
-- │ └── CurrentInputSource.spoon
-- │ └── init.lua ✅
-- └── init.lua
local obj = {}
local abcImage = hs.image.imageFromPath("/System/Library/Input Methods/JapaneseIM-RomajiTyping.app/Contents/PlugIns/JapaneseIM-RomajiTyping.appex/Contents/Resources/Roman.tiff"):template(true)
local pinyinImage = hs.image.imageFromPath("/System/Library/Input Methods/SCIM.app/Contents/PlugIns/SCIM_Extension.appex/Contents/Resources/pinyin.tiff"):template(true)
function isCurrentInputSource(sourceName, isMethod)
if isMethod then
return sourceName == hs.keycodes.currentMethod()
else
return sourceName == hs.keycodes.currentLayout()
end
end
function currentInputSourceIcon()
if isCurrentInputSource("ABC", false) then
return abcImage
elseif isCurrentInputSource("Pinyin - Simplified", true) then
return pinyinImage
end
return nil
end
-- ~/.hammerspoon
-- ├── Spoons
-- │ └── CurrentInputSource.spoon
-- │ └── init.lua ✅
-- └── init.lua
function obj:init()
self.menubar = hs.menubar.new(true, "CurrentInputSource")
self.abc = {
title = "ABC",
image = abcImage,
fn = function()
if not isCurrentInputSource("ABC", false) then
hs.keycodes.setLayout("ABC")
end
end,
checked = isCurrentInputSource("ABC", false)
}
self.pinyin = {
title = "简体拼音",
image = pinyinImage,
fn = function()
if not isCurrentInputSource("Pinyin - Simplified", true) then
hs.keycodes.setMethod("Pinyin - Simplified")
end
end,
checked = isCurrentInputSource("Pinyin - Simplified", true)
}
self.menuItems = {}
self.menuItems[1] = self.abc
self.menuItems[2] = self.pinyin
self.menubar:setMenu(function()
return self.menuItems
end)
self.menubar:setIcon(currentInputSourceIcon())
end
function obj:start()
hs.keycodes.inputSourceChanged(function()
if isCurrentInputSource("ABC", false) then
self.menubar:setIcon(abcImage)
self.abc.checked = true
self.pinyin.checked = false
elseif isCurrentInputSource("Pinyin - Simplified", true) then
self.menubar:setIcon(pinyinImage)
self.abc.checked = false
self.pinyin.checked = true
end
end)
end
function obj:stop()
hs.keycodes.inputSourceChanged(nil)
end
return obj
1
K2 2023-05-19 13:06:57 +08:00
不想看到也可以隐藏掉
|
2
eairjhioaegnh OP @K2 但是还是想看到当前状态
|
3
Socrazy 2023-05-19 13:15:34 +08:00
习惯一下就可以了,现在看高的输入法图标反而不适应了
|
4
Hooluu 2023-05-22 17:57:58 +08:00
留个名,请问如何更改啊?非程序员,看的云里雾里,T T
|
5
eairjhioaegnh OP @Hooluu 没法更改,是关掉系统本身的,自己用系统图标文件新建一个菜单栏图标
|
6
Hooluu 2023-05-22 20:25:55 +08:00
@eairjhioaegnh 完全听不懂,T T
|
7
eairjhioaegnh OP @Hooluu 1. 下载安装 Hammerspoon ,https://github.com/Hammerspoon/hammerspoon/releases/latest
2. 下载 Spoon 插件,https://wwcg.lanzouy.com/i07ur0wyl46d ,解压后将 CurrentInputSource.spoon 移动到 /Users/用户名 /.hammerspoon/Spoons/,将 init.lua 移动到 /Users/用户名 /.hammerspoon/ 3. 打开 Hammerspoon ,点击菜单栏图标(锤子模样),点击”Reload Config" |
8
Hooluu 2023-05-22 21:29:12 +08:00
@eairjhioaegnh 按照你的步骤操作,木有效果,不折腾了,我直接干脆把搜狗输入法图标自己 PS 修改变宽,反向让图标和系统默认丑陋的输入法图标一样的宽度,顺眼多了,doge
|
9
eairjhioaegnh OP @Hooluu 咱们强迫症太难了😂
|
10
Hooluu 2023-05-24 03:01:23 +08:00
@eairjhioaegnh 只能说苹果现在越来越不尊重自己立下的设计规范了。ε=(´ο`*)))唉
|