[GH-ISSUE #426] [Workspace] Workspace name based on the window title and/or class #2956

Open
opened 2026-05-22 23:52:54 +01:00 by JakeStanger · 5 comments
Owner

Originally created by @wehagy on GitHub (Jan 29, 2024).
Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/426

Describe the solution you'd like
Workspace name shows some custom string, icon, anything the user wants based on the window class and/or title

Describe alternatives you've considered
Waybar have something similar see https://github.com/Alexays/Waybar/wiki/Module:-Hyprland#window-rewrite-rules

Additional context
You will probably need regex to implement this, the issue for regex is #229

Originally created by @wehagy on GitHub (Jan 29, 2024). Original GitHub issue: https://github.com/JakeStanger/ironbar/issues/426 **Describe the solution you'd like** Workspace name shows some custom string, icon, anything the user wants based on the window class and/or title **Describe alternatives you've considered** Waybar have something similar see https://github.com/Alexays/Waybar/wiki/Module:-Hyprland#window-rewrite-rules **Additional context** You will probably need regex to implement this, the issue for regex is #229
Author
Owner

@JakeStanger commented on GitHub (Jan 29, 2024):

It isn't clear to me how this should work - what is the connection between workspaces and windows here?

Could you use an existing program like this to achieve this at the compositor level?
https://github.com/hyprland-community/hyprland-autoname-workspaces

I'd be potentially open to changing the name_map config option to accepting dynamic strings. I don't think I'd want to add in anything too specific like tying it to current windows though, as that is a lot of work for a niche feature.

<!-- gh-comment-id:1915591662 --> @JakeStanger commented on GitHub (Jan 29, 2024): It isn't clear to me how this should work - what is the connection between workspaces and windows here? Could you use an existing program like this to achieve this at the compositor level? https://github.com/hyprland-community/hyprland-autoname-workspaces I'd be potentially open to changing the `name_map` config option to accepting dynamic strings. I don't think I'd want to add in anything too specific like tying it to current windows though, as that is a lot of work for a niche feature.
Author
Owner

@wehagy commented on GitHub (Jan 31, 2024):

It isn't clear to me how this should work - what is the connection between workspaces and windows here?

The name of the workspace changes dynamically according to the name of the windows title and/or class that are open in that workspace, for example:

For context using ironbar v0.14.0 and hyprland-autoname-workspaces 1.1.12, and it doesn't work, it's just a demonstration
workspace 1 have one window, terminal window
workspace 2 have two windows, two firefox windows
workspace 3 have one window, steam window

  1. The bar now
    20240131_00h06m44s_grim

  2. Close one firefox window
    20240131_00h09m53s_grim

  3. Close the steam window, but the worskpace 3 is active, ignore the number 3 being the workspace 1, ironbar don't support, I'll talk more about it later
    20240131_00h14m27s_grim

  4. Go to workspace 1
    20240131_00h11m54s_grim

For this work is need regex to look for the name of the window class and change the workspace name to user defined variable, maybe I think you can't see the icon because of the font:

$ cat ~/.config/hyprland-autoname-workspaces/config.toml
...
[class]
# Add your icons mapping
# take class name from 'hyprctl clients'
"DEFAULT" = ""
"[Ff]irefox" = "󰈹"
"[Pp]rompt" = ""
"^([Ss]team)$" = "󰓓"
...
$ hyprctl clients
...
Window 558b25d1cc80 -> [Workspace] Workspace name based on the window title and/or class · Issue #426 · JakeStanger/ironbar — Mozilla Firefox:
	mapped: 1
	hidden: 0
	at: 6,70
	size: 1908,1004
	workspace: 1 (󰈹)
	floating: 0
	monitor: 0
	class: org.mozilla.firefox
	title: [Workspace] Workspace name based on the window title and/or class · Issue #426 · JakeStanger/ironbar — Mozilla Firefox
	initialClass: org.mozilla.firefox
	initialTitle: Mozilla Firefox
	pid: 275893
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	swallowing: 0
	focusHistoryID: 1
...
  1. And we can go further using window class and title, the same scenario, but one firefox window is on youtube
    20240131_01h22m52s_grim
$ cat ~/.config/hyprland-autoname-workspaces/config.toml
...
[class]
# Add your icons mapping
# take class name from 'hyprctl clients'
"DEFAULT" = ""
"[Ff]irefox" = "󰈹"
"[Pp]rompt" = ""
"^([Ss]team)$" = "󰓓"

[title_in_class."[Ff]irefox"]
"(?i)youtube" = "󰗃"
...
$ hyprctl clients
...
Window 558b252d8aa0 -> YouTube — Mozilla Firefox:
	mapped: 1
	hidden: 0
	at: 6,40
	size: 950,1034
	workspace: 1 (󰈹 󰗃)
	floating: 0
	monitor: 0
	class: org.mozilla.firefox
	title: YouTube — Mozilla Firefox
	initialClass: org.mozilla.firefox
	initialTitle: Mozilla Firefox
	pid: 275893
	xwayland: 0
	pinned: 0
	fullscreen: 0
	fullscreenmode: 0
	fakefullscreen: 0
	grouped: 0
	swallowing: 0
	focusHistoryID: 1
...

Could you use an existing program like this to achieve this at the compositor level? https://github.com/hyprland-community/hyprland-autoname-workspaces

Thanks, I didn't know about this project, and yes and no, tried and works like a charm in the waybar, but in the waybar is builtin, and works too... But maybe I can use for more edge cases, and with the ironbar I have some trouble, like you see in the third image above, sorting is "not working", probably because of the alphanumeric sort, the name of the workspaces don't change dynamically, don't remove empty workspaces.

I'd be potentially open to changing the name_map config option to accepting dynamic strings. I don't think I'd want to add in anything too specific like tying it to current windows though, as that is a lot of work for a niche feature.

Yeah, I don't think a lot of people use this feature, because is cool but is a little bit of pain to setup, and is good if name_map accept dynamic strings, maybe scripts too? To be honest the first thing I tried is to make some script magic, but name_map don't accept scripts... And if you support dynamic workspace rename I don't have any reason to use script here.

If you don't want to implement this feature builtin, but make ironbar happy with hyprland-autoname-workspaces it's nice too.

And doing my tests... I discovered that name_map don't accept Pango Markup, if you want I can open a new issue to track this.

<!-- gh-comment-id:1918402034 --> @wehagy commented on GitHub (Jan 31, 2024): > It isn't clear to me how this should work - what is the connection between workspaces and windows here? > The name of the workspace changes dynamically according to the name of the windows title and/or class that are open in that workspace, for example: For context using `ironbar v0.14.0` and `hyprland-autoname-workspaces 1.1.12`, and it doesn't work, it's just a demonstration `workspace 1` have one window, terminal window `workspace 2` have two windows, two firefox windows `workspace 3` have one window, steam window 1. The bar now ![20240131_00h06m44s_grim](https://github.com/JakeStanger/ironbar/assets/95216845/00756049-2c57-4ba4-b6a4-82c47438dc85) 2. Close one firefox window ![20240131_00h09m53s_grim](https://github.com/JakeStanger/ironbar/assets/95216845/187bf8d0-970a-4dbb-9dea-0d67a5eb8578) 3. Close the steam window, but the `worskpace 3` is active, ignore the `number 3` being the `workspace 1`, `ironbar` don't support, I'll talk more about it later ![20240131_00h14m27s_grim](https://github.com/JakeStanger/ironbar/assets/95216845/a1099d5c-7099-426e-846e-8681ea42d69c) 4. Go to `workspace 1` ![20240131_00h11m54s_grim](https://github.com/JakeStanger/ironbar/assets/95216845/d3c0a8e6-f42c-40f6-982f-9fff6e44fdf9) For this work is need regex to look for the name of the window class and change the workspace name to user defined variable, maybe I think you can't see the icon because of the font: ```bash $ cat ~/.config/hyprland-autoname-workspaces/config.toml ... [class] # Add your icons mapping # take class name from 'hyprctl clients' "DEFAULT" = "" "[Ff]irefox" = "󰈹" "[Pp]rompt" = "" "^([Ss]team)$" = "󰓓" ... ``` ```bash $ hyprctl clients ... Window 558b25d1cc80 -> [Workspace] Workspace name based on the window title and/or class · Issue #426 · JakeStanger/ironbar — Mozilla Firefox: mapped: 1 hidden: 0 at: 6,70 size: 1908,1004 workspace: 1 (󰈹) floating: 0 monitor: 0 class: org.mozilla.firefox title: [Workspace] Workspace name based on the window title and/or class · Issue #426 · JakeStanger/ironbar — Mozilla Firefox initialClass: org.mozilla.firefox initialTitle: Mozilla Firefox pid: 275893 xwayland: 0 pinned: 0 fullscreen: 0 fullscreenmode: 0 fakefullscreen: 0 grouped: 0 swallowing: 0 focusHistoryID: 1 ... ``` 5. And we can go further using window class and title, the same scenario, but one firefox window is on youtube ![20240131_01h22m52s_grim](https://github.com/JakeStanger/ironbar/assets/95216845/aa90aaf9-5413-41d1-a02d-b1da5efc8b9d) ```bash $ cat ~/.config/hyprland-autoname-workspaces/config.toml ... [class] # Add your icons mapping # take class name from 'hyprctl clients' "DEFAULT" = "" "[Ff]irefox" = "󰈹" "[Pp]rompt" = "" "^([Ss]team)$" = "󰓓" [title_in_class."[Ff]irefox"] "(?i)youtube" = "󰗃" ... ``` ```bash $ hyprctl clients ... Window 558b252d8aa0 -> YouTube — Mozilla Firefox: mapped: 1 hidden: 0 at: 6,40 size: 950,1034 workspace: 1 (󰈹 󰗃) floating: 0 monitor: 0 class: org.mozilla.firefox title: YouTube — Mozilla Firefox initialClass: org.mozilla.firefox initialTitle: Mozilla Firefox pid: 275893 xwayland: 0 pinned: 0 fullscreen: 0 fullscreenmode: 0 fakefullscreen: 0 grouped: 0 swallowing: 0 focusHistoryID: 1 ... ``` > Could you use an existing program like this to achieve this at the compositor level? https://github.com/hyprland-community/hyprland-autoname-workspaces > Thanks, I didn't know about this project, and yes and no, tried and works like a charm in the `waybar`, but in the `waybar` is builtin, and works too... But maybe I can use for more edge cases, and with the `ironbar` I have some trouble, like you see in the third image above, sorting is "not working", probably because of the alphanumeric sort, the name of the workspaces don't change dynamically, don't remove empty workspaces. > I'd be potentially open to changing the `name_map` config option to accepting dynamic strings. I don't think I'd want to add in anything too specific like tying it to current windows though, as that is a lot of work for a niche feature. > Yeah, I don't think a lot of people use this feature, because is cool but is a little bit of pain to setup, and is good if `name_map` accept dynamic strings, maybe scripts too? To be honest the first thing I tried is to make some script magic, but `name_map` don't accept scripts... And if you support dynamic workspace rename I don't have any reason to use script here. If you don't want to implement this feature builtin, but make `ironbar` happy with `hyprland-autoname-workspaces` it's nice too. And doing my tests... I discovered that `name_map` don't accept `Pango Markup`, if you want I can open a new issue to track this.
Author
Owner

@JakeStanger commented on GitHub (Feb 3, 2024):

Thanks for taking the time to come back with the extra detail. Here's how I see this:

  • Support for hyprland-autoname-workspaces is the first step. The fact that doesn't quite work as expected is arguably a bug, so I'd consider that a higher priority.
  • Changing name_map to be a dynamic string is fairly trivial for a quick win
  • Changing name_map to accept Pango is also trivial. I'll track that as part of this issue because I might as well do it at the same time as the above.

After those are in, we can revisit and see if there's anything else worth adding or if those solve the problem sufficiently.

<!-- gh-comment-id:1925410689 --> @JakeStanger commented on GitHub (Feb 3, 2024): Thanks for taking the time to come back with the extra detail. Here's how I see this: - Support for `hyprland-autoname-workspaces` is the first step. The fact that doesn't quite work as expected is arguably a bug, so I'd consider that a higher priority. - Changing `name_map` to be a dynamic string is fairly trivial for a quick win - Changing `name_map` to accept Pango is also trivial. I'll track that as part of this issue because I might as well do it at the same time as the above. After those are in, we can revisit and see if there's anything else worth adding or if those solve the problem sufficiently.
Author
Owner

@xabufr commented on GitHub (Feb 23, 2024):

Hello !
I tried to make some changes to support hyprland-autoname-workspaces.
I managed to get pango syntax in the workspaces name works by this little change:

diff --git a/src/modules/workspaces.rs b/src/modules/workspaces.rs
index 40c30c5..7953783 100644
--- a/src/modules/workspaces.rs
+++ b/src/modules/workspaces.rs
@@ -4,7 +4,7 @@ use crate::image::new_icon_button;
 use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext};
 use crate::{glib_recv, send_async, spawn, try_send};
 use color_eyre::{Report, Result};
-use gtk::prelude::*;
+use gtk::{prelude::*, Label};
 use gtk::{Button, IconTheme};
 use serde::Deserialize;
 use std::cmp::Ordering;
@@ -85,6 +85,9 @@ fn create_button(

     let button = new_icon_button(label, icon_theme, icon_size);
     button.set_widget_name(name);
+    if let Some(label) = button.child().and_downcast::<Label>() {
+        label.set_use_markup(true);
+    }

     let style_context = button.style_context();
     style_context.add_class("item");

This permits to have right icons provided by hyprland-autoname-workspaces, but they don't update. In fact digging into the code I find we didn't listen for workspacerename events.
The next challenge is to listen for rename events.

Moreover I think we will need to refactor a little the way we manage those workspace.
Currently we rely a lot on the workspace name (because the event API only send this info), the problem is that the name change with hyprland-autoname-workspaces:

  • we can have concurrency problems (the name we get may change before we request all workspaces, so we get ERROR ironbar::clients::compositor::hyprland: 86: Unable to locate workspace)
  • we also may have multiple workspaces with the same name (I have a triple monitor setup, and I may have multiple workspaces with the same name (I use split-monitor-workspace), fox exemple I have multiple workspaces named <sub>1</sub> )
<!-- gh-comment-id:1961011730 --> @xabufr commented on GitHub (Feb 23, 2024): Hello ! I tried to make some changes to support `hyprland-autoname-workspaces`. I managed to get pango syntax in the workspaces name works by this little change: ```diff diff --git a/src/modules/workspaces.rs b/src/modules/workspaces.rs index 40c30c5..7953783 100644 --- a/src/modules/workspaces.rs +++ b/src/modules/workspaces.rs @@ -4,7 +4,7 @@ use crate::image::new_icon_button; use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext}; use crate::{glib_recv, send_async, spawn, try_send}; use color_eyre::{Report, Result}; -use gtk::prelude::*; +use gtk::{prelude::*, Label}; use gtk::{Button, IconTheme}; use serde::Deserialize; use std::cmp::Ordering; @@ -85,6 +85,9 @@ fn create_button( let button = new_icon_button(label, icon_theme, icon_size); button.set_widget_name(name); + if let Some(label) = button.child().and_downcast::<Label>() { + label.set_use_markup(true); + } let style_context = button.style_context(); style_context.add_class("item"); ``` This permits to have right icons provided by `hyprland-autoname-workspaces`, but they don't update. In fact digging into the code I find we didn't listen for workspacerename events. The next challenge is to listen for rename events. Moreover I think we will need to refactor a little the way we manage those workspace. Currently we rely a lot on the workspace name (because the event API only send this info), the problem is that the name change with `hyprland-autoname-workspaces`: - we can have concurrency problems (the name we get may change before we request all workspaces, so we get `ERROR ironbar::clients::compositor::hyprland: 86: Unable to locate workspace`) - we also may have multiple workspaces with the same name (I have a triple monitor setup, and I may have multiple workspaces with the same name (I use [split-monitor-workspace](https://github.com/Duckonaut/split-monitor-workspaces)), fox exemple I have multiple workspaces named `<sub>1</sub> `)
Author
Owner

@JakeStanger commented on GitHub (Feb 24, 2024):

Thanks for this. I'm looking to enable pango support where possible, which is being tracked in #443 so feel free to open a PR for that. The other info sounds like it should be useful in fixing the issue Yavko linked above.

<!-- gh-comment-id:1962654109 --> @JakeStanger commented on GitHub (Feb 24, 2024): Thanks for this. I'm looking to enable pango support where possible, which is being tracked in #443 so feel free to open a PR for that. The other info sounds like it should be useful in fixing the issue Yavko linked above.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
JakeStanger/ironbar#2956
No description provided.