You are not logged in.
Hello good people of the Crunchbang forums. I figured if anyone knew the answer to this, they'd be here. Is there a way to do this with bash?
while :; do
...
...
<< wait for SIGUSR1 >>
done | ...Some clarification on what I'm trying to do, in case someone knows a different/better solution to this problem:
I'm trying to display mpd's currently playing song in a dzen2 bar. ncmpcpp can execute a command every time the song changes, so my idea was to setup a script called songchange.sh with the above construction and then make ncmpcpp execute "killall -SIGUSR1 songchange.sh". That way it would be much more performant than the usual construction where the script simply sleeps a few seconds every loop.
=======
EDIT:
After a lot of sweat and tears (it was fun as hell) I found a solution:
resume() {
kill $PID
}
trap resume SIGUSR1
while :; do
...
...
sleep 9999 &
PID=$!
echo $PID > $HOME/.barpid
wait $PID 2>/dev/null
done | ...Last edited by foozer (2013-05-15 16:54:31)
Offline
Small detail...
Why not put the trap ... command before the while? That way it only gets executed once, which is enough.
Not that you will notice the difference.
Groeten uit Eernegem 
Last edited by xaos52 (2013-05-14 13:45:05)
bootinfoscript - emacs primer - wireless problems- I ♥ #!
Offline
Small detail...
Why not put the trap ... command before the while? That way it only gets executed once, which is enough.
Not that you will notice the difference.
Groeten uit Eernegem
Hey, countryman!
Doing that gave me funny errors, but only when piping into dzen. Now that I try it again it works, so it must've been something else I was doing.
Offline
Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.