File tree Expand file tree Collapse file tree 3 files changed +16
-3
lines changed
Expand file tree Collapse file tree 3 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 1+ add_executable (get_im get_im.swift)
12add_executable (switch_im switch_im.swift)
23
34install (FILES "${CMAKE_CURRENT_SOURCE_DIR} /fcitx.icns"
@@ -33,6 +34,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/menu_icon_15.pdf"
3334# Preserve execution permission
3435install (PROGRAMS "${CMAKE_CURRENT_SOURCE_DIR} /uninstall.sh"
3536 "${CMAKE_CURRENT_SOURCE_DIR} /update.sh"
37+ "${CMAKE_CURRENT_BINARY_DIR} /get_im"
3638 "${CMAKE_CURRENT_BINARY_DIR} /switch_im"
3739 DESTINATION "${CMAKE_INSTALL_PREFIX} /Resources"
3840)
Original file line number Diff line number Diff line change 1+ import Carbon
2+
3+ let enId = " org.fcitx.inputmethod.Fcitx5.fcitx5 "
4+
5+ let inputSource = TISCopyCurrentKeyboardInputSource ( ) . takeRetainedValue ( )
6+ let id = TISGetInputSourceProperty ( inputSource, kTISPropertyInputSourceID)
7+ if let id = id {
8+ print ( Unmanaged < AnyObject > . fromOpaque ( id) . takeUnretainedValue ( ) as? String ?? enId)
9+ } else {
10+ print ( enId)
11+ }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ xattr -dr com.apple.quarantine "$APP_DIR"
2626codesign --force --sign - --deep " $APP_DIR "
2727
2828cd " $RESOURCES_DIR "
29+ im=$( su -m " $user " -c " ./get_im" )
2930# Switching out is necessary, otherwise it doesn't show menu
3031# Not sure which one so try both.
3132su -m " $user " -c " ./switch_im com.apple.keylayout.ABC"
@@ -53,6 +54,5 @@ killall Fcitx5
5354# org.fcitx.inputmethod.Fcitx5 is our CFBundleIdentifier;
5455# The rest is the keys under tsInputModeListKey trimming the org.fcitx.inputmethod.
5556
56- # Not sure which one so try both.
57- su -m " $user " -c " ./switch_im org.fcitx.inputmethod.Fcitx5.fcitx5"
58- su -m " $user " -c " ./switch_im org.fcitx.inputmethod.Fcitx5.zhHans"
57+ # Switch back.
58+ su -m " $user " -c " ./switch_im $im "
You can’t perform that action at this time.
0 commit comments