Last active
April 21, 2025 00:39
-
-
Save haje01/f133ab7f99b684b36672ed24e87c59f2 to your computer and use it in GitHub Desktop.
macOS IME Cursor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 설치 방법: | |
-- 1. Hammerspoon 설치 (https://www.hammerspoon.org/) | |
-- 2. 아래 내용을 ~/.hammerspoon/init.lua 으로 저장 | |
-- | |
-- 참고: 윈도우용 IME Cursor (https://forest.watch.impress.co.jp/library/software/imecursor/) | |
local indicatorCircle = nil | |
local followTimer = nil | |
local xoff = 15 | |
local yoff = 4 | |
local green = { red = 0.2, green = 1.0, blue = 0.2, alpha = 1.0 } | |
function showCircleIndicator(color) -- 기존 원 삭제 | |
if indicatorCircle and type(indicatorCircle.delete) == "function" then | |
indicatorCircle:delete() | |
indicatorCircle = nil | |
end | |
local cursor = hs.mouse.absolutePosition() | |
local size = 12 -- 원 크기 | |
local frame = { x = cursor.x + xoff, y = cursor.y + yoff, w = size, h = size } | |
indicatorCircle = hs.drawing.circle(frame) | |
indicatorCircle:setFillColor(color) | |
indicatorCircle:setStrokeColor({red=0, green=0, blue=0, alpha=1}) | |
indicatorCircle:setStrokeWidth(1) | |
indicatorCircle:setLevel(hs.drawing.windowLevels.overlay) | |
indicatorCircle:show() | |
-- 커서 따라다니게 | |
if followTimer then followTimer:stop() end | |
followTimer = hs.timer.doEvery(0.01, function() | |
if indicatorCircle then | |
local cursor = hs.mouse.absolutePosition() | |
indicatorCircle:setFrame({ | |
x = cursor.x + xoff, | |
y = cursor.y + yoff, | |
w = size, | |
h = size | |
}) | |
end | |
end) | |
end | |
-- 입력기 변경 감지 | |
hs.keycodes.inputSourceChanged(function() | |
local source = hs.keycodes.currentSourceID() | |
if source:find("com.apple.inputmethod.Korean") or source:find("Hangul") then | |
showCircleIndicator(green) | |
else | |
if indicatorCircle then indicatorCircle:hide() end | |
if followTimer then followTimer:stop() end | |
end | |
end) | |
-- 스크립트 실행 시 초기 표시 | |
local currentSource = hs.keycodes.currentSourceID() | |
if currentSource:find("com.apple.inputmethod.Korean") or currentSource:find("Hangul") then | |
showCircleIndicator(green) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment