【发布时间】:2026-01-26 06:25:01
【问题描述】:
在 Debian (11) 测试中运行 Awesome
awesome v4.3 (Too long)
• Compiled against Lua 5.3.3 (running with Lua 5.3)
• D-Bus support: ✔
• execinfo support: ✔
• xcb-randr version: 1.6
• LGI version: 0.9.2
我正在尝试在 systemd 触发挂起时向 Awesome 发出信号。直接在 D-Bus 上摆弄了一阵子,一无所获后,我写了几个函数,在某种程度上复制了信号的功能。
我通过在我的 Awesome 会话中的 shell 中运行以下命令对其进行了测试:
$ awesome-client 'require("lib.syskit").signal("awesome-client", "Hello world!")'
这运行得很好。一条通知发布到桌面“Hello world!”正如预期的那样。我将lib.syskit 代码的路径添加到~/.xsessionrc 中的$LUA_PATH。鉴于下面描述的错误,我怀疑这是一个问题。
现在是更困难的部分。我将以下内容放在位于/lib/systemd/system-sleep/pre-suspend.sh的脚本中
#!/bin/bash
if [ "${1}" == "pre" ]; then
ERR=$(export DISPLAY=":0"; sudo -u naddan awesome-client 'require("lib.syskit").signal("awesome-client", "pre-suspend")' 2>&1)
echo "suspending at `date`, ${ERR}" > /tmp/systemd_suspend_test
elif [ "${1}" == "post" ]; then
ERR=$(export DISPLAY=":0"; sudo -u naddan awesome-client 'require("lib.syskit").signal("awesome-client", "post-suspend")' 2>&1)
echo "resuming at `date`, ${ERR}" >> /tmp/systemd_suspend_test
fi
这是写入/tmp/systemd_suspend_test的输出
suspending at Thu 22 Jul 2021 10:58:01 PM MDT, Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally without any error message
E: dbus-send failed.
resuming at Thu 22 Jul 2021 10:58:05 PM MDT, Failed to open connection to "session" message bus: /usr/bin/dbus-launch terminated abnormally without any error message
E: dbus-send failed.
鉴于我已经告诉它正在运行 Awesome 的 $DISPLAY(这是一台笔记本电脑),并且我正在以我的用户而不是 root 身份运行 awesome-client,所以我还缺少什么这是工作吗?
有没有更好的方法可以在系统挂起时告诉 Awesome?
【问题讨论】:
标签: x11 dbus awesome-wm