Libpurple 无法在 bash 中工作

发布于 2024-09-07 18:05:13 字数 1302 浏览 9 评论 0原文

我正在使用从某个进程访问彻底的 DBUS。问题是它是从另一个用户运行的,并且 DBUS 会话对他们来说是不同的。因此,如果会话不同,我无法通过另一个进程访问使用 DBUS 的应用程序。我找到了解决这个问题的方法:一些脚本从主用户写入文件 dbus 会话数据(我在系统加载时设置它)。这是该脚本:

#!/bin/bash
touch /.Xdbus
chmod 666 /.Xdbus
env | grep DBUS_SESSION_BUS_ADDRESS > /.Xdbus
echo 'export DBUS_SESSION_BUS_ADDRESS' >> /.Xdbus

这是该文件的示例:

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023
export DBUS_SESSION_BUS_ADDRESS

现在我只需执行该文件中的数据,两个 DBUS 会话将是相同的。这里有一些麻烦:

#!/bin/bash
if [ -f /.Xdbus ]
then
    source /.Xdbus; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"
else
    echo "File doesnt exist"
fi

如您所见,我使用 pidgin 作为 DBUS 应用程序。但它会抛出错误,没有紫色应用程序,因此 DBUS 会话不同!所以命令:

source /.Xdbus

没用。为什么?


UPD

source /.Xdbus; echo $DBUS_SESSION_BUS_ADDRESS; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"; echo $DBUS_SESSION_BUS_ADDRESS;

unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023 No existing libpurple instance detected. unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023

I'm using accessing thorough DBUS from some process. The trouble is that it runs from another user and session of DBUS is different for them. So I can't acces application which uses DBUS through another process if the sessions are different. I found the way to resolve this trouble: some script writes into file dbus session data from main user (I set it at system loading). Here is that script:

#!/bin/bash
touch /.Xdbus
chmod 666 /.Xdbus
env | grep DBUS_SESSION_BUS_ADDRESS > /.Xdbus
echo 'export DBUS_SESSION_BUS_ADDRESS' >> /.Xdbus

Here is an example of that file:

DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023
export DBUS_SESSION_BUS_ADDRESS

Now I just have to execute data from that file and both DBUS sessions will be same. Here is some troubles:

#!/bin/bash
if [ -f /.Xdbus ]
then
    source /.Xdbus; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"
else
    echo "File doesnt exist"
fi

As you could see, I'm using pidgin as DBUS application. But it throws the error, that there is no purple application, so the DBUS sessions are different! So comand:

source /.Xdbus

Didn't work. Why?


UPD

source /.Xdbus; echo $DBUS_SESSION_BUS_ADDRESS; /usr/bin/purple-remote "setstatus?status=away&message=At lunch"; echo $DBUS_SESSION_BUS_ADDRESS;

unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023 No existing libpurple instance detected. unix:abstract=/tmp/dbus-9yStbCgjwb,guid=0deadb6519676638e1e93f5000000023

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

幽蝶幻影 2024-09-14 18:05:13

根据您的更新,source 命令正在运行。因此,问题出在 purple-remotelibpurple 或某些依赖项上,而不是您的 Bash 脚本上。

在根目录中创建此类文件不是一个好主意。尝试为您的文件选择更合适的位置。可能是以下之一:

  • /home/username/.Xdbus
  • /var/local/.Xdbus - 您可能必须将您的用户添加到拥有此目录的组
  • <代码>/tmp/.Xdbus

Based on your update, the source command is working. Therefore the problem is with purple-remote or libpurple or some dependency rather than with your Bash script.

It's not a good idea to create such files in the root directory. Try choosing a more appropriate location for your file. One of the following perhaps:

  • /home/username/.Xdbus
  • /var/local/.Xdbus - you might have to add your user to the group that owns this directory
  • /tmp/.Xdbus
や莫失莫忘 2024-09-14 18:05:13

我认为这是因为您使用 / 这是文件系统的根目录。
你想要的是 ./ 或丹尼斯所说的绝对路径。

您还可以使用 $PWD/file 或 ${pwd}/file

I think it is because you use / which is the root of the filesystem.
What you want is ./ or an absolute path as said Dennis.

You can also use $PWD/file or ${pwd}/file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文