This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
set -e | ||
|
||
all_plugins=( | ||
skk | ||
lua | ||
hallelujah | ||
chinese-addons # Optional dependency: lua | ||
|
Submodule fcitx5-skk
added at
9b34b5
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
diff --git a/src/skk.cpp b/src/skk.cpp | ||
index 2606461..1b37bcd 100644 | ||
--- a/src/skk.cpp | ||
+++ b/src/skk.cpp | ||
@@ -294,6 +294,8 @@ SkkEngine::SkkEngine(Instance *instance) | ||
newState->applyConfig(); | ||
return newState; | ||
}) { | ||
+ std::string datadir = std::string(getenv("HOME")) + "/Library/fcitx5/share/libskk"; | ||
+ setenv("LIBSKK_DATA_PATH", datadir.c_str(), 1); | ||
skk_init(); | ||
|
||
modeAction_ = std::make_unique<SkkModeAction>(this); | ||
@@ -501,30 +502,36 @@ void SkkEngine::loadDictionary() { | ||
continue; | ||
} | ||
if (mode == 1) { | ||
- if (stringutils::endsWith(path, ".cdb")) { | ||
+ constexpr char xdgDataDir[] = "$XDG_DATA_DIR/"; | ||
+ std::string realpath = path; | ||
+ if (stringutils::startsWith(path, xdgDataDir)) { | ||
+ realpath = StandardPath::global().locate( | ||
+ StandardPath::Type::Data, | ||
+ path.substr(sizeof(xdgDataDir) - 1)); | ||
+ } | ||
+ if (stringutils::endsWith(realpath, ".cdb")) { | ||
SkkCdbDict *dict = | ||
- skk_cdb_dict_new(path.data(), encoding.data(), nullptr); | ||
+ skk_cdb_dict_new(realpath.data(), encoding.data(), nullptr); | ||
if (dict) { | ||
- SKK_DEBUG() << "Adding cdb dict: " << path; | ||
+ SKK_DEBUG() << "Adding cdb dict: " << realpath; | ||
dictionaries_.emplace_back(SKK_DICT(dict)); | ||
} | ||
} else { | ||
SkkFileDict *dict = skk_file_dict_new( | ||
- path.data(), encoding.data(), nullptr); | ||
+ realpath.data(), encoding.data(), nullptr); | ||
if (dict) { | ||
- SKK_DEBUG() << "Adding file dict: " << path; | ||
+ SKK_DEBUG() << "Adding file dict: " << realpath; | ||
dictionaries_.emplace_back(SKK_DICT(dict)); | ||
} | ||
} | ||
} else { | ||
constexpr char configDir[] = "$FCITX_CONFIG_DIR/"; | ||
- constexpr auto len = sizeof(configDir) - 1; | ||
std::string realpath = path; | ||
if (stringutils::startsWith(path, configDir)) { | ||
realpath = stringutils::joinPath( | ||
StandardPath::global().userDirectory( | ||
StandardPath::Type::PkgData), | ||
- path.substr(len)); | ||
+ path.substr(sizeof(configDir) - 1)); | ||
} | ||
SkkUserDict *userdict = skk_user_dict_new( | ||
realpath.data(), encoding.data(), nullptr); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
set -e | ||
|
||
. ./common.sh skk $1 | ||
|
||
# Use PkgConfig::LibSKK | ||
sed -i '' 's/find_package(LibSKK REQUIRED)/pkg_check_modules(LibSKK REQUIRED IMPORTED_TARGET "libskk" REQUIRED)/' CMakeLists.txt | ||
sed -i '' 's/LibSKK::LibSKK/PkgConfig::LibSKK/' src/CMakeLists.txt | ||
|
||
# Patch to load data files from ~/Library/fcitx5 | ||
git checkout src/skk.cpp | ||
git apply ../patches/skk.patch | ||
|
||
# Build fcitx5-skk | ||
install_deps libxkbcommon pcre2 glib libgee libskk json-glib | ||
f5m_configure -DENABLE_QT=OFF | ||
f5m_build | ||
f5m_install | ||
|
||
# Install libskk data files to ~/Library/fcitx5/share/libskk | ||
rm -rf $DESTDIR$INSTALL_PREFIX/share/libskk | ||
mkdir -p $DESTDIR$INSTALL_PREFIX/share/libskk | ||
mv /tmp/fcitx5/share/libskk/rules $DESTDIR$INSTALL_PREFIX/share/libskk | ||
|
||
# Install the default dict to ~/Library/fcitx5/share/skk-dict | ||
dict_dir=$DESTDIR$INSTALL_PREFIX/share/skk-dict | ||
mkdir -p $dict_dir | ||
cd $dict_dir | ||
wget -nc https://skk-dev.github.io/dict/SKK-JISYO.L.gz | ||
gunzip -f SKK-JISYO.L.gz | ||
mv SKK-JISYO.L $dict_dir/SKK-JISYO.L | ||
cd - | ||
|
||
# Write the new dictionary list | ||
cat > $DESTDIR$INSTALL_PREFIX/share/fcitx5/skk/dictionary_list <<EOF | ||
type=file,file=\$FCITX_CONFIG_DIR/skk/user.dict,mode=readwrite | ||
type=file,file=\$XDG_DATA_DIR/skk-dict/SKK-JISYO.L,mode=readonly | ||
EOF | ||
|
||
f5m_make_tarball |