PDA

View Full Version : Help with Keeping/Looping an Active Script



jakfish
February 22nd, 2019, 10:17 PM
Hello, All,

Running Mate 18.3 on a 7" GPD Pocket 1, I'm trying to remove the text of Chromium's window title bar. I've gotten pretty far, but I'm stuck on executing a pkill command upon closing Chromium:



#!/bin/bash
if [[ $(pgrep chromium-browse) ]]
then
mate-terminal --command /home/jake/Scripts_Icons/chro_watch3 ##chro_watch3 is script running only one command: watch --exec bash -c 'wmctrl -r Chromium -T " "'##
else
sudo pkill -INT watch
fi
exit 0


Successful tests:

a) script starts watch command if chromium-browse is running in processes

b) script will not start watch command if chromium-browse is not running in processes

The rub is that the script ends once chromium and watch command are started, and I need it to keep running so that when I close chromium, a pkill -INT watch command will be sent.

I've looked hard, but I haven't figured out how to do this, and I'd be appreciative of any help.
Jake

freemedia2018
February 23rd, 2019, 01:50 AM
Like this?


while [[ 1 ]]
do echo you can say that again
sleep .5
done

jakfish
February 23rd, 2019, 04:39 AM
Many thanks for your post/help.

I had already tried:

while [ 1 ]; do wmctrl -r chromium -T " " ; done

but it gives a 30% spike in cpu usage and I've yet to figure out why. That's why I turned to the watch command, since it was less aggressive.

Jake

spjackson
February 23rd, 2019, 10:33 AM
I had already tried:

while [ 1 ]; do wmctrl -r chromium -T " " ; done

but it gives a 30% spike in cpu usage and I've yet to figure out why. That's why I turned to the watch command, since it was less aggressive.

What you are missing from freemedia2018's example is a sleep.