Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 1292  / 2 Years ago, fri, may 6, 2022, 12:41:38

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 .


More From » video

 Answers
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

[#41409] Saturday, May 7, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
laceanz

Total Points: 86
Total Questions: 113
Total Answers: 104

Location: Australia
Member since Thu, Jan 26, 2023
1 Year ago
;