From e1ba99e4758c4121cdbc7d968d37d1411d89581e Mon Sep 17 00:00:00 2001 From: Qijia Liu Date: Thu, 4 Jan 2024 20:59:15 -0500 Subject: [PATCH] move plugins to ~/Library/fcitx5 (#8) --- README.md | 16 ++++++++++++++++ src/fcitx.cpp | 19 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c6dc361..92051cb 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,22 @@ cmake --build build sudo cmake --install build ``` +## Debug +### Console.app +* Check `Include Info Messages` and `Include Debug Messages` in `Action` menu. +* Put `FcitxLog` in `Search`. + +### lldb +SSH into the mac from another device, then +```sh +$ /usr/bin/lldb +(lldb) process attach --name Fcitx5 +``` + +## Plugins +Fcitx5 only packges keyboard engine. +To install other engines, see [fcitx5-macos-plugins](https://github.com/fcitx-contrib/fcitx5-macos-plugins). + ## Credits * [fcitx5-android](https://github.com/fcitx5-android/fcitx5-android): LGPL-2.1-or-later * [squirrel](https://github.com/rime/squirrel): GPL-3.0-only diff --git a/src/fcitx.cpp b/src/fcitx.cpp index bf453c1..87798c6 100644 --- a/src/fcitx.cpp +++ b/src/fcitx.cpp @@ -35,9 +35,24 @@ void setupLog(bool verbose) { void start_fcitx() { setupLog(true); + + // ~/Library/fcitx5 + std::string fcitx5_prefix = std::string(getenv("HOME")) + "/Library/fcitx5"; + + // /Library/Input\ Methods/Fcitx5.app/Contents/lib/fcitx5:~/Library/fcitx5/lib/fcitx5 // Separate plugins so that dmg replacement won't remove them - setenv("FCITX_ADDON_DIRS", - APP_CONTENTS_PATH "/lib/fcitx5:/usr/local/lib/fcitx5", 1); + std::string fcitx_addon_dirs = + APP_CONTENTS_PATH "/lib/fcitx5:" + fcitx5_prefix + "/lib/fcitx5"; + setenv("FCITX_ADDON_DIRS", fcitx_addon_dirs.c_str(), 1); + + // ~/Library/fcitx5/share + std::string xdg_data_dirs = fcitx5_prefix + "/share"; + setenv("XDG_DATA_DIRS", xdg_data_dirs.c_str(), 1); + + // ~/Library/fcitx5/lib/libime + std::string libime_model_dirs = fcitx5_prefix + "/lib/libime"; + setenv("LIBIME_MODEL_DIRS", libime_model_dirs.c_str(), 1); + p_instance = std::make_unique(0, nullptr); auto &addonMgr = p_instance->addonManager(); addonMgr.registerDefaultLoader(&staticAddon);