From 125e9965992ba56c110a6cb28a135e70ce783ba4 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Fri, 19 Jul 2024 09:52:38 +0200 Subject: [PATCH] Small fixes --- src/main.rs | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 035a995..b63af9c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -35,18 +35,15 @@ enum WindowManager { } static WM: Lazy = Lazy::new(|| { - // SUPPORTED_COMPOSITORS="sway river Hyprland" - // if [ "${XDG_SESSION_TYPE:-""}" = "wayland" ] && \ - // echo " $SUPPORTED_COMPOSITORS " | \ - // grep -qi -e " ${XDG_CURRENT_DESKTOP:-""} " -e " ${XDG_SESSION_DESKTOP:-""} " let session_type = env::var("XDG_SESSION_TYPE").ok(); if session_type.as_deref() != Some("wayland") { return WindowManager::Unknown; } - // TODO: might be relevant? - let _session_desktop = env::var("XDG_SESSION_DESKTOP").ok(); + // might be relevant at some point + // let _session_desktop = env::var("XDG_SESSION_DESKTOP").ok(); + let current_desktop = env::var("XDG_CURRENT_DESKTOP").ok(); match current_desktop.as_deref() { @@ -69,8 +66,6 @@ fn main() -> eyre::Result<()> { Ok(()) } -// Map - #[derive(Serialize)] struct Workspace { monitor: i32, @@ -87,19 +82,17 @@ fn handle_niri(command: Command) -> eyre::Result<()> { .map_err(|e| eyre!("niri error: {e}"))?; let niri_ipc::Response::Workspaces(workspaces) = reply else { - panic!(); + bail!("Wrong response from niri: {reply:?}"); }; let workspaces = workspaces .into_iter() .map(|ws| { - ( - ws.idx, - Workspace { - monitor: 0, - active: ws.is_active, - }, - ) + let workspace = Workspace { + monitor: 0, + active: ws.is_active, + }; + (ws.idx, workspace) }) .collect::>();