elementary / default-settings

Default settings for elementary OS
GNU General Public License v3.0
39 stars 28 forks source link

AccountsService: Change PrefersColorScheme to enum #166

Closed cassidyjames closed 4 years ago

cassidyjames commented 4 years ago

From https://dbus.freedesktop.org/doc/dbus-api-design.html:

In particular, sending structured strings over D-Bus should be avoided, as they need to be built and parsed; both are complex operations which are prone to bugs. For APIs being used in constrained situations, enumerated values should be transmitted as unsigned integers.

It sounds like it is expected to be implemented as an enum on the client side and then just send the int over DBus. In this case we would use:

WhyNotHugo commented 3 years ago

Hi! I'm a non-elementaryOS user but asking here in the interest of cross-desktop compatibility (I ended up here through this thread).

I'm patching my system and different tools to automatically switch to a darker theme at sundown, and figuring out what each application supports, etc.

I'd love to see a cross-desktop API where applications of any desktop can figure out if they should use night mode right now or not (and possible get signalled if this should change). You guys are the first to implement an API to do this, and I think the design makes sense. I honestly see no reason not to adopt it elsewhere.

As it is right now, I would like to create a tiny service that just exposes the io.elementary.pantheon.AccountsService D-Bus interface, but just exposes the PrefersColorScheme property. This mimics what your elementary-specific service is doing (am I right so far?). My service would not really work on elementary, but that's not a problem, this is just for other environments.

I am correct in that this is a D-Bus interface, right? (the naming convention seems to be that).

Would it also make sense to expose a ColorSchemeChanged signal for application to also listen to property changes?

Thanks!

danirabbit commented 3 years ago

@WhyNotHugo Hey I'm glad to hear you're interested in porting this to other desktops. You may find the discussion here relevant: https://github.com/elementary/settings-daemon/issues/16

AccountsService does expose this information over DBus yes, but for sandboxing purposes it sounds like it would be better to use a different namespace. The current proposal is to provide org.freedesktop.prefers-color-scheme. So I would recommend you use that namespace for your interface and we'll follow shortly :)

If you wanted to add more discussion to that linked issue report that would be great since that's where we're currently tracking this change proposal