feat: add desktop entries for each settings page

This commit is contained in:
Michael Aaron Murphy 2024-03-22 15:44:04 +01:00 • committed by Michael Murphy
parent a40b1e9a1a
commit 1c61885428
65 changed files with 294 additions and 37 deletions

View file

@ -1,6 +1,6 @@
[workspace] [workspace]
members = ["app", "page", "pages/*"] members = ["cosmic-settings", "page", "pages/*"]
default-members = ["app"] default-members = ["cosmic-settings"]
resolver = "2" resolver = "2"
rust-version = "1.71.0" rust-version = "1.71.0"

View file

@ -12,7 +12,7 @@ use crate::pages::desktop::{
}, },
}; };
use crate::pages::input::{self, keyboard}; use crate::pages::input::{self, keyboard};
use crate::pages::{self, display, sound, system, time}; use crate::pages::{self, display, networking, sound, system, time};
use crate::subscription::desktop_files; use crate::subscription::desktop_files;
use crate::widget::{page_title, search_header}; use crate::widget::{page_title, search_header};
use crate::PageCommands; use crate::PageCommands;
@ -53,13 +53,25 @@ pub struct SettingsApp {
impl SettingsApp { impl SettingsApp {
fn subcommand_to_page(&self, cmd: &PageCommands) -> Option<Entity> { fn subcommand_to_page(&self, cmd: &PageCommands) -> Option<Entity> {
match cmd { match cmd {
// PageCommands::Bluetooth => self.pages.page_id::<system::bluetooth::Page>(), PageCommands::About => self.pages.page_id::<system::about::Page>(),
// PageCommands::Network => self.pages.page_id::<system::network::Page>(), PageCommands::Appearance => self.pages.page_id::<desktop::appearance::Page>(),
// PageCommands::Notifications => self.pages.page_id::<notifications::Page>(), PageCommands::Bluetooth => None,
// PageCommands::Power => self.pages.page_id::<system::power::Page>(), PageCommands::DateTime => self.pages.page_id::<time::date::Page>(),
PageCommands::DesktopPanel => self.pages.page_id::<desktop::options::Page>(),
PageCommands::Displays => self.pages.page_id::<display::Page>(),
PageCommands::Firmware => self.pages.page_id::<system::firmware::Page>(),
PageCommands::Keyboard => self.pages.page_id::<input::keyboard::Page>(),
PageCommands::Mouse => self.pages.page_id::<input::mouse::Page>(),
PageCommands::Network => None,
PageCommands::Notifications => self.pages.page_id::<desktop::notifications::Page>(),
PageCommands::Power => None,
PageCommands::RegionLanguage => self.pages.page_id::<time::region::Page>(),
PageCommands::Sound => self.pages.page_id::<sound::Page>(), PageCommands::Sound => self.pages.page_id::<sound::Page>(),
PageCommands::Time => self.pages.page_id::<time::Page>(), PageCommands::Time => self.pages.page_id::<time::Page>(),
_ => None, PageCommands::Touchpad => self.pages.page_id::<input::touchpad::Page>(),
PageCommands::Users => self.pages.page_id::<system::users::Page>(),
PageCommands::Wallpaper => self.pages.page_id::<desktop::wallpaper::Page>(),
PageCommands::Workspaces => self.pages.page_id::<desktop::workspaces::Page>(),
} }
} }
} }

View file

@ -37,18 +37,44 @@ pub struct Args {
#[derive(Subcommand, Debug, Serialize, Deserialize, Clone)] #[derive(Subcommand, Debug, Serialize, Deserialize, Clone)]
pub enum PageCommands { pub enum PageCommands {
/// Open the settings bluetooth page /// About settings page
About,
/// Appearance settings page
Appearance,
/// Bluetooth settings page
Bluetooth, Bluetooth,
/// Open the settings network page /// DateTime settings page
DateTime,
/// Desktop and panel settings page
DesktopPanel,
/// Displays settings page
Displays,
/// Firmware settings page
Firmware,
/// Keyboard settings page
Keyboard,
/// Mouse settings page
Mouse,
/// Network settings page
Network, Network,
/// Open the settings notifications page /// Notifications settings page
Notifications, Notifications,
/// Open the settings power page /// Power settings page
Power, Power,
/// Open the settings sound page /// Region & Language settings page
RegionLanguage,
/// Sound settings page
Sound, Sound,
/// Open the settings time page /// Time settings page
Time, Time,
/// Touchpad settings page
Touchpad,
/// Users settings page
Users,
/// Wallpaper settings page
Wallpaper,
/// Workspaces settings page
Workspaces,
} }
impl FromStr for PageCommands { impl FromStr for PageCommands {

View file

@ -480,17 +480,7 @@ impl Page {
let _ = self.tk.write_entry(config); let _ = self.tk.write_entry(config);
} }
tokio::spawn(async move { tokio::spawn(set_gnome_icon_theme(theme));
let _res = tokio::process::Command::new("gsettings")
.args(&[
"set",
"org.gnome.desktop.interface",
"icon-theme",
theme.as_str(),
])
.status()
.await;
});
} }
Command::none() Command::none()
@ -1500,6 +1490,7 @@ pub fn color_button<'a, Message: 'a + Clone>(
.into() .into()
} }
/// Find all icon themes available on the system.
async fn fetch_icon_themes() -> Message { async fn fetch_icon_themes() -> Message {
let mut icon_themes = BTreeSet::new(); let mut icon_themes = BTreeSet::new();
@ -1576,3 +1567,16 @@ async fn fetch_icon_themes() -> Message {
Message::Entered(icon_themes.into_iter().collect()) Message::Entered(icon_themes.into_iter().collect())
} }
/// Set the preferred icon theme for GNOME/GTK applications.
async fn set_gnome_icon_theme(theme: String) {
let _res = tokio::process::Command::new("gsettings")
.args(&[
"set",
"org.gnome.desktop.interface",
"icon-theme",
theme.as_str(),
])
.status()
.await;
}

View file

@ -17,8 +17,8 @@ use itertools::Itertools;
use tracing::error; use tracing::error;
pub mod keyboard; pub mod keyboard;
mod mouse; pub mod mouse;
mod touchpad; pub mod touchpad;
crate::cache_dynamic_lazy! { crate::cache_dynamic_lazy! {
static ACCELERATION_DESC: String = fl!("acceleration-desc"); static ACCELERATION_DESC: String = fl!("acceleration-desc");

View file

@ -8,33 +8,83 @@ appid := 'com.system76.CosmicSettings'
rootdir := '' rootdir := ''
prefix := '/usr' prefix := '/usr'
appdir := clean(rootdir / prefix) / 'share' / 'applications'
default-schema-target := clean(rootdir / prefix) / 'share' / 'cosmic' default-schema-target := clean(rootdir / prefix) / 'share' / 'cosmic'
bin-src := cargo-target-dir / 'release' / name bin-src := cargo-target-dir / 'release' / name
bin-dest := clean(rootdir / prefix) / 'bin' / name bin-dest := clean(rootdir / prefix) / 'bin' / name
desktop := appid + '.desktop'
desktop-src := 'resources' / desktop
desktop-dest := clean(rootdir / prefix) / 'share' / 'applications' / desktop
iconsdir := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor' iconsdir := clean(rootdir / prefix) / 'share' / 'icons' / 'hicolor'
metainfo := appid + '.metainfo.xml' metainfo := appid + '.metainfo.xml'
metainfo-src := 'resources' / metainfo metainfo-src := 'resources' / metainfo
metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo metainfo-dst := clean(rootdir / prefix) / 'share' / 'metainfo' / metainfo
# Desktop entries
entry-settings := appid + '.desktop'
entry-about := appid + '.About.desktop'
entry-appear := appid + '.Appearance.desktop'
entry-date-time := appid + '.DateTime.desktop'
entry-desktop := appid + '.Desktop.desktop'
entry-displays := appid + '.Displays.desktop'
entry-firmware := appid + '.Firmware.desktop'
entry-keyboard := appid + '.Keyboard.desktop'
entry-mouse := appid + '.Mouse.desktop'
entry-notifications := appid + '.Notifications.desktop'
entry-region-language := appid + '.RegionLanguage.desktop'
entry-sound := appid + '.Sound.desktop'
entry-touchpad := appid + '.Touchpad.desktop'
entry-users := appid + '.Users.desktop'
entry-wallpaper := appid + '.Wallpaper.desktop'
entry-workspaces := appid + '.Workspaces.desktop'
# Build recipes # Build recipes
[private] [private]
default: build-release default: build-release
[private]
install-desktop-entries:
install -Dm0644 'resources/{{entry-settings}}' '{{appdir}}/{{entry-settings}}'
install -Dm0644 'resources/{{entry-about}}' '{{appdir}}/{{entry-about}}'
install -Dm0644 'resources/{{entry-appear}}' '{{appdir}}/{{entry-appear}}'
install -Dm0644 'resources/{{entry-date-time}}' '{{appdir}}/{{entry-date-time}}'
install -Dm0644 'resources/{{entry-desktop}}' '{{appdir}}/{{entry-desktop}}'
install -Dm0644 'resources/{{entry-displays}}' '{{appdir}}/{{entry-displays}}'
install -Dm0644 'resources/{{entry-firmware}}' '{{appdir}}/{{entry-firmware}}'
install -Dm0644 'resources/{{entry-keyboard}}' '{{appdir}}/{{entry-keyboard}}'
install -Dm0644 'resources/{{entry-mouse}}' '{{appdir}}/{{entry-mouse}}'
install -Dm0644 'resources/{{entry-notifications}}' '{{appdir}}/{{entry-notifications}}'
install -Dm0644 'resources/{{entry-region-language}}' '{{appdir}}/{{entry-region-language}}'
install -Dm0644 'resources/{{entry-sound}}' '{{appdir}}/{{entry-sound}}'
install -Dm0644 'resources/{{entry-touchpad}}' '{{appdir}}/{{entry-touchpad}}'
install -Dm0644 'resources/{{entry-users}}' '{{appdir}}/{{entry-users}}'
install -Dm0644 'resources/{{entry-wallpaper}}' '{{appdir}}/{{entry-wallpaper}}'
install -Dm0644 'resources/{{entry-workspaces}}' '{{appdir}}/{{entry-workspaces}}'
# Install everything # Install everything
install: (install-bin bin-src bin-dest) (install-file desktop-src desktop-dest) (install-file metainfo-src metainfo-dst) install: install-desktop-entries (install-bin bin-src bin-dest) (install-file metainfo-src metainfo-dst)
find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'default_schema'/{} {{default-schema-target}}/{} find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'default_schema'/{} {{default-schema-target}}/{}
find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'icons'/{} {{iconsdir}}/{} find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} install -Dm0644 'resources'/'icons'/{} {{iconsdir}}/{}
# Uninstalls everything (requires same arguments as given to install) # Uninstalls everything (requires same arguments as given to install)
uninstall: uninstall:
rm -rf {{bin-dest}} {{desktop-dest}} rm -rf {{bin-dest}} \
'{{appdir}}/{{entry-settings}}' \
'{{appdir}}/{{entry-about}}' \
'{{appdir}}/{{entry-appear}}' \
'{{appdir}}/{{entry-date-time}}' \
'{{appdir}}/{{entry-desktop}}' \
'{{appdir}}/{{entry-displays}}' \
'{{appdir}}/{{entry-firmware}}' \
'{{appdir}}/{{entry-keyboard}}' \
'{{appdir}}/{{entry-mouse}}' \
'{{appdir}}/{{entry-notifications}}' \
'{{appdir}}/{{entry-region-language}}' \
'{{appdir}}/{{entry-sound}}' \
'{{appdir}}/{{entry-touchpad}}' \
'{{appdir}}/{{entry-users}}' \
'{{appdir}}/{{entry-wallpaper}}' \
'{{appdir}}/{{entry-workspaces}}'
find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm -rf {{default-schema-target}}/{} find 'resources'/'default_schema' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm -rf {{default-schema-target}}/{}
find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm {{iconsdir}}/{} find 'resources'/'icons' -type f -exec echo {} \; | rev | cut -d'/' -f-3 | rev | xargs -d '\n' -I {} rm {{iconsdir}}/{}

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=About
Comment=Device name, hardware information, operating system defaults.
Type=Settings
Exec=cosmic-settings about
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Appearance
Comment=Accent colors and COSMIC theming.
Type=Settings
Exec=cosmic-settings appearance
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Date & Time
Comment=Time zone, automatic clock settings, and time formatting.
Type=Settings
Exec=cosmic-settings date-time
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Desktop and Panel
Comment=Super key action, hot corners, and window control options
Type=Settings
Exec=cosmic-settings desktop-panel
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Displays
Comment=Display options, graphics modes, and night light.
Type=Settings
Exec=cosmic-settings displays
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Firmware
Comment=View and update firmware.
Type=Settings
Exec=cosmic-settings firmware
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Keyboard
Comment=Keyboard input settings.
Type=Settings
Exec=cosmic-settings keyboard
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Mouse
Comment=Mouse speed, acceleation, and natural scrolling.
Type=Settings
Exec=cosmic-settings mouse
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Notifications
Comment=Do Not Disturb, lockscreen notifications, and per-application settings.
Type=Settings
Exec=cosmic-settings notifications
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Region & Language
Comment=Format dates, times, and numbers based on your region.
Type=Settings
Exec=cosmic-settings region-language
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Sound
Comment=Audio settings for devices, alerts, and applications.
Type=Settings
Exec=cosmic-settings sound
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Touchpad
Comment=Touchpad speed, click options, gestures.
Type=Settings
Exec=cosmic-settings touchpad
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Users
Comment=Authentication and login, lock screen.
Type=Settings
Exec=cosmic-settings users
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Wallpaper
Comment=Wallpaper images, colors, and slideshow options.
Type=Settings
Exec=cosmic-settings wallpaper
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -0,0 +1,11 @@
[Desktop Entry]
Name=Workspaces
Comment=Set workspace number, behavior, and placement.
Type=Settings
Exec=cosmic-settings workspaces
Terminal=false
Categories=COSMIC
Keywords=COSMIC
OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings
StartupNotify=true

View file

@ -1,10 +1,10 @@
[Desktop Entry] [Desktop Entry]
Name=COSMIC Settings Name=COSMIC Settings
Type=Application Type=Settings
Exec=cosmic-settings Exec=cosmic-settings
Terminal=false Terminal=false
Categories=GNOME;GTK; Categories=COSMIC
Keywords=Gnome;GTK; Keywords=COSMIC
OnlyShowIn=GNOME;Unity;COSMIC OnlyShowIn=COSMIC
Icon=com.system76.CosmicSettings Icon=com.system76.CosmicSettings
StartupNotify=true StartupNotify=true