AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[d-bus](unix)

Martin Hope
Damn Vegetables
Asked: 2024-06-09 21:42:55 +0800 CST

为 org.freedesktop.FileManager1.ShowItems 设置特定的文件管理器

  • 6

以下命令打开文件管理器来显示目录。

dbus-send --session --dest=org.freedesktop.FileManager1 --print-reply \
 --type=method_call /org/freedesktop/FileManager1 \
 org.freedesktop.FileManager1.ShowItems array:string:"file:///path/to/your/directory" string:""

问题是默认文件管理器似乎是随机的。我猜是上次更新的文件管理器,因为它在文件管理器更新后发生了变化。此外,当文件管理器已在运行时,它会使用该文件管理器。

不用让别人dbus-send确定使用哪个文件管理器,如果我知道安装了哪些文件管理器,我可以设置一个特定的文件管理器,比如 Nemo 吗?

d-bus
  • 1 个回答
  • 32 Views
Martin Hope
Damn Vegetables
Asked: 2023-04-27 23:26:54 +0800 CST

设置默认文件管理器并使用默认文件管理器定位文件

  • 5

在阅读我的问题之前,请不要将其标记为重复。我知道已经有这些问题了,但是现有的答案没有按预期工作,这就是我问这个问题的原因。

已有答案说设置默认文件管理器的方法是xdg-mime default <app name> inode/directory,使用默认文件管理器定位文件的方法是dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"<path>" string:""。

但是,当我在一些基于 Arch 的发行版(包括 Arch with Gnome)上对此进行测试时,在安装 Nemo 文件管理器(Gnome 的默认文件管理器是 Gnome Files)之后,该dbus-send命令并不总是打开指示的文件管理器。xdg-mime query default在xdg-mime query default inode/directory输出的同时nemo.desktop,dbus-send...上面的命令打开了 Gnome Files,当前者输出“org.gnome.Nautilus.desktop”时,后者打开了 Nemo。(这是没有正在运行的文件管理器的情况。如果已经有文件管理器的实例,dbus-send命令似乎使用该文件管理器。)

dbus-send上面的命令是“使用默认文件管理器定位文件”的正确命令吗?虽然dbus-send上述命令没有按预期工作,但 JetBrain 的 IDE(如 Android Studio 或 IntellJ)使用默认文件管理器正确定位了文件,当我右键单击一个文件,然后单击“打开方式”,然后单击文件管理器的名称时。我想查看他们的源代码,但这些都是巨大的应用程序,尝试搜索他们的源代码没有返回任何结果(我使用了“打开方式”或“文件管理器”等关键字)。

d-bus
  • 1 个回答
  • 22 Views
Martin Hope
simonzack
Asked: 2021-12-02 01:09:12 +0800 CST

从网络浏览器中运行我想要的文件管理器

  • 2

我想在我的浏览器中运行Nemo而不是Xfce的默认文件浏览器。

在 Linux 上从 Firefox 运行正确文件管理器的Per Clean 方法我尝试做:

$ mkdir --parents ~/.local/share/dbus-1/services/
$ ln --symbolic /usr/share/dbus-1/services/nemo.FileManager1.service ~/.local/share/dbus-1/services/org.freedesktop.FileManager1.service

为了测试打开哪个文件管理器,我运行了:

$ dbus-send --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"file:///home/" string:""

然后我重新启动,但没有任何改变。我什至复制了一些服务文件并更新了它们的Name字段:

  • /usr/share/dbus-1/services/org.xfce.FileManager.service
  • /usr/share/dbus-1/services/org.xfce.Thunar.FileManager1.service

同样没有任何变化,Thunar仍然打开。似乎我的设置完全被忽略了。

关于发生了什么的任何想法,或者我该如何调试这个问题?

linux d-bus
  • 1 个回答
  • 213 Views
Martin Hope
user1929074
Asked: 2021-11-14 18:08:44 +0800 CST

每次匹配正则表达式时运行命令,从没有 EOF 的标准输入读取

  • 6

我正在尝试编写一个 BASH 脚本,该脚本每次在 dbus-monitor 的输出中找到某个字符串(稍后在帖子中指定的参数)时创建一个时间戳(要写入文件)。我的脚本的主要目的是在歌曲开始在 Spotify 上播放时保存时间(包括毫秒)和日期,因为它利用了通知。

string "Spotify"每当播放歌曲时,都会输出以下命令。

dbus-monitor --session interface='org.freedesktop.Notifications',member='Notify' | grep 'string "Spotify"'

我的尝试:

search='string "Spotify"'
found=$(dbus-monitor --session interface='org.freedesktop.Notifications',member='Notify' | grep 'string "Spotify"')

while [ ${search} == ${found} ]; do
    date -u +%Y%M%d-%H%M%S.%N >> timestamp.txt
done

我假设我的代码功能障碍的原因是 dbus-monitor 连续运行,因此阻止了 while 循环执行。

bash d-bus
  • 4 个回答
  • 737 Views
Martin Hope
Matthias Braun
Asked: 2019-08-30 10:04:07 +0800 CST

NameOwnerChanged 事件每秒发送到空目标

  • 0

Running dbus-monitor --system,显示了很多这样的事件:

signal time=1567100862.252579 sender=org.freedesktop.DBus -> destination=(null destination) serial=467227 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
  string ":1.381958"
  string ":1.381958"
  string ""
signal time=1567100863.303822 sender=org.freedesktop.DBus -> destination=(null destination) serial=467228 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
  string ":1.381959"
  string ""
  string ":1.381959"
signal time=1567100863.311397 sender=org.freedesktop.DBus -> destination=(null destination) serial=467229 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
  string ":1.381959"
  string ":1.381959"
  string ""
signal time=1567100863.315985 sender=org.freedesktop.DBus -> destination=(null destination) serial=467230 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
  string ":1.381960"
  string ""
  string ":1.381960"
signal time=1567100863.322069 sender=org.freedesktop.DBus -> destination=(null destination) serial=467231 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
  string ":1.381960"
  string ":1.381960"
  string ""

大约每秒都有一个新事件发生。

我注意到这些事件在调用之前不会发生startx。

我在运行 i3 的 Arch Linux 5.2.9 上。

这是 DBus 使用的某种计时器或心跳吗?

i3 d-bus
  • 2 个回答
  • 446 Views
Martin Hope
unazed spectaculum
Asked: 2019-08-16 12:51:05 +0800 CST

尽管安装了 libnotify,但 `notification-daemon` 完全不存在

  • 0

我在 x86_64 Debian 4.19 over i3-gaps & systemd 上运行;我有兴趣玩 DBus 上的接口,但是在, 和 no下都没有org.freedesktop.Notifications这样的服务/接口/任何东西。/usr/lib/dbus-1.0/usr/lib/notification-daemon/usr/lib/x86_64-linux-gnu/notification-daemon

我尝试libnotify从源代码重新编译(包括 running apt get libnotify-dev)但仍然无济于事,我完全困惑于在哪里可以找到这个守护进程以及如何生成应该在那里的 DBus 服务。

值得注意的是,当我运行时notify-send,确实显示了一个通知框,通过dbus-monitor您可以看到:

method call time=1565902191.045580 sender=:1.130 -> destination=:1.131 serial=7 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
   string "notify-send"
   uint32 0
   string ""
   string "smh"
   string ""
   array [
   ]
   array [
      dict entry(
         string "urgency"
         variant             byte 2
      )
   ]
   int32 -1
method return time=1565902191.046365 sender=:1.131 -> destination=:1.130 serial=4 reply_serial=7
   uint32 2
debian d-bus
  • 1 个回答
  • 329 Views
Martin Hope
Marcus
Asked: 2019-08-07 06:39:04 +0800 CST

服务“org.freedesktop.UDisks2”不存在

  • 0

我正在使用带有 OpenRC 初始化系统的 Debian Sid。我已经安装了最新的 udisks2 (2.8.4),以及 qdbus-qt5。早些时候(在此错误弹出之前未指定时间),我能够使用命令查询org.freedesktop.UDisks2界面。qdbus现在,当我运行命令时,出现以下错误。

$ qdbus org.freedesktop.UDisks2
Service 'org.freedesktop.UDisks2' does not exist.

我已确保它udisksd已启动并正在运行。升级系统后出现此错误。但是,udisksctl status及时显示

MODEL                     REVISION  SERIAL               DEVICE
--------------------------------------------------------------------------
WDC WD10SPZX-00Z10T0      01.01A01  WD-WXP1AB8HPJ11      sda     
TSSTcorp DVD+/-RW SU-208GB D100      S16A6YGGA000GC       sr0     

此外,当我尝试org.freedesktop.UDisks2使用 Qt 程序从内部访问界面时QDBusInterface,我没有收到任何错误。解决此问题的任何帮助都会很棒。

d-bus udisks
  • 1 个回答
  • 326 Views
Martin Hope
einpoklum
Asked: 2019-07-29 05:19:36 +0800 CST

获取 dbind-WARNING 关于注册无障碍总线的信息

  • 19

当我从命令行运行 X 应用程序(例如,leafpad;大多数应用程序)时,我在控制台上收到以下警告:

 ... dbind-WARNING **: ... Couldn't register with accessibility bus: Did
not receive a reply. Possible causes include: the remote application did 
not send a reply, the message bus security policy blocked the reply, the 
reply timeout expired, or the network connection was broken.

(换行以适应列宽。)

为什么我会收到此消息,我该怎么办?发布它的应用程序似乎运行良好。

这出现在 Ubuntu 18.04 和 Devuan 3.0 Beowulf (~= Debian Buster)

accessibility d-bus
  • 1 个回答
  • 10660 Views
Martin Hope
Stewart
Asked: 2019-06-28 06:37:08 +0800 CST

观看 sd-bus 属性

  • 3

我有一个 GUI,可以在其中显示ActiveState几个 systemd 服务。

在 10Hz 时,我使用 sd-bus api 来查询每个服务,如下所示:

sd_bus* bus;
sd_bus_error err = SD_BUS_ERROR_NULL;
char* msg = 0;

sd_bus_default_system(&bus);

sd_bus_get_property_string(bus,
    "org.freedesktop.systemd1",
    "/org/freedesktop/systemd1/unit/foo_2eservice",
    "org.freedesktop.systemd1.Unit",
    "ActiveState",
    &err,
    &msg);

我的问题是,当我运行这段代码时,/sbin/init还是/lib/systemd/systemd-logind消耗了大约 50% 的 CPU。分析代码显示sd_bus_get_property_string. 我需要减少调用此函数的次数。

d-bus接口的自省很有意思:

busctl introspect \
    org.freedesktop.systemd1 \
    /org/freedesktop/systemd1/unit/foo_2eservice \
    org.freedesktop.system1.Unit

NAME                             TYPE      SIGNATURE RESULT/VALUE   FLAGS
.Kill                            method    si        -     -
.Ref                             method    -         -     -
.Reload                          method    s         o     -
.ReloadOrRestart                 method    s         o     -
.ReloadOrTryRestart              method    s         o     -
.ResetFailed                     method    -         -     -
.Restart                         method    s         o     -
.SetProperties                   method    ba(sv)    -     -
.Start                           method    s         o     -
.Stop                            method    s         o     -
.TryRestart                      method    s         o     -
.Unref                           method    -         -     -
.ActiveEnterTimestamp            property  t         0     emits-change
.ActiveEnterTimestampMonotonic   property  t         0     emits-change
.ActiveExitTimestamp             property  t         0     emits-change
.ActiveExitTimestampMonotonic    property  t         0     emits-change
.ActiveState                     property  s         "inactive"   emits-change
...

这告诉我 ActiveState 属性发出了一个 change。

如何获取文件描述符,或点击事件循环以接收该更改?


D-Bus 规范建议 systemd 将在属性更改时发出信号org.freedesktop.DBus.Properties.PropertiesChanged。我想我需要弄清楚如何订阅该信号。

systemd d-bus
  • 2 个回答
  • 3000 Views
Martin Hope
zjeffer
Asked: 2018-11-12 17:07:15 +0800 CST

Plasma-browser-integration 因 `export QT_QPA_PLATFORMTHEME="qt5ct"` 而中断

  • 0

我使用plasma-browser-integration(不使用KDE)来获取firefox网站(如youtube、netflix ..)来响应播放/暂停等mpris命令,并获取播放状态(播放/暂停),以便我可以控制媒体使用我的媒体键,这样我就可以显示当前在 polybar 中播放的内容。

可悲的是,export QT_QPA_PLATFORMTHEME="qt5ct"在 my.xinitrc中,控制浏览器的 dbus 服务org.mpris.MediaPlayer2.plasma-browser-integration无法加载。

我需要那个环境变量,因为当我没有设置它时,像 VLC 这样的 qt 应用程序看起来很糟糕。

kde d-bus
  • 2 个回答
  • 565 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve