Skip to content

Set LUA_PATH envvar for fcitx5-lua #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 8, 2022
Merged

Set LUA_PATH envvar for fcitx5-lua #110

merged 1 commit into from
Sep 8, 2022

Conversation

SkymontVibe
Copy link
Contributor

@SkymontVibe SkymontVibe commented Sep 8, 2022

[ARCHIVED]

设置好LUA_PATHLUA_CPATH后就可以引入模块了

  • $FCITX_DATA_HOME/lua,为非root用户提供模块放置的位置
  • $XDG_DATA_DIRS/lua/5.4,和电脑上的lua位置是一样的,为那种反编译再重新打包来集成资源的人提供(放置在assets/usr/share/lua/5.4)
  • 保留了预置的/usr/local/share/lua/5.4,但是对非root用户来说显然没有任何意义

当然这是我自己定的,或者你看放置在哪里好一点

下面两例测试通过

例子一:

  1. json_example.lua,文件内容如下:
local json = require ("dkjson")

local tbl = {
  animals = { "dog", "cat", "aardvark" },
  instruments = { "violin", "trombone", "theremin" },
  bugs = json.null,
  trees = nil
}

function output()
  return {
    json.encode (tbl, { indent = true })
  }
end

ime.register_command("bm", "output", "", "none")
  1. dkjson.lua在此下载
  2. 编译并安装fcitx5,dkjson.lua放置在存储/Android/data/org.fcitx.fcitx5.android/files/data/lua/json_example.json放置在存储/Android/data/org.fcitx.fcitx5.android/files/data/lua/imeapi/extensions/,重启fcitx5
  3. 进入 QuickPhrase 模式并输入 bm,能够正常输出json。在以前日志会提示找不到模块

例子二:

  1. 解包一个fcitx5的安装包
  2. 上述dkjson.lua,放置在app/src/main/assets/usr/share/lua/5.4/并修改那个清单json文件(gradle 构建时会自动生成)
  3. 签名,安装这个改过的包
  4. json_example.lua还是放在上述位置,重启配置
  5. 进入 QuickPhrase 模式并输入 bm

With this commit:
- Users who do not root their devices could `require` modules from user directories.
- One can integrate Lua module into decompiled apk.
@SkymontVibe SkymontVibe changed the title Set LUA_PATH for fcitx5-lua Set LUA_PATH envvar for fcitx5-lua Sep 8, 2022
@rocka
Copy link
Member

rocka commented Sep 8, 2022

json_example.lua 没有写 return ,我加上去了(调了半天才发现);还有例子里的几个路径也改了一下。
v 触发快速输入只对全拼输入法有效,在英文键盘和双拼输入法的时候可以用左下角专门的 QuickPhrase 按键。
另外 descriptor.json 不需要手动修改, gradle 在构建的时候会自动生成。

然后测了一下都可以跑通,就先合并了。

@rocka rocka merged commit 5bde7a0 into fcitx5-android:master Sep 8, 2022
@SkymontVibe SkymontVibe changed the title Set LUA_PATH envvar for fcitx5-lua [REMOVED] May 12, 2024
@rocka rocka changed the title [REMOVED] Set LUA_PATH envvar for fcitx5-lua Jun 1, 2024
mokapsing pushed a commit to mokapsing/fcitx5-android that referenced this pull request Jun 26, 2024
@fcitx5-android fcitx5-android deleted a comment Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants