I’ve been making a docker container for JRiver Media Center. I had to do some hackery to prevent the window from being minimizeable and other Option Windows popping up behind the Main window and leaving you in a state where you cannot do anything.
This works fine when I’m executing the script with screen, but does not work without it.
You can find the container here https://gitlab.shio.at/max/jrivermc25-docker
Anyways, the script in question is xpropspy.sh witch is called that because I pipe the output of xprop -root -spy into it.
The script being
while read line; do
echo "[$(date +%d-%m-%Y_%H-%M-%S)] Received: $line" >> /tmp/xpropspy.log
search=$(echo "$line" | grep "_NET_ACTIVE_WINDOW(WINDOW): window id # ")
echo "[$(date +%d-%m-%Y_%H-%M-%S)] Search: $search" >> /tmp/xpropspy.log
if [ ! -z "$search" ]; then
hex=$(echo "$line" | cut -c41-)
echo "[$(date +%d-%m-%Y_%H-%M-%S)] Hex: $hex" >> /tmp/xpropspy.log
clients=$(obxprop --root | grep '^_NET_CLIENT_LIST(WINDOW)' | grep -o '[0-9]\+')
echo "$clients" >> /tmp/xpropspy.log
if [ "$hex" == "0x0" ]; then
echo "Entering 0x0 if..." >> /tmp/xpropspy.log
switch_to=$(echo $clients | awk '{print $NF}')
echo "[$(date +%d-%m-%Y_%H-%M-%S)] Changing Window to: $switch_to" >> /tmp/xpropspy.log
wmctrl -i -a $switch_to
else
echo "False '$hex' != '0x0'" >> /tmp/xpropspy.log
fi
fi
done
Now to the logging when minimizing a window this logs
[21-07-2019_17-43-28] Received: _NET_ACTIVE_WINDOW(WINDOW): window id # 0x0
[21-07-2019_17-43-28] Search: _NET_ACTIVE_WINDOW(WINDOW): window id # 0x0
[21-07-2019_17-43-28] Hex: 0x0
18874427
False '0x0' != '0x0'
Currently, I have no idea why this possibly would evaluate to false and even less idea why this works when running the script with screen. The working code is in the master branch. The currently failing one in the dev branch.
And the reason I want to change this is, simply because screen exits instantly. So right now screen -l is called so often that it does use quite a lot more cpu than this should use (because s6-overlay assumes the service is dead, then runs the run script… again… and again and so forth). I could add a sleep or something like that, but I’d rather just get rid of screen entierly.