Skip to content

Commit

Permalink
revive auto add im feature
Browse files Browse the repository at this point in the history
  • Loading branch information
eagleoflqj committed Oct 30, 2024
1 parent f26fbe6 commit 5fa38f6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ jobs:
- name: Test
run: |
cd build
ctest --output-on-failure
ctest --test-dir build --output-on-failure
- name: Upload artifact
uses: actions/upload-artifact@v4
Expand Down
8 changes: 8 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
"group": {
"kind": "build"
}
},
{
"type": "shell",
"label": "Test",
"command": "ctest --test-dir build --output-on-failure",
"group": {
"kind": "build"
}
}
]
}
4 changes: 3 additions & 1 deletion config/ipc.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import AppKit

let bundleId = "org.fcitx.inputmethod.Fcitx5"
let fcitx5Executable = "/Library/Input Methods/Fcitx5.app/Contents/MacOS/Fcitx5"

func restartFcitxProcess() {
func restartFcitxProcess(inputMethods: [String] = []) {
for app in NSRunningApplication.runningApplications(withBundleIdentifier: bundleId) {
app.terminate()
}
exec(fcitx5Executable, inputMethods, isAsync: true)
}
8 changes: 1 addition & 7 deletions config/plugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,8 @@ struct PluginView: View {
(nativeResults[$0] ?? true) && (dataResults[$0] ?? true)
}.flatMap { getAutoAddIms($0) }
refreshPlugins()
// if Fcitx.imGroupCount() == 1 {
// // Otherwise user knows how to play with it, don't mess it up.
// for im in inputMethods {
// Fcitx.imAddToCurrentGroup(im)
// }
// }
restartFcitxProcess(inputMethods: inputMethods)
processing = false
restartFcitxProcess()
},
onProgress: { progress in
downloadProgress = progress
Expand Down
9 changes: 9 additions & 0 deletions src/server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {

let locale = getLocale()
start_fcitx_thread(locale)

// Config Tool may restart Fcitx5 with input methods to auto add.
let inputMethods = CommandLine.arguments.dropFirst()
if imGroupCount() == 1 {
// Otherwise user knows how to play with it, don't mess it up.
for im in inputMethods {
Fcitx.imAddToCurrentGroup(im)
}
}
}

func applicationWillTerminate(_ notification: Notification) {
Expand Down

0 comments on commit 5fa38f6

Please sign in to comment.