Clear entire xwindow label if no window is open#1136
Conversation
|
It already does here: |
|
Sorry, maybe I didn't express myself clearly. I want the "Window: " part to be shown, but it only makes sense to be shown when there actually is an active window. IMO, the desired behavior should be as follows: Terminal window active -> output: "Window: Terminal" while the current behavior is No window active -> output: "Window: " I doubt anyone wants that stray "Window: " part or a window icon without any text to replace |
|
Maybe it's easiest explained with pictures. So this is what I want, see how there's a window icon in front the window's name: However, the current behavior when there isn't an active window is the following (the icon is still there and looks ugly), and there's currently no way to change this: I changed this behavior to the following: |
|
I understand now. I think it should be set as an option (like |
|
I would prefer, if another label or format was used to keep it consistent with what other modules do |
|
Ok, I guess the most consistent way would be to use two labels |
|
Yeah, almost. Either create a second format |
|
Alright this should do :) |
patrick96
left a comment
There was a problem hiding this comment.
Works perfectly! Just two minor changes and I'll merge this.
| m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%title%"); | ||
| m_statelabels.insert( | ||
| make_pair(state::ACTIVE, load_optional_label(m_conf, name(), "label", "%title%"))); | ||
| m_statelabels.insert( |
There was a problem hiding this comment.
Use emplace, it saves you the make_pair call
| m_label->replace_token("%title%", m_active ? m_active->title() : ""); | ||
| m_label->replace_token("%title%", m_active->title()); | ||
| } else { | ||
| m_label = m_statelabels.find(state::EMPTY)->second->clone(); |
There was a problem hiding this comment.
Using .at(..) instead of .find(..) saves you ->second
|
Here ya go. Hit me up if you want me to squash commits and/or follow some kind of commit naming scheme! |
|
We're gonna squash and merge this one anyway, but in the future try to follow the de facto standard git commit message rules and also try to structure structure the first line as Where purpose is what the commit does and is usually |
Breaking Changes: * `0 < label-NAME-maxlen < 3` will now throw an exception and disable the containing module, if ellipsis is enabled for that label. (#1198) Changelog: Deprecations: * `internal/volume` is now called `internal/alsa` (#967) * temperature: The `%temperature%` is deprecated in favor of `%temperature-c%`(#897) * mpd: `icon-repeatone` is deprecated in favor of `icon-single` (#1295), see #1279 Features: * feat(mpd): Add support for icon-consume (#861) * feat(bspwm): Add workspace separator (#942) * feat(i3): Add workspace separator (#938), see #929 * feat(build): Make polybar build on FreeBSD (#931, polybar/xpp#8), see #239 * feat(volume): Add pulseaudio backend (#779) * feat(script): Add %pid% token for tail commands (#934) * feat(temp): Add temperature tokens without unit (#897) * feat(memory): Add memory used/free ramp (#1038), see #1037 * feat(memory): Add swap tokens (#1018) * feat(net): Add unknown-as-up option (#1077), see #457 * feat(config): Support fractional size and offset (#972), see #953 * feat(xwindow): Add label-empty (#1136) * feat(battery): Add animation-discharging (analog to animation-charging) (#1190) * feat(config): Support pixel offset for bar size and offset values (#1224) * feat(mpd): Add `%album-artist%` token (#1263) * feat(net): Add local_ip6 token (#1239), see #1234 * feat(net): Add nl80211 support (#1009), see #277 Fixes: * fix(mpd): Wrong elapsed time when after standby (#921), see #915 * fix(config): Wrong min, maxlen when using the same token multiple times (#974), see #971 * fix(battery): use power_now correctly (#958), see #928 * fix(mpd): Crash when mpd isn't running (#983), see #979 * fix(xworkspaces): Respect 'enable-scroll' (#1002) * fix(xbacklight): Respect 'enable-scroll' (#1014) * fix(build): support xcb-proto >=1.13 (polybar/xpp#11), see #973 * fix(mpd): Respect MPD_HOST env variable (#1025), see #1007 * fix(i3): Reconnect i3 IPC socket on restart/error (#1099), see #762 * fix(cursor): Occasional crash on mouseover (#1124), see #1117 * fix(net): Mark 'not connected' on querying failure (#1171), see #1163 * fix(gcc): Fix -Wstringop-truncation warning (#1216, polybar/i3ipcpp#7), see #1215 * fix(builder): Don't truncate colors with same channels (#1217), see #1183 * fix(bspwm): Consistent behavior when scrolling through multiple desktops (#986), see #981 * fix(builder): Respect label-ellipsis option (#1198), see #1194



If you use the current config file in the wiki entry for the xwindow module, not having an active window will still result in "Window: " being displayed in the bar. This doesn't really make sense IMO, so I added an if statement to clear the entire label (including the "Window: ") if there is no active window.
I could also add an option to make this configurable, but I don't really see why anyone would want the "Window: " to be displayed.