fruitcombo

go back

toggle between xfwm compositor and picom compositor

this is a script i made to toggle between xfwm's lightweight compositor and picom, which is beautiful but a bit resource intensive. it could be used as a template for toggling between any two processes. download here.

#!/bin/bash

switch_to_xfce() {
   kill $(ps aux | grep '[p]icom' | awk '{print $2}')
   sleep 0.5
   xfconf-query -c xfwm4 -p /general/use_compositing -s true
   echo "okay, switched to xfce compositor"
}

switch_to_picom() {
   xfconf-query -c xfwm4 -p /general/use_compositing -s false
   sleep 0.5
   nohup picom --experimental-backend 0/dev/null 2>/dev/null &
   echo "okay, switched to picom compositor"
}

if [[ $(ps aux | grep -ic '[p]icom') -eq 1 ]]; then
   switch_to_xfce
 else
   switch_to_picom
fi

surrounding the [p] in picom stops grep from finding its own process. nohup is there to divorce picom's process from the terminal so it keeps running after it's closed and the dev/null stuff is to suppress the message it outputs (nohup: ignoring input and appending output to 'nohup.out') which is irrelevant here.