Last active
September 25, 2015 01:18
-
-
Save qguv/839618 to your computer and use it in GitHub Desktop.
simple timer using zenity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Timed unlock script. Must be run as root. | |
input=$(zenity --entry --text="Enter directory to be unlocked.") | |
name="$input" | |
thetime="5" | |
unit="m" | |
( | |
counter=0 | |
while [ "$counter" -le 100 ]; do | |
echo $counter; sleep "${increasefactor}""${unit}" | |
counter=$(( $counter + 1 )) | |
done | |
) | | |
zenity --progress --title="$name" --text="File opened. Open for 5 minutes." --percentage=0 --auto-close && | |
sudo chmod -R 770 "$input" | |
if [ "$?" == 1 ]; then | |
zenity --info --width=350 --title="$name" --text="File access closed before timeout." | |
else | |
zenity --info --width=350 --title="$name" --text="File access timed out." | |
fi | |
increasefactor=$(echo "${thetime}"/100|bc -l) | |
sudo chmod -R 777 "$input" | |
( | |
counter=0 | |
while [ "$counter" -le 100 ]; do | |
echo $counter; sleep "${increasefactor}""${unit}" | |
counter=$(( $counter + 1 )) | |
done | |
) | | |
zenity --progress --title="$name" --text="File opened. Open for 5 minutes." --percentage=0 --auto-close && | |
#sudo chmod -R 770 "$input" | |
if [ "$?" = "1" ]; then | |
zenity --info --width=350 --title="$name" --text="File access closed before timeout." | |
else | |
zenity --info --width=350 --title="$name" --text="File access timed out." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment