dbus-send如何从Zathura获取页面数?

发布于 2025-01-21 13:04:48 字数 620 浏览 3 评论 0原文

我正在尝试使用dbus-send从Zathura获取页面总数(Zathura是PDF查看器)(请参阅下面的图)。我不熟悉DBU(无论我如何尝试学习,我总是放弃)。

我可以使用GUI程序查看页面的总数numberOfpages当我双击该属性时,我会得到该值。

但是,我正在尝试使用dbus-send获得相同的信息。我在终端上尝试了以下内容:

dbus-send --session --dest=org.pwmt.zathura.PID-1057698 \
 --print-reply org.pwmt.zathura.Properties.numberofpages

上面的命令不起作用。

您能告诉我如何构建一个dbus-command以获取numberOfpages值?

I am trying to use dbus-send to get the total number of page from zathura (Zathura is a PDF viewer) (See figure below). I am not familiar with DBus (no matter how I try to learn it, I always give up).

I could use a GUI program to see the total number of pages numberofpages when I double click on that property I get the value.

However, I am trying to get the same information using dbus-send. I tried the following on the terminal:

dbus-send --session --dest=org.pwmt.zathura.PID-1057698 \
 --print-reply org.pwmt.zathura.Properties.numberofpages

The command above doesn't work.

Could you please tell me how can I construct a dbus-command to get the numberofpages value?

enter image description here

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

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

发布评论

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

评论(2

梦萦几度 2025-01-28 13:04:48

使用Busctl而不是dbus-send,这可能更容易。无论哪种方式,对于大多数D-Bus情况,您都需要了解四个信息。

  1. 总线名称:org.pwmt.zathura.pid-1057698
  2. 路径:/org/pwmt/pwmt/zathura
  3. 接口:org.pwmt.zathura
  4. 属性: numberOfpages

我希望您的情况会看起来像:

busctl --user get-property org.pwmt.zathura.PID-1057698 /org/pwmt/zathura org.pwmt.zathura numberofpages 

在大多数机器上可能运行的服务上尝试此情况:

  1. 总线名称:org.freedesktop.systemd1
  2. path:path:path: /org/freedesktop/systemd1
  3. 接口:org.freedesktop.systemd1.manager
  4. 属性:架构

与两个实用程序运行:

dbus-send

$ dbus-send --session --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties.Get string:"org.freedesktop.systemd1.Manager" string:"Architecture"
method return time=1650033765.273653 sender=:1.0 -> destination=:1.176 serial=2677 reply_serial=2
   variant       string "x86-64"

butctl

$ busctl --user get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Architecture 
s "x86-64"

This might be easier to do using busctl rather than dbus-send. Either way there is four bits of information you need to know for most D-Bus situation.

  1. Bus Name: org.pwmt.zathura.PID-1057698
  2. Path: /org/pwmt/zathura
  3. Interface: org.pwmt.zathura
  4. Property: numberofpages

I would expect your situation to look like:

busctl --user get-property org.pwmt.zathura.PID-1057698 /org/pwmt/zathura org.pwmt.zathura numberofpages 

To try this on a service that is likely to be running on most machines:

  1. Bus Name: org.freedesktop.systemd1
  2. Path: /org/freedesktop/systemd1
  3. Interface: org.freedesktop.systemd1.Manager
  4. Property: Architecture

And to run it with both utilities:

dbus-send

$ dbus-send --session --print-reply --dest=org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties.Get string:"org.freedesktop.systemd1.Manager" string:"Architecture"
method return time=1650033765.273653 sender=:1.0 -> destination=:1.176 serial=2677 reply_serial=2
   variant       string "x86-64"

busctl

$ busctl --user get-property org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.systemd1.Manager Architecture 
s "x86-64"

妖妓 2025-01-28 13:04:48

dbus-send命令搏斗后,我找到了正确的语法:

dbus-send --session  --print-reply \
 --dest=org.pwmt.zathura.PID-1057698\ 
 /org/pwmt/zathura \
 org.freedesktop.DBus.Properties.Get \
 string:org.pwmt.zathura string:numberofpages

该命令的输出是:

method return time=1650032068.076028 sender=:1.2273 -> destination=:1.2408 serial=79 reply_serial=2
   variant       uint32 46

我可以使用GREP获取值46(在我的案例PDF文档中的页面总数)。

After wrestling with dbus-send command, finally I found the right syntax:

dbus-send --session  --print-reply \
 --dest=org.pwmt.zathura.PID-1057698\ 
 /org/pwmt/zathura \
 org.freedesktop.DBus.Properties.Get \
 string:org.pwmt.zathura string:numberofpages

The output of that command is:

method return time=1650032068.076028 sender=:1.2273 -> destination=:1.2408 serial=79 reply_serial=2
   variant       uint32 46

I can use grep to get the value 46 (which is in my case the total number of pages in the PDF document).

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