Page 1 of 1

If "only when idle" doesn't work

Posted: Wed Mar 25, 2020 6:45 pm
by Barberousse
On my Kubuntu 19.10 distribution, "only when idle" does nothing.

To get the same behavior, I changed my config like that (/etc/fahclient/config.xml) removing "idle" option and adding "pause-on-start" option on slots :

Code: Select all

  <!-- Client Control -->
  <fold-anon v='true'/>

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

  <!-- User Information -->
  <passkey v='xxxxx'/>
  <team v='xxx'/>
  <user v='xxxxxxxxxx'/>

  <!-- Folding Slots -->
  <slot id='0' type='CPU'>
    <pause-on-start v='true'/>
    <paused v='true'/>
  </slot>
  <slot id='1' type='GPU'>
    <pause-on-start v='true'/>
    <paused v='true'/>
  </slot>
I created a testmonitor script in my /home/user/bin directory

Code: Select all

#!/bin/bash

CMD=/usr/bin/FAHClient
SLEEP_INTERVAL_ON=60
SLEEP_INTERVALL_OFF=10

sleep_interval=$SLEEP_INTERVAL_ON

while true; do

if xset -q | grep -q "Monitor is Off"; then
    new_state=off
else
    new_state=on
fi


if [ "$new_state" != "$old_state" ]; then
    old_state="$new_state"
    if [ "$new_state" == "on" ]; then
        $CMD --send-pause
        sleep_interval=$SLEEP_INTERVAL_ON
    else
        $CMD --send-unpause
        sleep_interval=$SLEEP_INTERVAL_OFF
    fi
fi

sleep $sleep_interval

done
then

Code: Select all

chmod +x /home/user/bin/testmonitor
I added the script to be started automatically on session start:

Code: Select all

kcmshell5 autostart
and added testmonitor as "script" file at startup.

At next session start, the folding will start only when screen is OFF, for instance when you set up DPMS ON on your screen as power saving option.

Re: If "only when idle" doesn't work

Posted: Wed Mar 25, 2020 7:00 pm
by bruce
The IDLE status is detected by the OS and traditionally was used to invoke a screensaver. People no longer use screensavers but one can be used to detect when the OS is telling FAH that it's idle.

Pause-on-start is totally different. It inhibits FAHClient from starting folding immediately after a reboot by initially invoking the FAH PAUSE function for that slot (or all slots).

You can manage the FAHCore activies my manually invoking the PAUSE/UNPAUSE functions or you can expect FAH to do that for you by waiting until the OS indicates taht the Mouse/Keyboard haven't been used recently.

That's pretty much what your script does.

Re: If "only when idle" doesn't work

Posted: Sat Apr 04, 2020 4:19 pm
by Peter Leslie Goulden
Thanks Barberousse. I used your script as the basis for a solution on my Linux Mint Cinnamon system with only a few minor modifications to suit my setup. There's also one bug fix. I see this as a temporary workaround until the FAH Client maintainers get around to fixing 'On Idle' properly in the Client as I'm yet to be convinced it works at all in Linux.

Here's my slightly modified version of your testmonitor script:

Code: Select all

#!/bin/bash

CMD=/usr/bin/FAHClient
SLEEP_INTERVAL_ON=60
SLEEP_INTERVAL_OFF=10

sleep_interval=$SLEEP_INTERVAL_ON

while true; do

if [ `xprintidle` -ge $(($SLEEP_INTERVAL_ON * 1000)) ]; then
    new_state=idle
else
    new_state=busy
fi


if [ "$new_state" != "$old_state" ]; then
    old_state="$new_state"
    if [ "$new_state" == "busy" ]; then
        $CMD --send-pause
        sleep_interval=$SLEEP_INTERVAL_ON
    else
        $CMD --send-unpause
        sleep_interval=$SLEEP_INTERVAL_OFF
    fi
fi

sleep $sleep_interval

done
The changes are:
1. Correction to SLEEP_INTERVALL_OFF=10 to remove superfluous 'L'.
2. Changed state names to suit my personal taste.
3. Modified to use xprintidle, which has to be installed on your system, instead of xset. I did this because I wanted the client to activate after only 1 minute of inactivity, rather than when my monitor goes to sleep, which is 30 minutes on my system. (That's 29 wasted minutes, otherwise. :eo )

I set mine to run from 'Startup Applications' on my Mint system rather than using your kcmshell5 command. It's very simple but if anyone needs clear instructions on how to do this then please just ask.

I didn't bother with the client config 'pause-on-start' change. I wasn't sure what it brought to the party.

Re: If "only when idle" doesn't work

Posted: Sat Aug 08, 2020 7:14 pm
by squidfr
bruce wrote: You can manage the FAHCore activies my manually invoking the PAUSE/UNPAUSE functions or you can expect FAH to do that for you by waiting until the OS indicates taht the Mouse/Keyboard haven't been used recently.
Hi @bruce

Allow me to piggy back on your answer. I'd like to avoid running additional scripts and only to use FAH to detect the user is away.
So, I am interested by knowing whether there are some settings I could tweak to have FAH actually detecting neither keyboard nor mouse have been used for some time ?

I have one compter running Manjaro and one running openSUSE Leap. None of them are able to get FAH detecting idling (in the way you define it).

Thanks!

Re: If "only when idle" doesn't work

Posted: Tue Aug 11, 2020 7:32 am
by PantherX
Welcome to the F@H Forum squidfr,

May I suggest that you first see how your OS defines and detect idle? Once you know that, the next step would be to set the client to fold when idle.

Re: If "only when idle" doesn't work

Posted: Tue Aug 11, 2020 4:49 pm
by bruce
What he said. :ewink:

It's the code in the OS that reports idle/not-idle to FAH. (In most cases, the same signal is observed by screen-saver code to open that app.)