I have noticed compton and libre office do not play nice. See below for details:
The above being the case, i am trying to write a little bash script loop to turn Compton off whenever Libreoffice is open. See below:
while : do sleep 5 if [ "$(pidof oosplash)" ] then killall compton else compton fi done
It works to switch off Compton if I open Lbreoffice and then switches Compton back on if I close Libreoffice, but then it gets stuck and doesn't do anything from that point. In other words, if I reopen libreoffice, it no longer switches Compton off. I have run it in a terminal to see if it gives a message, but it displays nothing. It just hangs there never going back round the loop.
I've tried replacing "if [ "$(pidof oosplash)" ]" with " if pgrep "oosplash" > /dev/null"
It is just the same...works once, then gets stuck.
I think it would work better if you use the script as a launcher for libreoffice, so it executes every time you want to open libreoffice. Something like:
killall compton
libreoffice
compton
You can also keep the original script running by using something like while true = true, but that wouldn’t be very nice or efficient, and you would also need to check that compton is not already running (i.e.
elif [ $(pgrep -c “compton”) -eq 0 ] ; then
compton ).
I tried that but i can;t do it for the following reason:
If you take a look at the libre office launchers in the menu, you will notice that they are suffixed with “%U”. This allows one to double click a libreoffice file and have it open inside the appropriate libre office application. However, if I include that in a series of commands in a script like
killall compton
libreoffice --calc %U
compton
it fails with the following message:
/home/stephen/%U does not exist.
If I omit the “%U”, then libre office will open. But, if I also try and open libreoffice indirectly by double clicking a file, then it opens, but as a blank file and so I must then manually navigate to the file.
All of which is why I am trying to deal with Compton independently in a way that does not interfere with the usual way that Libre office operates but, instead, simply looks to see if it is running
Can you be more specific with regards to the exact syntax vis a vis my script and the suggestion of modification to it you have suggested? I am not a scripter and so need idiot proof instructions
A “slave” script that has the following content:
if pgrep "oosplash" > /dev/null
then
killall compton
else
compton
fi
And a “master” script with the following:
sleep 10
while true; do cd /home/stephen/my-bash-scripts; sudo sh ./kill-compton-if-libreoffice-running-slave.sh; sleep 5; done
It still hangs in exactly the same way. And i have no idea why. Though, i suspect, it may be because the "slave2 acript is somehow stuck and the master can’t repeat it.
I am going to add in a kill command to the slave script in the master script loop before it is reinvoked in the loop and see what happens
There’s nothing wrong with the original loop actually (I didn’t know that syntax worked that way), in my machine the problem seems to be that when you run the command compton it doesn’t release the terminal, so the script doesn’t advance from that point.
It’s weird because if I open one terminal up and type “compton” it will hang there running Compton unless I type CTRL/C. Which is all well and good and as one should expect.
But, if I open another terminal and type “killall compton”, the first terminal is released from Compton with the the output “Terminated” and it goes back to the command prompt.
So, killing it in real time manually does seem to release the terminal
So, if the “compton”, and possibly the “killall compton” part of the script is not allowing progress, could that (or those) command/s be hived off and so called from a separate script/s?
If this script is invoked from the menu launcher instead of invoking the default command, it opens from the menu correctly. Furthermore, it also opens correctly when indirectly opened via a double-clicked file