daily pastebin goal
33%
SHARE
TWEET

Playing with Zenity

jessicakennedy1028 Dec 10th, 2018 (edited) 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. TITLE="FunzAlot"
  4. LOGGEDIN=0
  5.  
  6. systemCheck() {
  7.   UNAME=`which uname`
  8.   GREP=`which egrep`
  9.   GREP_OPTIONS=""
  10.   CUT=`which cut`
  11.   READLINK=`which readlink`
  12.   XARGS=`which xargs`
  13.   DIRNAME=`which dirname`
  14.   MKTEMP=`which mktemp`
  15.   RM=`which rm`
  16.   CAT=`which cat`
  17.   SED=`which sed`
  18.  
  19.   if [ -z "$UNAME" -o -z "$GREP" -o -z "$CUT" -o -z "$MKTEMP" -o -z "$RM" -o -z "$CAT" -o -z "$SED" ]; then
  20.     message "Required tools are missing - check beginning of \"$0\" file for details."
  21.     exit 1
  22.   fi
  23. }
  24.  
  25. message() {
  26.   if [ -n "`which zenity`" ]; then
  27.     zenity --error --title="$TITLE" --text="$1"
  28.   elif [ -n "`which kdialog`" ]; then
  29.     kdialog --error "$1" --title "$TITLE"
  30.   elif [ -n "`which xmessage`" ]; then
  31.     xmessage -center "ERROR: $TITLE: $1"
  32.   elif [ -n "`which notify-send`" ]; then
  33.     notify-send "ERROR: $TITLE: $1"
  34.   else
  35.     printf "ERROR: $TITLE\n$1\n"
  36.   fi
  37. }
  38.  
  39. login() {
  40.   ENTRY=`zenity --password --username`
  41.  
  42.   case $? in
  43.     0)
  44.       UN="`echo $ENTRY | cut -d'|' -f1`"
  45.       PW="`echo $ENTRY | cut -d'|' -f2`"
  46.       if [ $UN == "jessica" ] && [ $PW == "Testing123" ]; then
  47.         LOGGEDIN=1
  48.         return
  49.       else
  50.         LOGGEDIN=0
  51.         zenity --notification --window-icon="warning" --text="The username and password are incorrect"
  52.       fi
  53.       ;;
  54.     1)
  55.       message "Stop login."
  56.       exit 0
  57.       ;;
  58.    -1)
  59.       message "An unexpected error has occurred."
  60.       exit 1
  61.       ;;
  62.   esac
  63. }
  64.  
  65. main() {
  66.   while [ $LOGGEDIN -ne 1 ]; do
  67.     login
  68.   done
  69. }
  70.  
  71.  
  72. main
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top