Skip to content

Posts tagged ‘Xfce’

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:

For compton:

#!/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.

Xfce – Set a keyboard shortcut for compositing toggle

I use Xfce as my primary desktop environment, and recently, I found the need to disable and enable compositing on a regular basis. This led to my search for a way to do this via keyboard shortcuts, as it was quite inconvenient to have to open the Window Manager Tweaks GUI each time to simply toggle a check box.

So, I discovered xfconf-query, and upon some further reading, came to this as the quickest possible way of doing it via the command line:

xfconf-query -Tc xfwm4 -p /general/use_compositing

Create file compositing.sh using the editor of your choice, with the following content:

#!/bin/sh
xfconf-query -Tc xfwm4 -p /general/use_compositing

Make the file executable:

chmod u+x compositing.sh

Now open Menu > Settings > Keyboard > Application shortcuts > Add

Voila! Enjoy switching compositing on and off as and when you need to.