Reading dbus properties does not work on snap but works on native

hi there… it seems that I’m not able to access dbus using snap. I should be able to read the
org.gnome.SettingsDaemon.Color NightLightActive
properties to understand if the user is running night light or not.
my code works on native app and on flatpak but not on snap.

Is there some limitations on snap on this?

I have tried adding this to my snapcraft.yaml

slots: 
  dbus-gnome-nightlight:
    interface: dbus
    bus: session
    name: org.gnome.SettingsDaemon.Color

app:
    slots: [ dbus-gnome-nightlight ]
    plugs:
      - dbus-gnome-nightlight

I then tried this

plugs: 
  dbus-gnome-nightlight:
    interface: dbus
    bus: session
    name: org.gnome.SettingsDaemon.Color

app:
    plugs:
      - dbus-gnome-nightlight

but it still not work. what am I doing wrong?

I get this error when I try to read that dbus properties:
[Instance #1] 09:28:24.519 [pool-21-thread-1] ERROR org.dpsoftware.NativeExecutor - An AppArmor policy prevents this sender from sending this message to this recipient;
type=“method_call”, sender=“:1.696” (uid=1000 pid=211607 comm=“/snap/fireflyluciferin/x1/bin/FireflyLuciferin” label=“snap.fireflyluciferin.fireflyluciferin (enforce)”) interface=“org.freedesktop.DBus.Properties” member=“Get” error name=“(unset)” requested_reply=“0” destination=“org.gnome.SettingsDaemon.Color” (uid=1000 pid=40480 comm=“/usr/libexec/gsd-color” label=“unconfined”)

Have you connected the interface? Snap interfaces need to be connected before the snap can use them.

https://snapcraft.io/docs/interface-management

thanks for the answer @alan_g .

can you tell me what plug I need and what slot I need to be able to use DBUS and read this properties on host org.gnome.SettingsDaemon.Color please?

I’m really struggling to understand what slot and what plug I need in the snapcraft.yaml before thinking in connecting the interfaces :slight_smile:

any help would be much appreciated :slight_smile:

AFAICT none at this time. Snapd interfaces need to be updated to make it possible.

Since nobody has asked for this particular DBus access rule before, I would suggest to try installing in --devmode first. Collect all denials and post them here. Only then we’ll see which ones need to be added to snapd.

hi thanks @mborzecki1 for the answer, I appreciate it. :slight_smile:

to read the night light status on the host I would need this paths:
this is for gnome:
org.gnome.SettingsDaemon.Color
and this for KDE:
org.kde.KWin.NightLight

What do you mean for collect all denials? If I install it in devmode it works with no denials.

That’s just unfortunate phrasing (there are logs for the suppressed denials). Have a look here:

Specifically under " Debugging policy violation logs"

1 Like

Thank you alan :slight_smile: it’s my fault, I’m a noob on the snap ecosystem.

@mborzecki1 as per your suggestion, here the output of the snappy-debug.

This is when running gnome:

sudo snappy-debug INFO: Following ‘/var/log/syslog’. If have dropped messages, use: INFO: $ sudo journalctl --output=short --follow --all | sudo snappy-debug kernel.printk_ratelimit = 0 = AppArmor = Time: 2025-02-07T21:3 Log: apparmor=“DENIED” operation=“dbus_method_call” bus=“session” path=“/org/gnome/SettingsDaemon/Color” interface=“org.freedesktop.DBus.Properties” member=“Get” mask=“send” name=“org.gnome.SettingsDaemon.Color” pid=51257 label=“snap.fireflyluciferin.fireflyluciferin” peer_pid=4596 peer_label=“unconfined”] DBus access

that’s it, I have only this denial.

When using KDE, night light settings can be read on a different dbus path, this one:
org.kde.KWin.NightLight
but weirdly that path works without any app armour error.

I don’t know if it can help, but this is my current snapcraft.yaml

please let me know if you need other infos.
if not, what are the next steps? can you “open this plug” in snap? how long it will take? a week? 6 months? two years?
thanks!

I also tried the kde one, that didn’t work too in my machine and this is expected as it’s not implemented.

@zyga I believe this is a good candidate for the desktop plug. Or something like screen-inhibit-control be created. WDYT?

I tried to implement the apparmor rule with this, but didn’t work

dbus (send)
    bus=session
    interface=org.freedesktop.DBus.Properties
    member={Get,GetAll,Set}
    path=/org/kde/KWin/NightLight
    peer=(label=unconfined),

@mborzecki1 any news on this? do you need other infos to proceed?

No, not yet, I’m neck deep in other things right now. Though, I agree with @soumyaDghosh that it’s probably best to tweak the desktop interface. If any of you want to give it a go, I’ll happily review the PR to snapd.

@soumyaDghosh have you tried implementing this org.gnome.SettingsDaemon.Color? does it work?

Hii, Sorry but no. I am not a Canonical employee. And also I am having some of own problems to deal with for some days. You might skip the snap for some days.

1 Like