Advertisement
Guest User

sleeptimer_menu

a guest
Mar 25th, 2017
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/bin/sh
  2. # Set sleep timer to stop music
  3.  
  4. export DIALOGRC=/usr/share/ziptuner/dialogrc.soho
  5. DIALOGSIZE="15 45"
  6. 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
  7.  
  8. var=`cat /tmp/sleeptimer`
  9. rm /tmp/sleeptimer
  10.  
  11. if [ "$var" -eq "$var" ] 2>/dev/null; then
  12.     # Sleep, then run onStop
  13.     if [ "$var" -le "4" ] 2>/dev/null; then
  14.     ( sleep $(( var * 3600  )) && onStop ) &
  15.     else
  16.     ( sleep $(( var * 60 )) && onStop ) &
  17.     fi
  18.     dialog --title "Radio Sleep/Shutoff Timer" --infobox "Timer set for $var minutes" $DIALOGSIZE
  19. else
  20.     # Not a number or user cancelled
  21.     dialog --title "Radio Sleep/Shutoff Timer" --infobox "Invalid time or cancelled" $DIALOGSIZE
  22. fi
  23.  
  24. sleep 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement