diff --git a/CHANGELOG.md b/CHANGELOG.md index ea54358..ab6b885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,15 @@ +### 1.0.5: + • Config loaded at startup + • Theme applied from config + • Fixed inconsistency in app limits and metadata by @1peter10 + • Updated Czech translation by @lorduskordus ### 1.0.4: • Add ashpd for Flatpak theming support • Updated app metadata + • Czech translation by @lorduskordus ### 1.0.3: - Fixes a bug in Verify option + • Fixes a bug in Verify option + • First Flathub release ### 1.0.2: • Fixes Verify being active for unenrolled fingers • Add cargo-source.json for Flathub diff --git a/Cargo.lock b/Cargo.lock index 51ac625..1604768 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1009,7 +1009,7 @@ dependencies = [ [[package]] name = "cosmic-utils-enroll" -version = "1.0.4" +version = "1.0.5" dependencies = [ "ashpd 0.13.8", "futures-util", diff --git a/Cargo.toml b/Cargo.toml index 8dae9e0..bbfb853 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cosmic-utils-enroll" -version = "1.0.4" +version = "1.0.5" edition = "2024" license = "MPL-2.0" description = "GUI for fprintd fingerprint enrolling" diff --git a/README.md b/README.md index fd70ee8..eab9e56 100644 --- a/README.md +++ b/README.md @@ -4,23 +4,34 @@ GUI application for fingerprint management. Designed for COSMIC DE. ## Prerequisites -You're using Linux or freedesktop compatible system with a supported fingerprint scanner. +You're using Linux or freedesktop compatible system with a supported fingerprint scanner. You also need [fprintd][fprintd] running. -Tested only with COSMIC™ DE, Pop!_OS, Framework 13 laptop with a Goodix MOC Fingerprint Sensor. +Tested with: +| Distribution | Desktop | Architecture | Fingerprint scanner | +| ------------ | ------- | ------------ | ------------------- | +| Pop!_OS | COSMIC™ DE | amd64 | Goodix MOC Fingerprint Sensor | +| Arch Linux | KDE Plasma | arm64 | No fingerprint scanner | ## Usage -On a multiuser system you can choose user from navigation. It asks for authentication and checks correct rights if you choose user other than current session. +On a multiuser system you can choose user from navigation. It asks for authentication and checks correct rights if you choose user other than the user of current session. -Click the action you want to take. Different kind of authentication and rights check is performed. If something goes wrong status is shown. Otherwise you'll get a progress indicator. If you don't have correct rights or incorrect password your attempt will be dismissed. +Select the finger and action to take. Authentication and user rights check are performed for security. If anything goes wrong the status is displayed in the center. When registering a progress bar reflecting progress is shown. Follow instructions. + +If you don't have correct rights or incorrect password your attempt is just dismissed. ## Installation -Download the .flatpak from latest release or build; +### Flathub +Get it on Flathub +### Build from source [justfile](./justfile) is included by default for the [casey/just][just] command runner. - `just` builds the application with the default `just build-release` recipe - `just run` builds and runs the application - `just install` installs the project into the system + +[just]: https://github.com/ +[fprintd]: https://gitlab.freedesktop.org/libfprint/fprintd diff --git a/i18n/cs/cosmic_utils_enroll.ftl b/i18n/cs/cosmic_utils_enroll.ftl index 8a5c83b..582f768 100644 --- a/i18n/cs/cosmic_utils_enroll.ftl +++ b/i18n/cs/cosmic_utils_enroll.ftl @@ -5,11 +5,10 @@ view = Zobrazení fprint = Registrovat welcome = Registrujte nebo smažte otisky prstů git-description = Git commit {$hash} dne {$date} -alternative-ui = Alternativní UI - register = Registrovat verify = Ověřit delete = Smazat +danger = Varování success = Hotovo. Nyní zaregistrujte otisk. deleted = Otisk byl smazán. deleting = Mazání otisku... @@ -21,7 +20,13 @@ clear-device-confirm = Opravdu chcete vymazat otisky pro VŠECHNY známé uživa cancel = Zrušit settings-ui = Uživatelské rozhraní +alternative-ui = Alternativní UI settings-clear-device = Odstranit všechny otisky +settings-theme = Motiv + +theme-system = Podle systému +theme-light = Světlý +theme-dark = Tmavý register-tooltip = Zaregistruje nový otisk prstu delete-tooltip = Smaže tento otisk prstu diff --git a/i18n/en/cosmic_utils_enroll.ftl b/i18n/en/cosmic_utils_enroll.ftl index 21b47e1..204bf37 100644 --- a/i18n/en/cosmic_utils_enroll.ftl +++ b/i18n/en/cosmic_utils_enroll.ftl @@ -8,6 +8,8 @@ git-description = Git commit {$hash} on {$date} register = Register verify = Verify delete = Delete +danger = Danger +cancel = Cancel success = Success. Now go register a print. deleted = Deleted fingerprint. deleting = Deleting fingerprint... @@ -16,7 +18,6 @@ confirm-clear = Are you sure? clearing-device = Clearing all fingerprints from device for all known users... device-cleared = Device cleared for all known users. clear-device-confirm = Are you sure you want to clear fingerprints for ALL known users? -cancel = Cancel settings-ui = User Interface alternative-ui = Alternative UI diff --git a/i18n/fi/cosmic_utils_enroll.ftl b/i18n/fi/cosmic_utils_enroll.ftl index b524b71..36bb629 100644 --- a/i18n/fi/cosmic_utils_enroll.ftl +++ b/i18n/fi/cosmic_utils_enroll.ftl @@ -5,10 +5,12 @@ view = Katso fprint = Rekisteröi sormenjälki welcome = Rekisteröi tai poista sormenjälkiä git-description = Git julkaisu {$hash} päivänä {$date} -alternative-ui = Toinen käyttöliittymä - register = Rekisteröi +verify = Varmenna delete = Poista +danger = Vaara +cancel = Peruuta +success = Onnistui deleted = Sormenjälki poistettu. deleting = Poistetaan sormenjälkeä... clear-device = Tyhjennä laite @@ -16,7 +18,31 @@ confirm-clear = Oletko varma? clearing-device = Tyhjennetään laitteen kaikki käyttäjien sormenjäljet... device-cleared = Laite tyhjennetty. clear-device-confirm = Oletko varma, että haluat poistaa kaikki käyttäjien sormenjäljet? -cancel = Peruuta + +settings-ui = Käyttöliittymä +alternative-ui = Toinen käyttöliittymä +settings-clear-device = Poista kaikki +settings-theme = Teema + +theme-system = Järjestelmä +theme-light = Vaalea +theme-dark = Tumma + +register-tooltip = Rekisteröi uusi sormenjälki +delete-tooltip = Poista tämä sormenjälki +clear-tooltip = Poista kaikki käyttäjien sormenjäljet +verify-tooltip = Varmenna sormenjälki + +verify-finger = Laita {$finger} lukijalle +verify-no-match = Sormenjälki ei täsmännyt +verify-match = Sormenjälki täsmäsi +verify-retry-scan = Lukija ei voinut lukea. Yritä uudelleen. +verify-swipe-too-short = Pyyhkäisy oli liian lyhyt. Yritä uudelleen. +verify-finger-not-centered = Sormi ei ole keskellä lukijaa. Yritä uudelleen. +verify-remove-and-retry = Poista sormi ja yritä uudelleen. +verify-too-fast = Liian nopea toisto. Yritä uudelleen. +verify-disconnected = Laite katkaisi yhteyden. Sulje ikkuna. +verify-unknown-error = Tapahtui tuntematon virhe. page-right-thumb = Oikea Peukalo page-right-index-finger = Oikea Etusormi diff --git a/i18n/sv/cosmic_utils_enroll.ftl b/i18n/sv/cosmic_utils_enroll.ftl index 3996289..d4636d3 100644 --- a/i18n/sv/cosmic_utils_enroll.ftl +++ b/i18n/sv/cosmic_utils_enroll.ftl @@ -5,10 +5,12 @@ view = Visa fprint = Registrera fingeravtryck welcome = Registrera och/eller radera fingeravtryck git-description = Git commit {$hash} på {$date} -alternative-ui = Andra UI - register = Registrera +verify = Verifiera delete = Radera +danger = Varning +cancel = Avbryt +success = Sukse deleted = Raderat fingeravtryck. deleting = Raderar fingeravtryck... clear-device = Rensa enhet @@ -16,7 +18,27 @@ confirm-clear = Är du säker? clearing-device = Rensar enhet... device-cleared = Rensad för alla kända användare. clear-device-confirm = Är du säker du vill radera fingeravtryck för alla kända användare? -cancel = Avbryt + +alternative-ui = Andra UI +settings-ui = Användargränssnitt +settings-clear-device = Radera alla användarens fingeravtryck +settings-theme = Tema + +register-tooltip = Registrera en ny fingeravtryck +delete-tooltip = Raderar detta fingeravtryck +clear-tooltip = Radera alla fingeravtryck +verify-tooltip = Verifierar fingeravtrycket mot de registrerade fingeravtrycken + +verify-finger = Plas {$finger} på läsare +verify-no-match = Fingerprint matchade inte +verify-match = Fingerprint matchade +verify-retry-scan = Kunde inte läsa fingeravtrycket. Försök igen. +verify-swipe-too-short = Swipe var för kort. Försök igen. +verify-finger-not-centered = Finger var inte centrerat. Försök igen. +verify-remove-and-retry = Ta bort finger och försök igen. +verify-too-fast = Förstörande snabb touch. Försök igen. +verify-disconnected = Enheten är uppkopplad. Stäng fönstret. +verify-unknown-error = Det uppstod ett okänt fel. page-right-thumb = Höger tumme page-right-index-finger = Höger pekfinger diff --git a/resources/icons/hicolor/scalable/apps/enroll.svg b/resources/icons/hicolor/scalable/apps/enroll.svg index c16f19d..7d19665 100644 --- a/resources/icons/hicolor/scalable/apps/enroll.svg +++ b/resources/icons/hicolor/scalable/apps/enroll.svg @@ -1,23 +1,27 @@ - + + id="mdi-fingerprint" + viewBox="0 0 124 124" + version="1.1" + width="128" + height="128" + xml:space="preserve" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg" +> + + diff --git a/resources/org.cosmic_utils.enroll.metainfo.xml b/resources/org.cosmic_utils.enroll.metainfo.xml index 9a3b566..731f2b8 100644 --- a/resources/org.cosmic_utils.enroll.metainfo.xml +++ b/resources/org.cosmic_utils.enroll.metainfo.xml @@ -5,8 +5,9 @@ MPL-2.0 Enroll Fingerprint record management - GUI vytvořené pomocí toolkitu COSMIC pro registraci otisků prstů pomocí fprintd + Správa otisků prstů Sormenjälkien hallinointi + Fingerprint registreringshantering Joonas Tuomi @@ -15,18 +16,21 @@ Fingerprint management for single and multi-user systems. Allows you to register, verify and delete prints.

- Správa otisků prstů pro víceuživatelské systémy pomocí služby fprintd. Umožňuje registrovat a mazat otisky prstů pro ověřování ve vašem systému Linux. + Správa otisků prstů pro jednoho i více uživatelů. Umožňuje registrovat, ověřovat a mazat otisky.

Sormenjälkien hallinnointi yhden ja useamman käyttäjän järjestelmille. Sallii sinun luoda, varmentaa sekä poistaa jälkiä.

+

+ Fingerprint registreringshantering för enskilda och flera användare. Tillåter dig att registrera, verifiera och ta bort fingeravtryck. +

https://github.com/cosmic-utils/enroll/raw/main/resources/icons/hicolor/scalable/apps/enroll.svg org.cosmic_utils.enroll.desktop - cosmic-utils-enroll + cosmic-utils-enroll 360 @@ -51,6 +55,9 @@ Sormenjälki Tunnistautuminen COSMIC + Fingerprint + Autentisering + COSMIC #7ea5ae @@ -61,22 +68,43 @@ https://github.com/cosmic-utils/enroll - https://user.fm/files/v2-1be40ab863867624714661b062d93218/main.png - Main UI - Hlavní UI - Pääkäyttöliittymä + + https://user.fm/files/v2-1be40ab863867624714661b062d93218/main.png + + Main UI + Hlavní UI + Pääkäyttöliittymä + Huvudsida - + + +

+ Changes: +

+
    +
  • Configuration is loaded and theme applied on startup
  • +
  • Theme setting change works better on COSMIC
  • +
  • Settings aesthetics overhauled
  • +
  • Improved Czech translation
  • +
  • Bigger Icon with added whitespace
  • +
  • Fixed formatting of Release information
  • +
  • Lowered the window width limit and raised height
  • +
+
+
+

- - Updated dependencies - - Flathub friendlier metadata - - Added Setting section for Theme - - New Czech translation + Changes:

+
    +
  • Updated dependencies
  • +
  • Flathub friendlier metadata
  • +
  • Added Setting section for Theme
  • +
  • New Czech translation
  • +
diff --git a/src/app/application.rs b/src/app/application.rs index 28d4db2..52ae00a 100644 --- a/src/app/application.rs +++ b/src/app/application.rs @@ -1,12 +1,10 @@ // SPDX-License-Identifier: MPL-2.0 -use crate::app::tasks::{task_config, task_connect}; -use crate::app::{error::*, finger::*, fprint::*, subscription::*, users::*}; - use crate::app::message::{Message, REPOSITORY}; +use crate::app::tasks::task_connect; use crate::app::{ContextPage, MenuAction}; -use crate::config::{AppTheme, Config}; +use crate::app::{error::*, finger::*, fprint::*, subscription::*, users::*}; +use crate::config::{Config, read_config}; use crate::fl; - use cosmic::app::context_drawer; use cosmic::iced::{Alignment, Subscription}; @@ -14,7 +12,7 @@ use cosmic::{ cosmic_theme, prelude::*, theme, - widget::{self, button, column, dialog, menu, nav_bar, radio, settings::view_column, text}, + widget::{self, column, dialog, menu, nav_bar, text}, }; use super::AppModel; @@ -34,7 +32,7 @@ impl cosmic::Application for AppModel { type Message = Message; /// Unique identifier in RDNN (reverse domain name notation) format. - const APP_ID: &'static str = "org.cosmic_utils.Enroll"; + const APP_ID: &'static str = "org.cosmic_utils.enroll"; fn core(&self) -> &cosmic::Core { &self.core @@ -49,14 +47,22 @@ impl cosmic::Application for AppModel { mut core: cosmic::Core, _flags: Self::Flags, ) -> (Self, Task>) { + // Gets users let (users, nav, selected_user) = initialize_users(); + + // Load configuration + let (config_handler, config) = read_config(Self::APP_ID); + + // Start with navigation closed core.nav_bar_toggle(); + let mut app = AppModel { core, context_page: ContextPage::About, nav, key_binds: HashMap::new(), - config: Config::default(), + config, + config_handler, status: fl!("status-connecting"), device_path: None, device_proxy: None, @@ -73,11 +79,11 @@ impl cosmic::Application for AppModel { confirm_clear: false, }; + let start_theme = cosmic::command::set_theme(app.config.app_theme.theme()); let command = app.update_title_task(); let connect_task = task_connect(); - let config_task = task_config(Self::APP_ID.to_string()); - (app, Task::batch(vec![command, connect_task, config_task])) + (app, Task::batch(vec![command, connect_task, start_theme])) } /// Elements to pack at the start of the header bar. @@ -308,65 +314,6 @@ impl AppModel { .into() } - /// Settings menu - pub fn settings(&self) -> Element<'_, Message> { - let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing; - let sel_theme = text::title3(fl!("settings-theme")); - let text = text::title3(fl!("settings-ui")); - let clear = text::title3(fl!("settings-clear-device")); - let clear_btn = button::text(fl!("clear-device")).tooltip(fl!("clear-tooltip")); - - let clear_btn = - if !self.busy && self.device_path.is_some() && self.enrolling_finger.is_none() { - clear_btn.on_press(Message::ClearDevice) - } else { - clear_btn - }; - - let selected = Some(self.config.app_theme); - let system = radio( - text::heading(fl!("theme-system")), - AppTheme::System, - selected, - Message::ThemeSetting, - ); - - let light = radio( - text::heading(fl!("theme-light")), - AppTheme::Light, - selected, - Message::ThemeSetting, - ); - - let dark = radio( - text::heading(fl!("theme-dark")), - AppTheme::Dark, - selected, - Message::ThemeSetting, - ); - - let col = column() - .push(sel_theme) - .push(system) - .push(light) - .push(dark) - .push(text) - .push( - widget::checkbox(self.config.experimental_ui) - .on_toggle(|value| { - Message::UpdateConfig(Config { - app_theme: self.config.app_theme, - experimental_ui: value, - }) - }) - .label(fl!("alternative-ui")), - ) - .push(clear) - .push(clear_btn) - .spacing(space_xxs); - view_column(vec![col.into()]).into() - } - /// Gets all registered prints for requested user pub(crate) fn list_fingers_task(&self) -> Task> { if let (Some(proxy), Some(user)) = (&self.device_proxy, &self.selected_user) { diff --git a/src/app/fprint.rs b/src/app/fprint.rs index a7b26e2..c13c88c 100644 --- a/src/app/fprint.rs +++ b/src/app/fprint.rs @@ -184,10 +184,7 @@ where .await?; // Claim device - match device.claim(username).await { - Ok(_) => {} - Err(e) => return Err(e), - }; + device.claim(username).await?; let total_stages = match device.num_enroll_stages().await { Ok(n) if n > 0 => Some(n as u32), @@ -270,9 +267,7 @@ where validate_username(&username)?; let device = DeviceProxy::builder(connection).path(path)?.build().await?; - if let Err(e) = device.claim(&username).await { - return Err(e); - } + device.claim(&username).await?; if let Err(e) = device.verify_start(&finger).await { let _ = device.release().await; diff --git a/src/app/message.rs b/src/app/message.rs index 443616b..8c7a16f 100644 --- a/src/app/message.rs +++ b/src/app/message.rs @@ -4,9 +4,10 @@ use crate::app::AppModel; use crate::app::error::AppError; use crate::app::tasks::*; use crate::app::{ContextPage, Finger}; -use crate::config::{AppTheme, Config, is_cosmic_desktop}; +use crate::config::{AppTheme, Config}; use crate::fl; use crate::fprint_dbus::DeviceProxy; +use cosmic::cosmic_config::CosmicConfigEntry; use cosmic::{Task, command}; use std::sync::Arc; use tracing::info; @@ -379,16 +380,10 @@ impl AppModel { pub(crate) fn on_update_config(&mut self, config: Config) -> Task> { self.config = config.clone(); - tokio::task::spawn_blocking(move || { - use cosmic::Application; - use cosmic::cosmic_config::{self, CosmicConfigEntry}; - - if let Ok(context) = cosmic_config::Config::new(AppModel::APP_ID, Config::VERSION) - && let Err(err) = config.write_entry(&context) - { + if let Some(handler) = &self.config_handler + && let Err(err) = config.write_entry(handler) { tracing::error!("failed to write config: {}", err); } - }); Task::none() } @@ -421,15 +416,7 @@ impl AppModel { ..self.config.clone() })]; - let task = if theme == AppTheme::Dark { - command::set_theme(cosmic::Theme::dark()) - } else if theme == AppTheme::Light { - command::set_theme(cosmic::Theme::light()) - } else if is_cosmic_desktop() { - command::set_theme(cosmic::theme::system_preference()) - } else { - Task::none() - }; + let task = cosmic::command::set_theme(theme.theme()); tasks.push(task); Task::batch(tasks) diff --git a/src/app/mod.rs b/src/app/mod.rs index 5c4fbdf..d3bd1cf 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -2,7 +2,10 @@ use std::{collections::HashMap, sync::Arc}; -use cosmic::widget::{menu, nav_bar}; +use cosmic::{ + cosmic_config, + widget::{menu, nav_bar}, +}; use crate::{ app::{finger::Finger, message::Message, users::UserOption}, @@ -14,6 +17,7 @@ pub mod error; pub mod finger; pub mod fprint; pub mod message; +pub mod settings; pub mod subscription; pub mod tasks; pub mod users; @@ -34,6 +38,8 @@ pub struct AppModel { key_binds: HashMap, // Configuration data that persists between application runs. config: Config, + // Config handler for writing & reading it + config_handler: Option, // Status text for the UI status: String, // Currently selected device path diff --git a/src/app/settings.rs b/src/app/settings.rs new file mode 100644 index 0000000..ddc2108 --- /dev/null +++ b/src/app/settings.rs @@ -0,0 +1,76 @@ +use crate::app::{AppModel, message::Message}; +use crate::config::{AppTheme, Config}; +use crate::fl; +use cosmic::widget::settings::item::builder; +use cosmic::widget::settings::{item_row, section, view_column}; +use cosmic::{ + Element, cosmic_theme, theme, + widget::{button, checkbox, column, radio, text}, +}; + +impl AppModel { + /// Settings menu + pub fn settings(&self) -> Element<'_, Message> { + let cosmic_theme::Spacing { space_xs, .. } = theme::active().cosmic().spacing; + let clear_btn = button::text(fl!("clear-device")).tooltip(fl!("clear-tooltip")); + + let clear_btn = + if !self.busy && self.device_path.is_some() && self.enrolling_finger.is_none() { + clear_btn.on_press(Message::ClearDevice) + } else { + clear_btn + }; + + let theme_section = section() + .title(fl!("settings-ui")) + .add( + builder(fl!("settings-theme")) + .control(item_row(vec![ + radio( + text::heading(fl!("theme-system")), + AppTheme::System, + Some(self.config.app_theme), + Message::ThemeSetting, + ) + .into(), + radio( + text::heading(fl!("theme-light")), + AppTheme::Light, + Some(self.config.app_theme), + Message::ThemeSetting, + ) + .into(), + radio( + text::heading(fl!("theme-dark")), + AppTheme::Dark, + Some(self.config.app_theme), + Message::ThemeSetting, + ) + .into(), + ])) + .wrap(), + ) + .add( + builder(fl!("alternative-ui")).control( + checkbox(self.config.experimental_ui) + .on_toggle(|value| { + Message::UpdateConfig(Config { + app_theme: self.config.app_theme, + experimental_ui: value, + }) + }) + .label(fl!("alternative-ui")), + ), + ); + + let clear_section = section() + .title(fl!("danger")) + .add(builder(fl!("settings-clear-device")).control(item_row(vec![clear_btn.into()]))); + + let col = column() + .push(theme_section) + .push(clear_section) + .spacing(space_xs); + view_column(vec![col.into()]).into() + } +} diff --git a/src/app/tasks.rs b/src/app/tasks.rs index e73e66d..57bc11d 100644 --- a/src/app/tasks.rs +++ b/src/app/tasks.rs @@ -1,10 +1,8 @@ // SPDX-License-Identifier: MPL-2.0 use crate::app::{error::AppError, fprint::*, message::Message}; -use crate::config::Config; use crate::fprint_dbus::*; use cosmic::Task; -use cosmic::cosmic_config::{self, CosmicConfigEntry}; /// **Returns** ***Task*** which: /// @@ -121,34 +119,3 @@ pub fn task_connect() -> Task> { cosmic::Action::App, ) } - -/// **Returns** ***Task*** which: -/// parses the configuration -pub fn task_config(app_id: String) -> Task> { - Task::perform( - async move { - let config = tokio::task::spawn_blocking(move || { - cosmic_config::Config::new(&app_id, Config::VERSION) - .map(|context| match Config::get_entry(&context) { - Ok(config) => config, - Err((errors, config)) => { - for why in errors { - tracing::error!(%why, "error loading app config"); - } - - config - } - }) - .unwrap_or_default() - }) - .await - .unwrap_or_else(|e| { - tracing::error!("Config task join error: {}", e); - Config::default() - }); - - Message::UpdateConfig(config) - }, - cosmic::Action::App, - ) -} diff --git a/src/config.rs b/src/config.rs index eea6425..0bc9dff 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,6 +2,7 @@ use cosmic::cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry}; use cosmic::{Theme, theme}; use serde::{Deserialize, Serialize}; +use tracing::error; // AppTheme is directly copied from https://github.com/cosmic-utils/camera /// Application theme preference @@ -63,3 +64,22 @@ pub fn is_cosmic_desktop() -> bool { }); *IS_COSMIC } + +pub fn read_config(app_id: &str) -> (Option, Config) { + match cosmic_config::Config::new(app_id, Config::VERSION) { + Ok(handler) => { + let config = match Config::get_entry(&handler) { + Ok(config) => config, + Err((errors, config)) => { + error!(?errors, "Errors loading config"); + config + } + }; + (Some(handler), config) + } + Err(err) => { + error!(%err, "Failed to create config handler"); + (None, Config::default()) + } + } +} diff --git a/src/main.rs b/src/main.rs index d89964a..57f049c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,8 @@ extern crate ashpd; extern crate tracing; extern crate zbus; -const WINDOW_MIN_WIDTH: f32 = 400.0; -const WINDOW_MIN_HEIGHT: f32 = 380.0; +const WINDOW_MIN_WIDTH: f32 = 360.0; +const WINDOW_MIN_HEIGHT: f32 = 600.0; fn main() -> cosmic::iced::Result { // Get the system's preferred languages.