Visszaszámláló linuxra :)

Státusz
Nem lehet hozzászólni.

DeletedUser20691

Guest
Biztos többen használunk linuxot, nekik ajánlanék egy kellemes könnyed bash scriptet (nem én írtam, csak a magyar fordítás az érdemem).
Eredeti helye: http://handybashscripts.blogspot.hu/2012/01/simple-timer-with-progress-bar.html. Sok sikert!
Kód beillesztése:
#!/bin/bash
# Filename: progbar-timer.sh
# Version: 110212
# Author: robz
# Improved from the "Egg Timer" script, a countdown timer with progress bar.
# This one has an indication of time remaining provided by Zenity's progress
# bar function. As usual you'll need to find a sound and icon for the variables
# below, you might find the icon variable is correct, check the directory.

ICON=/home/usernév/Forge_of_Empires_Logo.png              # az ablak ikonja
SOUND=/home/usernév/ready.ogg                                   # figyelmeztető hang.

COUNT=$(zenity --title "Visszaszámlálás" --window-icon=$ICON --text "Egyszerű visszaszámláló a Forge of Empires játékhoz :P.\n\nÍgy használd: 10s (másodperc) vagy 5m (perc) vagy 2h (óra)"\
    --entry-text "15m" --entry)           # gyors ismertető + alapértelmezésben 15 percről indul a visszaszámlálás, persze átírható :)
if [ $? = 1 ]; then exit $?; fi

# idő átszámítása másodperc alapon.
case "${COUNT: -1}" in
    "S" | "s" ) COUNT=$(echo $COUNT | sed -s "s/[Ss]//") ;;
    "M" | "m" ) COUNT=$(echo $COUNT | sed -s "s/[Mm]//"); ((COUNT*=60)) ;;
    "H" | "h" ) COUNT=$(echo $COUNT | sed -s "s/[Hh]//"); ((COUNT*=3600)) ;;
    *         ) zenity --error --text "<span color=\"red\"><b>\
    \nígy használd: 10s (másodperc) vagy 5m (perc) vagy 2h (óra)\nTizedesjegyet nem kell beírnod.</b></span>"
    sh -c "$0"                                                               # hiba esetén újraindítás
esac

START=$COUNT                                                           # indítási pont beállítása. 

until [ "$COUNT" -eq "0" ]; do                                         # ismétlés...
    ((COUNT-=1))                                                          # másodpercenkénti csökkentés...
    PERCENT=$((100-100*COUNT/START))                        # százalékban...
    echo "#Hátralévő idő$(echo "obase=60;$COUNT" | bc)"   # átalakítás óra:perc:másodperc formátumba.
    echo $PERCENT                                                       # progressbar kiírása.
    sleep 1
done | zenity --title "Visszaszámlálás" --progress --percentage=0 --text=""\
    --window-icon=$ICON --auto-close 
    # hátralévő idő kijelzése.
if [ $? = 1 ]; then exit $?; fi
notify-send -i $ICON "Forge of Empires ..:: Lejárt az idő!! ::.."         # vége üzenete!
/usr/bin/canberra-gtk-play --volume 3 -f $SOUND                         # vége hang!
zenity --notification --window-icon="$ICON"\
    --text "Forge of Empires ..:: Lejárt az idő!! ::.."                       # vége üzenet az értesítések közé!
 
Státusz
Nem lehet hozzászólni.
Fent