我已經安裝並配置了 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>
但是,啟動服務後永遠不會開始處理。如果我切換客戶的idle
設定它立即開始處理,但是即使我將設定降低power
到中等,機器幾乎無法用於其他任何事情。如何確保 Folding@Home 在且僅在機器空閒時才工作?也就是說,在沒有人工幹預的情況下,它應該在幾分鐘的空閒時間後開始處理,並在不再空閒時立即停止處理。
答案1
我有完全相同的問題,客戶從不認為我的電腦空閒。我最終製作了一個腳本,僅在螢幕鎖定時恢復 FAH。效果非常好。您可以在這裡查看:
https://github.com/Madoshakalaka/gnome-folding-at-screenlock
以下是儲存庫發生故障時使其正常運作的完整步驟:
- 將此服務文件複製到
/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
- 將此 shell 腳本複製到您的
/usr/bin/gnome-folding-at-screenlock.sh
並為其授予可執行權限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
sudo systemctl enable foldingathome && sudo systemctl start foldingathome
如果您還沒有這樣做。請注意,我們的腳本不會啟動或停止foldingathome
服務。它假設服務已啟動並通過 暫停/取消暫停折疊FAHClient
。暫停或取消暫停將保留在位於 的設定檔中/etc/foldingathome/config.xml
。- 轉到瀏覽器中的儀表板
http://localhost:7396/
並更改一些選項。您應該勾選“當我工作時”選項,因為我們不再依賴 FAH 的空閒檢測。此外,您也可以設定理想的功率等級。最後,透過點擊「停止折疊」按鈕來停止折疊,這實際上會<paused v='true'>
在您的設定檔中添加一個標籤(它與我們的腳本在喚醒顯示器時所做的事情完全相同)。 systemctl --user enable gnome-folding-at-screenlock.service
。不要以 root 身份或使用 sudo 運行,因為鎖定和解鎖與您的桌面用戶相關。systemctl --user start gnome-folding-at-screenlock.service
。不要以 root 身分或使用 sudo 運行。- 完畢!現在,只要您離開計算機,只需按super+即可鎖定螢幕。l蛋白質將立即開始折疊!當你回來後,解鎖你的電腦,折疊就會立即暫停!
- 為了獲得獎勵積分,請前往 GNOME
Settings > Power
並關閉自動暫停,否則將無法進行擴展折疊。預設情況下,20 分鐘不活動後會暫停,這也會停止 FAH。
答案2
這是我的快速而骯髒的解決方案,靈感來自於答案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
只需根據您的喜好更改TIMEOUT_MINUTES
和sleep
值,然後將其設定為在登入時啟動。
如果xprintidle
您的儲存庫中沒有,就像我運行 Fedora 37 時的情況一樣,您可以從原始程式碼建置它(可在https://github.com/g0hl1n/xprintidle)。