Fold only when Ubuntu/Linux Mint screensaver enabled
Posted: Fri Jan 15, 2021 7:40 pm
I think the Folding@Home client relies on xscreensaver to check if a Linux machine is idle, but this has been replaced with cinnamon-screensaver in newer Ubuntu and Linux Mint versions.
To get idle detection working again, there are two possible solutions:
Note 2: Remove any "On idle" settings on the slots or client first - we're going to explicitly pause and unpause the slots when the screensaver enables, rather than relying on the broken idle detection.
Note 3: Set "pause-on-start" to "True" on any slots that you're controlling with this script, if you don't want to fold until you've logged in and started the screensaver.
Note 4: It is assumed that you want the screensaver to control slot 01 (the GPU) here. Adjust the script as needed by changing the slot number, remove the slot number if you want to control the whole client, or just add command lines.
Run
And put this in the file, then save it with Ctrl+o, accept with filename, then exit with ctrl+x:
To keep the script running at every reboot, run
enter this in the file and save it:
To get idle detection working again, there are two possible solutions:
- Put xscreensaver back. (I don't recommend this, but if you want to try, here's the guide for that: https://forums.linuxmint.com/viewtopic.php?t=284037)
- Use a custom idle-detect script. Credit for this goes to Norbert Preining's blog post "Changing cinnamon’s lockscreen background". The rest of this post explains how. It has been tested in Linux Mint 20, but should work in most Linux distributions using cinnamon-screensaver:
Note 2: Remove any "On idle" settings on the slots or client first - we're going to explicitly pause and unpause the slots when the screensaver enables, rather than relying on the broken idle detection.
Note 3: Set "pause-on-start" to "True" on any slots that you're controlling with this script, if you don't want to fold until you've logged in and started the screensaver.
Note 4: It is assumed that you want the screensaver to control slot 01 (the GPU) here. Adjust the script as needed by changing the slot number, remove the slot number if you want to control the whole client, or just add command lines.
Run
Code: Select all
sudo pico /usr/local/bin/cinnamon-lockscreen-folding.sh
Code: Select all
#!/bin/bash
# Check for existing instances and kill them leaving current instance running
for PID in $(pidof -o %PPID -x "${0##*/}"); do
if [ "$PID" != $$ ]; then
kill -9 "$PID"
fi
done
dbus-monitor --session "interface='org.cinnamon.ScreenSaver', member='ActiveChanged'" | while read -r msg
do
case "$msg" in
"boolean true")
# Unpause command(s) for when screensaver enables. The number is for the folding slot. Leave out the number to unpause the whole client:
FAHClient --send-unpause 01
;;
"boolean false")
# Pause command for when desktop in use:
FAHClient --send-pause 01
;;
*) ;;
esac
done
Code: Select all
pico ~/.config/autostart/cinnamon-lockscreen-folding-autostart.desktop
Code: Select all
[Desktop Entry]
Type=Application
Exec=/bin/bash /usr/local/bin/cinnamon-lockscreen-folding.sh
X-GNOME-Autostart-enabled=true
NoDisplay=false
Hidden=false
Name=cinnamon-lockscreen-folding.desktop
Comment=Change folding
X-GNOME-Autostart-Delay=1