Script to replace Caffeine in XFCE4

Posted on 06 April 2016 in Linux

Main script

Dependences

xfconf
xdotool
xfce4-genmon-plugin
redshift

Description

The whole conception is designed around "Presentation Mode" that inhibits a screensaver and xfce4-power-manager. See a block diagram.

A bunch of Deadbeef-dedicated if-statements is necessary in order to get if Deadbeef playing music or not and treat an APP array in an appropriate way (it removes Deadbeef from the array if it's not playing music). As soon as the script reads itself it must be run with full path specified. You can alter the script if you favourite player allows to read its status via command line. If you don't use Deadbeef you can either delete this section or just leave it, it's not meant to be run unless Deadbeef is present in the APPS list.

SITES array contains a list of websites that trigger the script if is found opened in Firefox as active tab. Does nothing if Firefox is not running.

Code

To get the script run

git clone http://git.speran.info/suspendPM.git suspendPM

Configuration

You will want to edit the second line of suspendPM.sh script and put there a path there the script is stored. Add this command to Application Autostart list to start the script with a lock file in order to avoid it to be started multiple times.

sh -c "flock -n /$PATH/.bin/temp/suspendPM.lockfile -c /$PATH/.bin/suspendPM.sh"

Editions:

21.06.2016: Fixed a bug when an empty desktop was treated as full screen application.
23.06.2016: Regex mustn't be quoted! Fixed.
29.06.2016: only active Firefox tab is being checked.
01.07.2016: new way to look for an element in an array implemented.
08.07.2016: two scripts merged to one.
09.08.2016: redshift handling has been added. You will want to run the script with param "red" in cron to have "smart" redshift enabling/disabling based on full screen app is running or the "suspendPM" button on a panel has been pressed.

Additional sript

The script as separate one has been deprecated. You need to configure General Monitor to run the main script with "mon" parameter.

Description

It's necessary in order to add a panel button. That will allow you to toggle the presentation mode manually plus to see its current state. Add xfce4-genmon-plugin on a panel and configure it to run this script every second. So the command must look like

/path/to/the/script/suspendPM.sh mon

Conclusion

The only thing I would like to alter is to allow the system to switch off a screen when a player plays music.