mirror of
https://github.com/NotAShelf/microfetch.git
synced 2025-11-06 08:32:19 +00:00
modularize
This commit is contained in:
parent
198fd107d7
commit
29e4ccc806
6 changed files with 223 additions and 203 deletions
13
src/desktop.rs
Normal file
13
src/desktop.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
use std::{env, io};
|
||||
|
||||
pub fn get_desktop_info() -> Result<String, io::Error> {
|
||||
let desktop_env = env::var("XDG_CURRENT_DESKTOP").unwrap_or_default();
|
||||
let display_backend = env::var("XDG_SESSION_TYPE").unwrap_or_default();
|
||||
|
||||
// Trim "none+" from the start of desktop_env if present
|
||||
// XXX: This is a workaround for NixOS modules that set XDG_CURRENT_DESKTOP to "none+foo"
|
||||
// instead of just "foo"
|
||||
let desktop_env = desktop_env.trim_start_matches("none+");
|
||||
|
||||
Ok(format!("{} ({})", desktop_env, display_backend))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue