bbqalarm

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

bbqalarm

Unread post by machinebacon » Thu May 23, 2013 10:51 am

Alarm clock.

Code: Select all

#!/bin/bash
# by D.M. Wilhelm
# adopted for the Q by bacon

Encoding=UTF-8
export TEXTDOMAIN=alert-clock
export TEXTDOMAINDIR="/usr/share/locale"
TITLE=EggTimer
VERSION=1.0.6
ICON=/usr/share/icons/minibbqtux.png
function menu {
COUNTDOWN=$(yad --entry --text $"Enter value in minutes" --title="$TITLE"" $VERSION" --window-icon=$ICON \
                        --image=$ICON \
                        --button=$"Change:2" \
                        --button=$"Test:3" \
                        --button="gtk-ok:0" \
                        --button="gtk-close:1" \
                   )

ret=$?

[[ $ret -eq 1 ]] && exit 0

if [[ $ret -eq 2 ]]; then
    CHANGE=$(yad --title="$TITLE"" $VERSION" --window-icon=$ICON \
                --file --width=600 --height=500 \
                --text=$"<b>Choose your own audio file as alert!</b>")
                if [ -z "$CHANGE" ];then 
                exec alert_clock
                exit 0
                else
                mkdir $HOME/.config/alert-clock
                rm -rf $HOME/.config/alert-clock/alert sleep 1
                ln -s "$CHANGE" $HOME/.config/alert-clock/alert
                yad --title $"$TITLE"" $VERSION" \
            --button="gtk-ok:0" \
            --width 300 \
            --window-icon=$ICON \
            --text=$"Your own sound is set!!"
                fi
menu            
fi

if [[ $ret -eq 3 ]]; then
        if [ -f $HOME/.config/alert-clock/alert ]; then
        SOUND="$HOME/.config/alert-clock/alert"
        else
        SOUND='/usr/share/alert-clock/alert.mp3'
        fi
mplayer "$SOUND" | yad --title $"$TITLE"" $VERSION" \
                 --button="gtk-ok:0" \
                 --width 300 \
                 --window-icon=$ICON \
                 --text=$"Exit sound test!!"
killall mplayer
menu                 
fi
}
menu

if [ "$COUNTDOWN" = "" ];then
exit
else
echo you enter "$COUNTDOWN" minutes
TIMER=$(echo $(($COUNTDOWN*60)))
TASK1=$(date -s "+$TIMER seconds" 2>/dev/null | cut -d " " -f4)
exec 3> >(yad --notification --command=CMD --image=$ICON --listen)
echo tooltip: $"Egg timer was set to $COUNTDOWN minutes and notifiers at $TASK1!" >&3
sleep $TIMER
exec 3>&-

if [ -f $HOME/.config/alert-clock/alert ]; then
        SOUND="$HOME/.config/alert-clock/alert"
        else
        SOUND='/usr/share/alert-clock/alert.mp3'
fi

(mplayer -loop 0 "$SOUND") | yad --title $"$TITLE"" $VERSION" \
                 --button="gtk-ok:0" \
                 --width 300 --image=$ICON \
                 --window-icon=$ICON \
                 --text=$"<b>Time is over!!</b>"
                 exit;
fi
exit
..gnutella..

Post Reply