ironbar
ironbar copied to clipboard
[Workspace] Workspace name based on the window title and/or class
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
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.
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
-
The bar now
-
Close one firefox window
-
Close the steam window, but the
worskpace 3
is active, ignore thenumber 3
being theworkspace 1
,ironbar
don't support, I'll talk more about it later -
Go to
workspace 1
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
...
- And we can go further using window class and title, the same scenario, but one firefox window is on youtube
$ 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.
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.
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>
)
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.