Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Set sleep timer to stop music
- export DIALOGRC=/usr/share/ziptuner/dialogrc.soho
- DIALOGSIZE="15 45"
- dialog --title "Radio Sleep/Shutoff Timer" --menu "How long before the music stops?" $DIALOGSIZE 8 5 minutes 10 minutes 20 minutes 30 minutes 45 minutes 60 minutes 90 minutes 2 hours 3 hours 2>/tmp/sleeptimer
- var=`cat /tmp/sleeptimer`
- rm /tmp/sleeptimer
- if [ "$var" -eq "$var" ] 2>/dev/null; then
- # Sleep, then run onStop
- if [ "$var" -le "4" ] 2>/dev/null; then
- ( sleep $(( var * 3600 )) && onStop ) &
- else
- ( sleep $(( var * 60 )) && onStop ) &
- fi
- dialog --title "Radio Sleep/Shutoff Timer" --infobox "Timer set for $var minutes" $DIALOGSIZE
- else
- # Not a number or user cancelled
- dialog --title "Radio Sleep/Shutoff Timer" --infobox "Invalid time or cancelled" $DIALOGSIZE
- fi
- sleep 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement