Small fixes

This commit is contained in:
2024-07-19 09:52:38 +02:00
parent 1a70e5772e
commit 125e996599

View File

@ -35,18 +35,15 @@ enum WindowManager {
} }
static WM: Lazy<WindowManager> = Lazy::new(|| { static WM: Lazy<WindowManager> = 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(); let session_type = env::var("XDG_SESSION_TYPE").ok();
if session_type.as_deref() != Some("wayland") { if session_type.as_deref() != Some("wayland") {
return WindowManager::Unknown; return WindowManager::Unknown;
} }
// TODO: might be relevant? // might be relevant at some point
let _session_desktop = env::var("XDG_SESSION_DESKTOP").ok(); // let _session_desktop = env::var("XDG_SESSION_DESKTOP").ok();
let current_desktop = env::var("XDG_CURRENT_DESKTOP").ok(); let current_desktop = env::var("XDG_CURRENT_DESKTOP").ok();
match current_desktop.as_deref() { match current_desktop.as_deref() {
@ -69,8 +66,6 @@ fn main() -> eyre::Result<()> {
Ok(()) Ok(())
} }
// Map<i32, Workspace>
#[derive(Serialize)] #[derive(Serialize)]
struct Workspace { struct Workspace {
monitor: i32, monitor: i32,
@ -87,19 +82,17 @@ fn handle_niri(command: Command) -> eyre::Result<()> {
.map_err(|e| eyre!("niri error: {e}"))?; .map_err(|e| eyre!("niri error: {e}"))?;
let niri_ipc::Response::Workspaces(workspaces) = reply else { let niri_ipc::Response::Workspaces(workspaces) = reply else {
panic!(); bail!("Wrong response from niri: {reply:?}");
}; };
let workspaces = workspaces let workspaces = workspaces
.into_iter() .into_iter()
.map(|ws| { .map(|ws| {
( let workspace = Workspace {
ws.idx, monitor: 0,
Workspace { active: ws.is_active,
monitor: 0, };
active: ws.is_active, (ws.idx, workspace)
},
)
}) })
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();