-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: icon theme abstraction for certain icons
Signed-off-by: Ryan Brue <[email protected]>
- Loading branch information
Showing
10 changed files
with
137 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use std::{env, path::PathBuf}; | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Deserialize, Serialize)] | ||
pub enum IconTheme { | ||
Breeze, | ||
Cosmic, | ||
None, | ||
} | ||
|
||
impl Default for IconTheme { | ||
fn default() -> Self { | ||
// guess icon theme | ||
let current_desktop = env::var_os("XDG_CURRENT_DESKTOP") | ||
.map(|x| x.to_ascii_lowercase().to_string_lossy().to_string()); | ||
match current_desktop.as_deref() { | ||
Some("kde") => Self::Breeze, | ||
Some("cosmic") => Self::Cosmic, | ||
Some(_) => Self::None, // Don't know what desktop this is | ||
None => Self::None, | ||
} | ||
} | ||
} | ||
|
||
pub fn default_icon_path(theme: &IconTheme) -> Option<PathBuf> { | ||
match theme { | ||
IconTheme::Breeze => freedesktop_icons::lookup("wayland") | ||
.with_theme("breeze") | ||
.with_cache() | ||
.find(), | ||
IconTheme::Cosmic => freedesktop_icons::lookup("application-default") | ||
.with_theme("Cosmic") | ||
.with_cache() | ||
.find(), | ||
IconTheme::None => None, | ||
} | ||
} | ||
|
||
pub fn start_menu_icon(theme: &IconTheme) -> Option<PathBuf> { | ||
match theme { | ||
IconTheme::Breeze => freedesktop_icons::lookup("applications-all") | ||
.with_theme("breeze") | ||
.with_cache() | ||
.find(), | ||
IconTheme::Cosmic => freedesktop_icons::lookup("applications-office") | ||
.with_theme("Cosmic") | ||
.with_cache() | ||
.find(), | ||
IconTheme::None => None, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod desktop_entry; | ||
pub mod icons; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters