-
-
Notifications
You must be signed in to change notification settings - Fork 817
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x11/wayland: use xdg desktop portal settings interface to get dark mode
There are some other settings in there that could also help with things like the cursor theme on Wayland. Note that we don't currently subscribe to the settings changed signal: that can be done in a follow up. refs: #2258 refs: #1742
- Loading branch information
Showing
7 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#![cfg(all(unix, not(target_os = "macos")))] | ||
|
||
//! <https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.Settings.xml> | ||
use anyhow::Context; | ||
use std::collections::HashMap; | ||
use zbus::dbus_proxy; | ||
use zvariant::OwnedValue; | ||
|
||
#[dbus_proxy( | ||
interface = "org.freedesktop.portal.Settings", | ||
default_service = "org.freedesktop.portal.Desktop", | ||
default_path = "/org/freedesktop/portal/desktop" | ||
)] | ||
trait PortalSettings { | ||
fn ReadAll( | ||
&self, | ||
namespaces: &[&str], | ||
) -> zbus::Result<HashMap<String, HashMap<String, OwnedValue>>>; | ||
|
||
fn Read(&self, namespace: &str, key: &str) -> zbus::Result<OwnedValue>; | ||
|
||
#[dbus_proxy(signal)] | ||
fn SettingChanged(&self, namespace: &str, key: &str, value: OwnedValue) -> Result<()>; | ||
} | ||
|
||
pub async fn read_setting(namespace: &str, key: &str) -> anyhow::Result<OwnedValue> { | ||
let connection = zbus::ConnectionBuilder::session()?.build().await?; | ||
let proxy = PortalSettingsProxy::new(&connection) | ||
.await | ||
.context("make proxy")?; | ||
proxy.Read(namespace, key).await.context("Read") | ||
} |