-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: icon overrides #837
base: master
Are you sure you want to change the base?
feat: icon overrides #837
Conversation
Thanks for this. I'm wondering if this would actually be better as a top-level config option, rather than implemented per module. That would allow for a single set of overrides to be defined and take place everywhere an icon is used, rather than eg just within the Launcher module. |
I thought about doing that, but I wasn't sure where else it could be used. Only other place I could think of is the system tray but I'm not sure how that would work. |
A lot of the modules have an
It would definitely make sense to have in |
👍 I think it would probably be good to have it for future-proofing purposes too. I'll get to it soon enough. |
/// Map of app IDs (or classes) to icon names, | ||
/// overriding the app's default icon. | ||
/// | ||
/// **Default**; `{}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// **Default**; `{}` | |
/// **Default**: `{}` |
/// | ||
/// **Default**; `{}` | ||
#[serde(default)] | ||
pub icon_overrides: HashMap<String, String>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives the ability to set overrides per-bar. I'm not sure I can see a use-case for that personally - it would probably be better to have this on the Config
struct so that it applies application-wide.
Happy to keep as-is if you think otherwise though?
@@ -153,9 +154,15 @@ impl Module<gtk::Box> for FocusedModule { | |||
|
|||
{ | |||
let icon_theme = icon_theme.clone(); | |||
let icon_overrides = icon_overrides.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this were to move to Config
(see other comment)...I don't particularly like that we need to clone here, as it'll re-alloc for every focused/launcher instance. It'd be cheaper to wrap in an Arc
(no Mutex
needed since we're not mutating).
If it's kept at bar-level config though, I think this is fine since in most cases you'll only have 1 copy of the launcher or focused module at a time anyway.
let items2 = Arc::clone(&items); | ||
|
||
let icon_overrides = arc_mut!(info.icon_overrides.clone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not need to be mutable. Removing the mutex will also simplify some of the code below as it removes the need to lock.
This allows the user to override an app's icon in the launcher with a specified icon name. The only alternative to this currently is to dig through your icon theme's folder and replace existing entries / manually add entries yourself, which is rather inconvenient.
I thought about instead adding functionality to look for an associated desktop file and use the icon from that if one is found, but I'm not sure how I would address the problem of app IDs not having to match the desktop file name, or anything in the file.
Example:
Before After