From 18b967a3853441917a6c75e925820febc9c14f56 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 20 Mar 2024 02:53:07 +0100 Subject: [PATCH] feat(appearance): set preferred icon theme for GNOME/GTK applications --- app/src/pages/desktop/appearance.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/src/pages/desktop/appearance.rs b/app/src/pages/desktop/appearance.rs index e507bbe..ca833da 100644 --- a/app/src/pages/desktop/appearance.rs +++ b/app/src/pages/desktop/appearance.rs @@ -6,7 +6,6 @@ use std::collections::BTreeSet; use std::path::{Path, PathBuf}; use std::sync::Arc; -use apply::Apply; use ashpd::desktop::file_chooser::{FileFilter, SelectedFiles}; use cosmic::config::CosmicTk; use cosmic::cosmic_config::{Config, ConfigSet, CosmicConfigEntry}; @@ -23,6 +22,7 @@ use cosmic::widget::{ button, color_picker::ColorPickerUpdate, container, horizontal_space, row, settings, spin_button, text, ColorPickerModel, }; +use cosmic::Apply; use cosmic::{command, Command, Element}; use cosmic_settings_page::Section; use cosmic_settings_page::{self as page, section}; @@ -55,7 +55,6 @@ enum ContextView { InterfaceText, } -// TODO integrate with settings backend pub struct Page { can_reset: bool, no_custom_window_hint: bool, @@ -473,12 +472,25 @@ impl Page { Command::none() } Message::IconTheme(id) => { - if let Some(theme) = self.icon_themes.get(id) { + if let Some(theme) = self.icon_themes.get(id).cloned() { self.icon_theme_active = Some(id); self.tk.icon_theme = theme.clone(); + if let Some(ref config) = self.tk_config { let _ = self.tk.write_entry(config); } + + tokio::spawn(async move { + let _res = tokio::process::Command::new("gsettings") + .args(&[ + "set", + "org.gnome.desktop.interface", + "icon-theme", + theme.as_str(), + ]) + .status() + .await; + }); } Command::none()