Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Clear entire xwindow label if no window is open#1136

Merged
patrick96 merged 2 commits into
polybar:masterfrom
kenogo:master
Apr 1, 2018
Merged

Clear entire xwindow label if no window is open#1136
patrick96 merged 2 commits into
polybar:masterfrom
kenogo:master

Conversation

@kenogo

@kenogo kenogo commented Mar 31, 2018

Copy link
Copy Markdown

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.

@NBonaparte

Copy link
Copy Markdown
Member

It already does here: m_active ? m_active->title() : "". Just leave the label as %title% (or don't set it at all so it will be set as default to that) and no "Window: " will be shown.

@NBonaparte NBonaparte closed this Mar 31, 2018
@kenogo

kenogo commented Mar 31, 2018

Copy link
Copy Markdown
Author

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"
No window active -> no output

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 %title%. Maybe that is the behavior you want, though. I don't know, just wanna be sure you understand what I mean, since the m_active ? m_active->title() : "" does something very different from what I implemented here.

@kenogo

kenogo commented Mar 31, 2018

Copy link
Copy Markdown
Author

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:

bildschirmfoto_2018-04-01_00-49-07

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:

bildschirmfoto_2018-04-01_00-52-00

I changed this behavior to the following:

bildschirmfoto_2018-04-01_00-49-32

@NBonaparte

Copy link
Copy Markdown
Member

I understand now. I think it should be set as an option (like no-window-blank = true) or create another label just for this purpose, because otherwise this behaviour deviates from what is normally expected.

@NBonaparte NBonaparte reopened this Mar 31, 2018
@patrick96

Copy link
Copy Markdown
Member

I would prefer, if another label or format was used to keep it consistent with what other modules do

@kenogo

kenogo commented Apr 1, 2018

Copy link
Copy Markdown
Author

Ok, I guess the most consistent way would be to use two labels label-active and label-unactive? I can start working on this.

@patrick96

Copy link
Copy Markdown
Member

Yeah, almost. Either create a second format format-empty and let it have a separate label like label-empty (similar to what the network module does), or just have a second label and use label, if there is a window title and label-empty when there is not (this is what the xworkspaces module does wher <label-state> is replaced depending on the module state). The main label needs to be called label though, because it would break polybar configs when changed.

@kenogo

kenogo commented Apr 1, 2018

Copy link
Copy Markdown
Author

Alright this should do :)

@patrick96 patrick96 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works perfectly! Just two minor changes and I'll merge this.

Comment thread src/modules/xwindow.cpp Outdated
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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Use emplace, it saves you the make_pair call

Comment thread src/modules/xwindow.cpp Outdated
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();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Using .at(..) instead of .find(..) saves you ->second

@kenogo

kenogo commented Apr 1, 2018

Copy link
Copy Markdown
Author

Here ya go. Hit me up if you want me to squash commits and/or follow some kind of commit naming scheme!

@patrick96

patrick96 commented Apr 1, 2018

Copy link
Copy Markdown
Member

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 purpose(target): msg

Where purpose is what the commit does and is usually fix or feat (for feature) and target is the name of the component your commit is affecting. Just target: msg is also fine. See our commit history for some examples

@patrick96 patrick96 merged commit d31570f into polybar:master Apr 1, 2018
patrick96 added a commit that referenced this pull request Jul 23, 2018
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
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.

3 participants