darktable-org / darktable-org/lua-scripts

Docs: personal scripts and Flatpak luarc limitations not documented (5.6.0)

未关闭
#697 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Lua
星标
219
派生
142
PR 合并指标
30 天内没有已合并 PR

描述

Summary

Several behaviours that affect anyone writing personal Lua startup scripts under Darktable 5.6.0 (Flatpak, Linux) are undocumented or incorrect in the current README. Discovered through hands-on debugging. Submitting as a doc issue in case it is useful to others or to the maintainers for a README update.


1. Lua version is 5.4, not the host system version

Darktable 5.x bundles its own interpreter. The system lua -v (often 5.1 or 5.3) is irrelevant. Confirmed for 5.6.0 Flatpak:

flatpak run --command=find org.darktable.Darktable /app -name "liblua*.so.*"
# → /app/lib/liblua.so.5.4.6

goto, <const>, bitwise operators all work inside Darktable scripts.


2. require "myscript" in the user luarc silently fails under Flatpak

The README's "Enabling" section says to add require "myscript" to the user luarc. This works for native installs but silently does nothing under Flatpak.

Why: Darktable Flatpak ships a system luarc (/app/share/darktable/luarc) that loads tools/script_manager. Because script_manager detects it is running from the system data directory (system_based = true), the user's ~/.var/.../config/darktable/luarc is loaded via loadfile() rather than require(), and at that point the Lua package.path does not include the user lua/ directory. Any require "myscript" in the user luarc silently fails — no error, no load.


3. The correct approach: personal/ subfolder + darktablerc entry

script_manager scans USER_LUA_DIR but only processes scripts that are inside a named subfolder (the pattern requires at least one /). A .lua file placed directly in lua/ is silently ignored.

Working approach:

mkdir -p ~/.var/app/org.darktable.Darktable/config/darktable/lua/personal
cp myscript.lua ~/.var/app/org.darktable.Darktable/config/darktable/lua/personal/

Then add one line to darktablerc:

lua/script_manager/personal/myscript=TRUE

Key format: lua/script_manager/<folder>/<script-name-without-.lua>.

The script can also be enabled through the Darktable UI (Lua Scripts panel → personal folder → toggle), which writes the darktablerc entry automatically.


4. dt.films.new(path) creates empty film rolls — use dt.database.import(path) instead

dt.films.new(path) creates the film_roll database entry but does not scan for images. The resulting roll is empty. Darktable prunes empty film rolls on exit, so the call appears to succeed (no Lua error) but nothing persists after the session.

dt.database.import(path) is the correct call when the intent is to import images:

-- When given a directory path, returns a table of imported image objects
local ok, result = pcall(dt.database.import, path)
if ok then
    local n = type(result) == "table" and #result or (result ~= nil and 1 or 0)
    -- n images imported, film roll created with content
end

5. Minimal working template for a personal startup script

-- lua/personal/myscript.lua
-- Loaded by script_manager; runs when lighttable becomes active.

local dt = require "darktable"

local function run()
    -- dt.films, dt.database.import, etc. are all ready here
end

dt.register_event("myscript", "view-changed",
    function(event, old_view, new_view)
        if new_view.id == "lighttable" and
           (old_view == nil or old_view.id == "none") then
            pcall(run)
        end
    end
)

6. Debugging gotcha: Snap/Flatpak LD_LIBRARY_PATH crash

On systems with Snap installed, running flatpak run org.darktable.Darktable -d lua from a terminal may crash immediately:

symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0:
    undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE

Workaround:

env -u LD_LIBRARY_PATH flatpak run org.darktable.Darktable -d lua 2>&1 | grep lua

Suggested README additions

  • Note under the Flatpak section that require "myscript" only works for scripts inside the cloned lua-scripts repository; personal scripts need the personal/ subfolder + darktablerc approach.
  • A brief "Personal Scripts" subsection covering the above.
  • A note in the API docs (or script_manager docs) that dt.films.new() does not import images and dt.database.import() should be used instead.

Happy to help draft specific text if useful.

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

先从 README 的 Enabling 和 Flatpak 部分开始,然后检查 script_manager 入口点以及 dt.films.new 和 dt.database.import 的 API 文档。更新文档,涵盖 personal/ scripts、darktablerc 键、Flatpak 加载限制、图像导入行为以及 LD_LIBRARY_PATH 调试 workaround。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua
领域
documentation
Issue 类型
文档
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。