3

My friend wanted to know if it is possible to get a patch that would allow him to set his computer to not suspend when he is using a video or music player, to include being on youtube? I wouldnt mind the same patch.

He is on a Toshiba and runs Ubuntu 11.10. I am on a hp and run Ubuntu 11.10 .

1
  • Can you add more detail to your question? Ubuntu doesn't suspend your system unless you either close the lid or set it to suspend. Dec 17, 2011 at 20:51

2 Answers 2

5
  1. Install xmacro (sudo apt-get install xmacro)

  2. Create a file called "myxmacro" and give it the following content:

Code:

MotionNotify 90 90 
MotionNotify 120 120

3. Create a file "no.idle.sh" and make it executable:

Code:

touch no.idle.sh
chmod +x no.idle.sh

4.4. Create a file "no.idle.sh" and make it executable: Code:

touch no.idle.sh
chmod +x no.idle.sh

Give it the following content:

Code

    #!/bin/bash
# No.idle.sh prevents GNOME to turn IDLE 
# if there is any sound sent to speakers
# This script requires the package "xmacro"
# (apt-get install xmacro)
###########################################
# This script requires a textfile called "myxmacro"
# with the following (dummy) content:
# ------------ myxmacro ------------
# MotionNotify 90 90 
# MotionNotify 120 120
# ----------------------------------
# You need to fix the path to "myxmacro" in line 31
#
#############################################

# set Log-File
LOG=/home/YOUR_USERNAME/noidle.log
sound=0
silence=0


while true; do
    sleep 1
    Datum=`date +%d.%m.%Y-%H:%M:%S`    

    # check if sound is sent to speaker    
    if pactl list | grep RUNNING > /dev/null; then
        echo "[$Datum] Sound (Ping: $sound)" >> $LOG
        sound=$((sound+1));
        xmacroplay :0 </path/to/myxmacro
        silence=0
    else
        echo "[$Datum] Silence (Ping: $silence)"    >> $LOG
        silence=$((silence+1));
        sound=0
    fi
    #----------------------------------------------------
done

You need to: - fix the path to the logfile in line 18

  • fix the path to "myxmacro" in line 31

    1. Add the script "no.idle.sh" to your GNOME-Startup-Items, so that no.idle.sh is running on every startup.

Done.

What the script does: The script checks every second, if there is any sound sent to the speakers (using the terminal command pactl list | grep RUNNING).

If music is running, it simulates mouse-movement (using xmacroplay). This has the effect, that your GNOME-session won't run IDLE (and as a result your PC won't suspend).

If there is no music played, it does nothing (so your session IS ABLE to run IDLE and after that suspends)

You can watch the script checking for music by typing in a terminal:

tail -f /path/to/noidle.log
1
  • 1
    There's a problem with these script that, while it does what it says, it doesn't let you work when music is playing.... Feb 21, 2012 at 21:05
1

I think caffeine prevents the screensaver from showing up (if this is what you mean).

http://www.webupd8.org/2009/10/caffeine-10-for-linux-released.html

https://launchpad.net/~caffeine-developers/+archive/ppa

https://launchpad.net/caffeine

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .