Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

BowDown097
Copy link
Contributor

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:

icon_overrides = { legcord = "discord" }

    Before         After

@JakeStanger
Copy link
Owner

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.

@BowDown097
Copy link
Contributor Author

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.

@JakeStanger
Copy link
Owner

A lot of the modules have an icons option, or some other ability to configure its icons. Most of those support image icons, which includes icons straight from the system theme. I was originally thinking they'd make use of it but I guess that'd be useless actually since you're already controlling the displayed icon.

launcher, focused and tray would be the 3 big ones, but yeah you're probably right that it wouldn't be very useful for the tray.

It would definitely make sense to have in focused for the same reason as the launcher, but probably not enough to warrant a top-level option. I think if you're up for it, just duplicating the feature into the focused module would actually be enough.

@BowDown097
Copy link
Contributor Author

👍 I think it would probably be good to have it for future-proofing purposes too. I'll get to it soon enough.

@BowDown097 BowDown097 changed the title feat(launcher): icon overrides feat: icon overrides Jan 17, 2025
docs/Configuration guide.md Outdated Show resolved Hide resolved
src/config/mod.rs Outdated Show resolved Hide resolved
src/modules/launcher/mod.rs Outdated Show resolved Hide resolved
/// Map of app IDs (or classes) to icon names,
/// overriding the app's default icon.
///
/// **Default**; `{}`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// **Default**; `{}`
/// **Default**: `{}`

///
/// **Default**; `{}`
#[serde(default)]
pub icon_overrides: HashMap<String, String>,
Copy link
Owner

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();
Copy link
Owner

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());
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants