#!/bin/sh # A countdown timer # GNU GPLv3 value_num=$# HOU=$2 MIN=$3 SEC=$4 start(){ # If there are 3 arguments given, they become H, M, and S. Otherwise, the user is asked if [ $HOU -eq 0 ] && [ $MIN -eq 0 ] && [ $SEC -eq 0 ] ; then HOU=0 MIN=30 SEC=0 fi if [ $SEC -lt 60 ] ; then SEC=60 fi # Convert input to seconds TIMER=$(( ($HOU*3600) + ($MIN*60) + $SEC )) # Count down and output remaining time to temp file while [ $TIMER -gt 0 ] do #printf "%02dh:%02dm:%02ds\n" $((TIMER/3600)) $((TIMER%3600/60)) $((TIMER%60)) printf "%02d:%02d:%02d\n" $((TIMER/3600)) $((TIMER%3600/60)) $((TIMER%60)) sleep 10 TIMER=$(( TIMER - 10 )) done if [ $SEC -gt 0 ] ; then #echo freeze > /sys/power/state echo sleep > /etc/kernel_state pkill scanservice /etc/usbmonitor & /etc/pm_control off echo 0 > /sys/class/leds/red/brightness echo 0 > /sys/class/leds/white/brightness echo 0 > /sys/class/leds/green/brightness echo 1 > /sys/class/leds/green/brightness fi } stop(){ echo "timer need to be killed" } if [ "$1" != "" ]; then case $1 in start|stop) "$1" ;; esac fi