Wednesday, October 12, 2011

[LINUX_Newbies] Re: Audible internet disconect sound?

 


> You might want to make sure you change the sleep time to something
> more reasonable... the way that loop is set up, in theory, it'll fire
> off another vlc instance for every second that the link is
> disconnected.
>
> Maybe change it back to 60 (your original value). That way, at least,
> you'll have a minute when the alarm goes off to sort it out before the
> loop ticks again and it fires off another vlc... (I'm assuming here
> that it'll keep opening vlcs over and over, instead of just restarting
> the existing one... YMMV because that's a big assumption I've not
> tested)
>

When testing using mplayer or vlc, the instance of the player would start and would not continue untill I closed the program (only one instance)

>
> errrr.... replace vlc with gnome-mplayer for everything I just said ;-)

Here's the final version of my script, it now plays the sound within the terminal, and continues to play the sound every 30 seconds. (sound bit is 4 seconds long) So I have 27 seconds to sort it out after the alarm goes off.
uses the terminal instance (no GUI) of mplayer instead of gnome-mplayer

#!/bin/bash

IFACE="ttyUSB0"
SLEEP_TIME="30s"
SOUND_FILE='/home/grant/connection_script/warningredalert.mp3'
WORKING_TEXT='STILL CONNECTED'

while true; do
[ "$(nmcli dev status | grep $IFACE | awk '{print $3'})" == "disconnected" ] && mplayer $SOUND_FILE || echo $WORKING_TEXT
sleep $SLEEP_TIME
done

__._,_.___
Recent Activity:
To unsubscribe from this list, please email LINUX_Newbies-unsubscribe@yahoogroups.com & you will be removed.
MARKETPLACE

Stay on top of your group activity without leaving the page you're on - Get the Yahoo! Toolbar now.

.

__,_._,___

No comments:

Post a Comment