Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 .

share|improve this question
    
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. –  Jorge Castro Dec 17 '11 at 20:51

2 Answers 2

up vote 3 down vote accepted
  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
share|improve this answer
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.... –  Yossi Farjoun Feb 21 '12 at 21:05

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.