Sleep Timer Bash Script
Someone in Ubuntu Forums posted that they wanted to create a deb package full of useful scripts and was asking for help. In his post he also said that one of the scripts he was after was a sleep timer so I decided to post one in his thread for him.
The bash script uses zenity for the user interface and in Ubuntu and other Linux distributions needs to be executed with administrative privileges.
#!/bin/bash echo "Sleep Timer." TimeMinutes=$(zenity --entry --title "Sleep Timer" --text "How long before shutdown? (minutes)" --entry-text "30"); TimeSeconds=$(($TimeMinutes * 60)) if [ $TimeMinutes = 1 ] then echo "System power off in 1 minute. ($TimeSeconds seconds)" else echo "System power off in $TimeMinutes minutes. ($TimeSeconds seconds)" fi sleep $TimeSeconds echo "powering off now..." poweroff