1

I'm on Ubuntu 16.04 and I have a few little bash aliases set up like this:

alias radio='cvlc http://internet/radio/stream.pls -q'

so I can just quickly fire up some music in Bash. Is there a command I can add to disable suspend while VLC is running and enable it again when I exit VLC? I know I can change the power settings but I'd rather not do that every time I want to play some Internet radio. What's a better general solution?

0

I wrote an answer to the question: How to make Ubuntu beep (a few seconds) before suspend? a few days ago, I'm going to use the same concept for your situation.

Install xdotool package:

sudo apt install xdotool

Create a script, save it somewhere you like:

#!/bin/bash
sleep 2
while [ `pgrep -x vlc` ]
do
 xdotool key shift 
 sleep 60;
done

Change you alias to:

alias radio='bash ~/path/myscript.sh & cvlc http://internet/radio/stream.pls -q'

Now this script makes some fake activities every minute while vlc is running so your computer is not going to sleep.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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