Closed absolutelynothelix closed 1 year ago
What is a the "role" of a window? What do you mean? @mighty9245
@emanuele6, the WM_ROLE
window property
@mighty9245, I've never heard of it, but most windows don't have it: I tried checking the WM_ROLE
of an urxvt
window (see screenshot) and of a qutebrowser
window and they both didn't have it.
Since most window don't even have this I don't see the point of being able to match windows via this atom when using bspc rule
. You can easily just check the output of xprop -id "$1" WM_ROLE
in your external_rules_command
script if you want to apply a rule based on that atom.
Are you sure this is a standard atom? I can't find any reference to it online. Keep in mind that any atom can be set/created; e.g.:
xprop -id "$(pfw)" -format HELLO_WORLD 8s -set HELLO_WORLD 'hi there'
(set the focused window's HELLO_WORLD
atom to hi there
)
oh, it's called WM_WINDOW_ROLE
, my bad. i don't have much apps to test, but at least firefox, discord, atom and thunar have it.
WM_WINDOW_ROLE
@mighty9245, I tried checking it on urxvt
and qutebrowser
and they didn't have it. I also checked on telegram-desktop
and zathura
and it doesn't have it. I even tried polybar
and it doesn't have it.
That's basically all the GUI programs I use, none of them have it!
It clearly is not as used as WM_CLASS
and WM_NAME
, you can just xprop -id "$1" WM_WINDOW_ROLE
in your external rules script if you want to make a rule based on that; as you would do with the other uncoventional/custom atoms.
@mighty9245, I just tried checking it on krita
and it has it:
$ xprop -id "$(xdo id -Nkrita -nkrita | head -1)" WM_WINDOW_ROLE
WM_WINDOW_ROLE(STRING) = "MainWindow#1"
Most programs don't have it though; there is no point in allowing to set a rule based on this atom that most windows don't even have!
You can use:
#!/bin/env bash
wid="$1"
class="$2"
instance="$3"
window_role="$(xprop -id "$wid" WM_WINDOW_ROLE | sed -nE 's,^WM_WINDOW_ROLE[(]STRING[)] = "(.*)"$,\1,p')"
[[ "$class" = krita && "$instance" = krita && "$window_role" = MainWindow#1 ]] \
&& echo layer=below
(apply layer=below
to windows which have class=krita
, instance=krita
and WM_WINDOW_ROLE
=MainWindow#1
)
This also has the benefit that you can use regular expression matching, i.e.
[[ "$class" = krita && "$instance" = krita && "$window_role" =~ ^MainWindow# ]] \
&& echo layer=below
(apply layer=below
to windows which have class=krita
, instance=krita
and WM_WINDOW_ROLE
that starts with MainWindow#
)
I don't know how a WM_WINDOW_ROLE
atom looks in general, but if they looks like krita
's (i.e. something#n
), you probably want regex matching or a custom matching anyway.
i'm not using bspwm anymore, so i'm closing this to reduce the amount of open issues.
can we have some love for rules? currently we can match windows either by class name or by instance name. it would be amazing if we could also match them by at least role.
i know about
external_rules_command
but i think matching windows by rule is basic enough to be implemented on our own.if you're wondering, i'm trying to write a rule for firefox's picture-in-picture window and probably the only thing that allows to identify it is it's role.
i know that most likely i won't get any reply on this, but... hope dies last