Skip to content

Commit

Permalink
feat: check for version in hyprland version command
Browse files Browse the repository at this point in the history
Signed-off-by: Enrico Stemmer <[email protected]>
  • Loading branch information
H3rmt committed Jan 9, 2025
1 parent 69a43ef commit 1a67ca5
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const MIN_VERSION: Version = Version::new(0, 42, 0);

pub mod cli;
pub mod client;
#[cfg(feature = "config")]
pub mod config;
pub mod daemon;
pub mod envs;
pub mod handle;
#[cfg(feature = "config")]
pub mod config;

#[derive(Debug, Clone)]
pub struct MonitorData {
Expand Down Expand Up @@ -163,7 +163,7 @@ pub enum GUISend {
pub enum UpdateCause {
Client(u8),
LauncherUpdate,
GuiClick
GuiClick,
}

impl Display for UpdateCause {
Expand All @@ -177,7 +177,11 @@ impl Display for UpdateCause {
}

// shared ARC with Mutex and Notify for new_gui and update_gui
pub type Share = Arc<(Mutex<SharedData>, Sender<(GUISend, UpdateCause)>, Receiver<bool>)>;
pub type Share = Arc<(
Mutex<SharedData>,
Sender<(GUISend, UpdateCause)>,
Receiver<bool>,
)>;

/// global variable to store if we are in dry mode
pub static DRY: OnceLock<bool> = OnceLock::new();
Expand Down Expand Up @@ -273,14 +277,17 @@ pub fn check_version() -> anyhow::Result<()> {
info!(
"Starting Hyprswitch ({}) on Hyprland {}",
option_env!("CARGO_PKG_VERSION").unwrap_or("?.?.?"),
version.tag
version.version.clone().unwrap_or(version.tag.clone()),
);

let parsed_version = Version::parse(version.tag.trim_start_matches('v'))
.context("Unable to parse Hyprland Version")?;
let parsed_version = Version::parse(
&*version
.version
.unwrap_or(version.tag.trim_start_matches('v').to_string()),
)
.context("Unable to parse Hyprland Version")?;

// TODO use .version in future and fall back to tag (only parse tag if version is not found => <v0.41.?)
if version.tag == "unknown" || parsed_version.lt(&MIN_VERSION) {
if parsed_version.lt(&MIN_VERSION) {
let _ = Notification::new()
.summary(&format!(
"Hyprswitch ({}) Error",
Expand Down

0 comments on commit 1a67ca5

Please sign in to comment.