Xfce compositing and compton keyboard shortcut toggle
In a previous post we addressed a simple way of enabling and disabling compositing in Xfce using a shell script. In this post we discuss how to do the same with compton, as well as some additions made to the original script.
So, without further ado, the relevant code:
#!/bin/sh if [ `pidof compton` ]; then # Comment the line below to disable notifications notify-send -t 400 'Disabled compton' --icon=video-display # Kill compton killall compton else # Comment the line below to disable notifications notify-send -t 400 'Enabled compton' --icon=video-display # Start compton as a daemon compton -b fi exit
The difference here is that it will send a message to the notification daemon. This line may be commented out (or deleted) by those who wish not to have that feature.
To achieve the same for XFWM4 compositing, we must change our old script to the following:
#!/bin/sh status=$(xfconf-query -c xfwm4 -p /general/use_compositing) xfconf-query -Tc xfwm4 -p /general/use_compositing # Comment the lines below to disable notifications if [ $status = "false" ]; then notify-send -t 400 'Enabled compositing' --icon=video-display else notify-send -t 400 'Disabled compositing' --icon=video-display fi exit
As before, name the file whatever you wish (I named mine compositing.sh), mark it executable with
chmod u+x compositing.sh and assign it as a keyboard shortcut.