Xfce Forum

Sub domains
 

You are not logged in.

#1 2023-10-24 14:38:16

conta
Member
Registered: 2023-10-22
Posts: 2

[SOLVED] How to detect Do not Disturb via DBUS?

Hi there,

for my open-source app, I am trying to detect when my users are in DND to not disturb them. I have this working for KDE and trying to do for XFCE now.

I am in node, so using some dbus library, and would like to do the same for XFCE. I was not able to find where to look for XFCE value so I asked AIs, but no seems to work.

    try {
      const obj = await bus.getProxyObject('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
      const properties = obj.getInterface('org.freedesktop.DBus.Properties')
      const dndEnabled = await properties.Get('org.freedesktop.Notifications', 'Inhibited')
      if (await dndEnabled.value) {
        return true
      }
    } catch (e) {
      // KDE is not running
    }

    try {
      const obj = await bus.getProxyObject('org.xfce.settings.DoNotDisturb', '/org/xfce/settings/DoNotDisturb')
      const properties = obj.getInterface('org.freedesktop.DBus.Properties')
      const dndEnabled = await properties.Get('org.xfce.settings.DoNotDisturb', 'Enabled')
      if (await dndEnabled.value) {
        return true
      }
    } catch (e) {
      // XFCE is not running
    }

Any ideas welcome smile

Last edited by conta (2023-10-27 06:29:14)

Offline

#2 2023-10-24 19:45:30

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,485

Re: [SOLVED] How to detect Do not Disturb via DBUS?

Hello and welcome.

Xfce uses xfconf to manage settings, so you could use the Xfconf interface on the session bus to query the value of "/do-not-disturb" in the "xfce4-notifyd" channel. Here is what d-feet says about the method:

dnd.png


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2023-10-27 06:28:33

conta
Member
Registered: 2023-10-22
Posts: 2

Re: [SOLVED] How to detect Do not Disturb via DBUS?

Many thanks!

Here's the updated code that works:

    try {
      const obj = await bus.getProxyObject('org.xfce.Xfconf', '/org/xfce/Xfconf')
      const properties = obj.getInterface('org.xfce.Xfconf')
      const dndEnabled = await properties.GetProperty('xfce4-notifyd', '/do-not-disturb')
      if (await dndEnabled.value) {
        return true
      }
    } catch (e) {
      // XFCE is not running
    }

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.011 seconds, 7 queries executed - Memory usage: 520.63 KiB (Peak: 521.48 KiB) ]