5

I've installed and configured Folding@Home:

$ lsb_release --all
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.10
Release:    19.10
Codename:   eoan
$ FAHClient --version
7.5.1
$ cat /etc/fahclient/config.xml 
<config>
  <!-- Network -->
  <proxy v=':8080'/>

  <!-- Slot Control -->
  <idle v='true'/>
  <power v='FULL'/>

  <!-- User Information -->
  <team v='[omitted]'/>
  <user v='[omitted]'/>

  <!-- Folding Slots -->
  <slot id='0' type='CPU'/>
  <slot id='1' type='GPU'/>
</config>

However, after starting the service never starts processing. If I toggle the client's idle setting it starts processing immediately, but then the machine is pretty much unusable for anything else, even if I reduce the power setting to medium. How can I make sure Folding@Home does work when, and only when, the machine is idle? That is, with no manual intervention it should start processing after a few minutes of idle time, and should immediately stop processing when no longer idle.

l0b0
  • 51,350
  • I had the exact same problem, and still have it after upgrading Ubuntu to 20.04 and FAHClient to 7.6.13. This is quite frustrating... – Pierre-Antoine May 22 '20 at 12:34

2 Answers2

1

I have exactly the same problem and the client never thinks my computer is idle. I ended up making a script that only resumes FAH when the screen is locked. It worked wonderfully. You can check here:

https://github.com/Madoshakalaka/gnome-folding-at-screenlock

Here are the full steps to get this working in case the repo goes down:

  1. Copy this service file to /home/YOUR_DESTOP_USER/.config/systemd/user/gnome-folding-at-screenlock.service
[Unit]
Description=FAH controller based on screen locking/unlocking signals

[Service] ExecStart=/usr/bin/gnome-folding-at-screenlock.sh

[Install] WantedBy=default.target

  1. Copy this shell script to your /usr/bin/gnome-folding-at-screenlock.sh and give it the executable permission with sudo chmod +x /usr/bin/gnome-folding-at-screenlock.sh.
#!/usr/bin/env sh

dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" |

Somehow I receive duplicate signals during locking and unlocking.

It's a weird behavior but does no harm in our case.

while read x; do case "$x" in "boolean true") echo "screen turns locked. Initiate folding" && FAHClient --send-unpause ;; "boolean false") echo "screen turns unlocked. Unfold! Unfold!" && FAHClient --send-pause ;; *) ;; esac done

  1. sudo systemctl enable foldingathome && sudo systemctl start foldingathome If you haven't already done so. Note our script won't start or stop the foldingathome service. It assumes the service is started and pauses/unpauses folding via FAHClient. The pause or unpause will be persisted in the configuration file located at /etc/foldingathome/config.xml.
  2. Go to the dashboard in your browser at http://localhost:7396/ and change some options. You should tick the "While I'm working" option because we are not relying on FAH's idle detection anymore. Also, you can set up your ideal power level too. Finally, stop the folding by hitting the "Stop Folding" button, which actually adds a <paused v='true'> tag to your config file (It does exactly the same thing our script does when you wake up your monitor).
  3. systemctl --user enable gnome-folding-at-screenlock.service. Do not run as root or with sudo because locking and unlocking is tied to your desktop user.
  4. systemctl --user start gnome-folding-at-screenlock.service. Do not run as root or with sudo.
  5. Done! Now you can just hit super + l and lock the screen whenever you will be away from the computer. Proteins will start folding right away! When you are back, unlock your computer, and the folding will pause immediately!
  6. For bonus points, go to GNOME's Settings > Power and turn off automatic suspension, otherwise no extended folding will be possible. By default, suspension happens after 20 minutes of inactivity, this will stop FAH too.
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
0

Here's my quick-and-dirty solution, inspired by the answer at https://unix.stackexchange.com/a/259963.

#!/bin/bash

let TIMEOUT_MINUTES=5 let TIMEOUT_MS=TIMEOUT_MINUTES*60000

while [ 0 ] do IDLE=$(xprintidle) if [ $IDLE -lt $TIMEOUT_MS ] then FAHClient --send-pause else FAHClient --send-unpause fi sleep 15 done

Just change the TIMEOUT_MINUTES and sleep values to your liking and then set up it up to start at login.

If xprintidle isn't in your repo, as was my case in running Fedora 37, you can build it from source (available at https://github.com/g0hl1n/xprintidle).

David Yockey
  • 1,834