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

Skip to content

feat(script): %pid% token for tail commands#934

Merged
NBonaparte merged 2 commits into
polybar:masterfrom
patrick96:pid_token
Jan 21, 2018
Merged

feat(script): %pid% token for tail commands#934
NBonaparte merged 2 commits into
polybar:masterfrom
patrick96:pid_token

Conversation

@patrick96

@patrick96 patrick96 commented Jan 2, 2018

Copy link
Copy Markdown
Member

This can be used to send signals to the script running (e.g. SIGUSR1, etc) which
makes it easier to have an updatable state inside the script. With this, it is
for example possible to have a two-state date script:

[module/date]
type = custom/script
exec = /path/to/date.sh
tail = true
click-left = bash -c "kill -SIGUSR1 %pid%"

date.sh:

t=0

toggle() {
    t=$(((t + 1) % 2))
}


trap "toggle" USR1

while true; do
    if [ $t -eq 0 ]; then
        date
    else
        date --rfc-3339=seconds
    fi
    sleep 1 &
    wait
done

Todo:

  • Add to wiki

@NBonaparte

Copy link
Copy Markdown
Member

Not exactly relevant to this PR specifically but is Travis having some issues? The clang build failed here as well as for #931 and I had to restart the builds for it to pass.

@patrick96

Copy link
Copy Markdown
Member Author

I've had it once before where the travis build would suddenly fail for no reason. I think it's just a minor hickup.

@patrick96 patrick96 requested a review from NBonaparte January 6, 2018 17:50
@NBonaparte

Copy link
Copy Markdown
Member

Does this fix #720?

@patrick96

Copy link
Copy Markdown
Member Author

Does this fix #720?

No, it only adds a new token to the script module click commands nothing else. The output of a click command can still not be used inside the bar. However this makes it easier to notify a tail command about a click event, whereas before we would have to write to a certain file to share information with a tailed script.

@NBonaparte NBonaparte merged commit 1d9dd71 into polybar:master Jan 21, 2018
@NBonaparte

Copy link
Copy Markdown
Member

I put the example in the wiki as part of the examples section.

@patrick96 patrick96 deleted the pid_token branch February 1, 2018 20:15
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
patrick96 added a commit to patrick96/polybar that referenced this pull request Oct 4, 2018
If a tailed command is used polybar would generate two action tags, one
with %counter% replaced and one with %pid% replaced, but never both

This is a bug that was introduced in polybar#934
patrick96 added a commit to patrick96/polybar that referenced this pull request Oct 5, 2018
If a tailed command is used polybar would generate two action tags, one
with %counter% replaced and one with %pid% replaced, but never both

This is a bug that was introduced in polybar#934
NBonaparte pushed a commit that referenced this pull request Oct 9, 2018
If a tailed command is used polybar would generate two action tags, one
with %counter% replaced and one with %pid% replaced, but never both

This is a bug that was introduced in #934
patrick96 added a commit to patrick96/polybar that referenced this pull request Nov 17, 2018
If a tailed command is used polybar would generate two action tags, one
with %counter% replaced and one with %pid% replaced, but never both

This is a bug that was introduced in polybar#934
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.

2 participants