Announcement

Collapse
No announcement yet.

Simon's Bash

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Simon's Bash

    Oh were you expecting a party?

    Sorry this is about bash scripts I made up I found quite usful;

    This first script I named Screen.sh was used to replace the KRandRTray I was using. I already knew the resolutions I wanted to use so what is the point to having 320x240 on that list? Also KRandRTray has an annoying revert back timer. Ugh, why ask twice? I probably don't need lines 12 and 13 but I like idiot proofing. If you plan to use this script you need to replace the resolutions for your system and you need to set the output to your output. After this was done I made up a desktop shortcut with a pretty icon and stuck it on my panel at the bottom of the screen.

    Code:
     #!/bin/bash 
    ScreenRes=`kdialog --radiolist "Select Screen Resolution:" 1 1360x768 on  2 1280x768 off 3 1024x768 off 4 800x600 off`
    case $ScreenRes in
        1) xrandr --output default --mode 1360x768
           ;;
        2) xrandr --output default --mode 1280x768
           ;;
        3) xrandr --output default --mode 1024x768
           ;;
        4) xrandr --output default --mode 800x600
           ;;
        *) exit
           ;;
    esac
    For those of us who like to wine (you know who you are) this script pulls the icons from the MS executable and makes compatible PNG formats.

    Code:
    #!/bin/bash
    #Tool use to extract MS Windows icons and convert them to PNG
    exefile=`kdialog --getopenfilename '*.exe'`
    #Strips out the name of the file
    nameonly=$(basename "$( readlink -f "$exefile")")
    #Strips out the filepath
    filepath=$(dirname "$( readlink -f "$exefile")")
    #Saves to the same directory as the executable
    wrestool -x -t 14 "$exefile" > "$filepath/$nameonly.ico"
    convert -alpha on "$filepath/$nameonly.ico" "$filepath/$nameonly.png"
    #Removes the unused icon file
    rm "$filepath/$nameonly.ico"
    A more streamline version of that same would be;

    Code:
    #!/bin/bash
    #Tool use to extract MS Windows icons and convert them to PNG
    exefile=`kdialog --getopenfilename '*.exe'`
    #Saves to the same directory as the executable
    wrestool -x -t 14 "$exefile" > "$exefile.ico"
    convert -alpha on "$exefile.ico" "$exefile.png"
    rm "$exefile.ico"
    I will be adding more below, so I don't go making a mess on the forum.

    Enjoy!
    Last edited by Simon; Oct 05, 2012, 07:42 AM. Reason: Added another script

    #2
    Handy. Thanks for posting! Looking forward to more Simon Bashing.

    Comment


      #3
      Wow six months already? Where does the time go...

      I really do love the features in Ksnapshot it is a great program with a few bells and whistles. But if you want to make your own simple version;

      Code:
      #!/bin/bash
      #
      # This shell script requires and uses: import
      #Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
      #Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
      
      #Variables could be added using a Kdialog but these are set to take
      #a picture in the center of my 1360x768 display.
      crx=640
      cry=480
      posx=360
      posy=144
      #cropped to above coordinates
      import -window root -crop "$crx"x"$cry"+"$posx"+"$posy" screenshot0.png
      
      #Active Window
      activeWindow=$(xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)")
      WinId=${activeWindow:40}
      import -window "$WinId" screenshot1.png
      
      #Full Screen
      import -window root screenshot2.png
      That makes 3 screenshots in the directory you ran the shell program.

      Fun with $RANDOM

      Code:
      #!/bin/bash
      #
      # Draws a card at random.
      
      Suites="Clubs
      Diamonds
      Hearts
      Spades"
      
      Value="2
      3
      4
      5
      6
      7
      8
      9
      10
      Jack
      Queen
      King
      Ace"
      
      #Fill the arrays
      suit=($Suites)                
      face=($Value)
      
      #Is this your card? Probably not since the odds are 1 in 52.
      kdialog --msgbox "${face[$((RANDOM%13))]} of "${suit[$((RANDOM%4))]}
      Now all you need are the simple rules to Black Jack or if you are REAL ambitious Poker... :eek:

      Comment


        #4
        Excellent examples of bash coding!

        You reminded me to install bash-doc and abs-guide from the repository, to team up with Zenity (for GTK+ scripts) and Kdialog for KDE, which should be installed (if not install kdebase-bin), and the docs are here: http://techbase.kde.org/Development/...th_KDE_Dialogs.
        Last edited by GreyGeek; Mar 02, 2013, 05:14 PM.
        "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
        – John F. Kennedy, February 26, 1962.

        Comment


          #5
          Formating USB drive. Please heed my warning...

          Code:
          #!/bin/bash
          #
          #Simon's USB Format
          #This simple shell script should work for most USB key drives.
          #HOWEVER if the device fails to unmount or should it format the wrong device
          #don't go blaming me. AS-IS NO idiot proofing!!
          #
          #Search for a removable disk
          driveID=$(dmesg | grep "removable disk")
          
          #grab 3 letter ID
          DevId=${driveID:29:3}
          
          #Drive confirmation
          Confirm=$(df | grep "$DevId")
          
          kdialog --title "Format Device" --warningyesno "Are ou sure you this is your USB device: \n"$Confirm"?"
          case $? in 
              0) RootID=`kdialog --title "Root Password" --password "To proceed root access is required:"`
                 ;;
              *) exit
                 ;;
          esac
          
          #Unmount the Device
          echo $RootID | sudo -S umount /dev/$DevId
          
          #Menu 
          FormatType=`kdialog --radiolist "Select Format:" 1 FAT on  2 FAT32 off 3 EXT3 off 4 EXT4 off`
          case $ScreenRes in
              1) echo $RootID | sudo -S mkdosfs -I /dev/$DevId
                 ;;
              2) echo $RootID | sudo -S mkdosfs -F 32 -I /dev/$DevId
                 ;;
              3) echo $RootID | sudo -S mkfs.ext3 -I /dev/$DevId
                 ;;
              4) echo $RootID | sudo -S mkfs.ext4 -I /dev/$DevId
                 ;;
              *) exit
                 ;;
          esac
          Updated and edited: I forgot to include the -S switch on all the case statement. I couldn't figure it out until I ran the script from terminal.
          Repair #2: See posting below. As for bail out on blank password could be added but since this script is kind of "silly" in my opinion... uh yeah.

          Edit #3 What I mean by "silly", IF I were to implement this on my system, it need not be so complicated.

          This all I would need to do;

          Code:
          #!/bin/bash
          #
          #Simon's USB Ultra Simple Format
          #This example has the password in the script. 
          #HOWEVER this is not my password
          
          #Unmount the Device - I don't need variables or menu if I know what I am doing.
          echo "P455W0RD" | sudo -S umount /dev/sdc
          echo "P455W0RD" | sudo -S mkdosfs -F 32 -I /dev/sdc
          Last edited by Simon; Mar 10, 2013, 08:05 PM. Reason: Repair x2

          Comment


            #6
            Putting on my code review hat. I'm not sure the following code works as expected:

            > kdialog --title "Format Device" --warningyesno "Are ou sure you this is your USB device: \n"$Confirm"?"
            > case $? in
            > 0) kdialog --title "Root Password" --password "To proceed root access is required:"
            > ;;
            > *) exit
            > ;;
            > esac
            > RootID=$?

            "$?" gets the exit status of the previous process (an integer: 0 is success, non-zero failure). What is probably wanted is to capture the output of the previous command. Perhaps something like this:

            [in case statement]
            PasswdString=$(kdialog --title 'Password' --password "To proceed, root access is required:")
            [ after case statement]
            if [ -z "$PasswdString" ]; then
            exit 1 #empty password bailing out here...
            fi

            Comment


              #7
              Thank you, I was thinking it was something wrong with my, echo <password> | sudo -S <command>

              fixing code above now.

              Comment


                #8
                I made this one because my ATI driver interface doesn't seem to have a thermal readout.

                Code:
                #!/bin/bash
                #
                #Get the temp from the aticonfig - look for the line with a colon.
                TempInfo=$(aticonfig --odgt | grep ":")
                #Now convert C to F for "those who use it" 
                CtoF=$(aticonfig --odgt | grep ":"|cut -d " " -f23)
                Ftmp=$(echo "scale=1;((9/5) * $CtoF) + 32" |bc)
                #Display in a message box
                kdialog --msgbox "${TempInfo:28} / $Ftmp F"
                Short and sweet and to the point. Now you can make a panel shortcut and query the temp when you need to know.

                Comment


                  #9
                  For very paranoid people like myself...

                  watch -d -n 2 "df; ls -FlAt;"

                  Allows you to observe file changes in real time.
                  Note: The "ls" command can be structured however you desire it is currently set to show long filenames and sort by most recently changed.

                  Comment


                    #10
                    That's cool.

                    Comment


                      #11
                      Full time doctoring hasn't left me much "free time" to hobby with this stuff. But one of my friends wanted to know, if Linux could run scripts like Windows. Josh is pretty big on macros for his gaming needs. So I invited him over the last weekend and we kicked about and I showed him how to make some bash macros.

                      Code:
                      #!/bin/bash 
                      # Clicks the screen 3000 times in one minute.
                      # Josh wanted this so he didn't wear out his mouse playing "idle games"
                      
                      for a in {1..3000} 
                        do 
                          xdotool click 1 
                          sleep 0.02 
                        done
                      Then he wanted to know if I could get the color from the screen;

                      Code:
                      #!/bin/sh
                      eval $(xdotool getmouselocation --shell)
                      IMAGE=`import -window root -depth 8 -crop 1x1+$X+$Y txt:-`
                      COLOR=`echo $IMAGE | grep -om1 '#\w\+'`
                      zenity --info --text=$COLOR
                      This result was instant so we added a timer;

                      Code:
                      #!/bin/sh  
                      #10 second timer
                      sleep 10
                      
                      #same code as above
                      eval $(xdotool getmouselocation --shell)
                      IMAGE=`import -window root -depth 8 -crop 1x1+$X+$Y txt:-`
                      COLOR=`echo $IMAGE | grep -om1 '#\w\+'`
                      zenity --info --text=$COLOR
                      I am working up a new way to display the timer using zenity. I guess that about rounds out all you game cheating needs eh?
                      Last edited by Simon; Jan 14, 2015, 10:36 PM.

                      Comment


                        #12
                        Kewl!
                        I use Xrandr on my document processing machine/monitor.

                        I think that I have a pic on the forum someplace of the setup.

                        woodsmoke
                        Last edited by woodsmoke; Jan 15, 2015, 03:27 AM.

                        Comment


                          #13
                          Here is that visual timer. The variable "count" is always in seconds. I suppose someone with the "math skills" can figure minutes.
                          It uses the Zenity progress bar to show the time and auto closes when finished. The hard part is to recalculate the percentage.
                          Ten times ten is 100 but for a 20 second timer you would want; percent=$((100-count*5))

                          One possible solution would be adding yet another variable; multiple=$((100/count)) just below the count.

                          Code:
                          #!/bin/sh  
                          #10 second visual countdown timer
                          count=10
                          until [ "$count" -eq "0" ]; 
                          do 
                            count=$((count-1))
                            percent=$((100-count*10))
                            echo "#Time remaining: $(echo "$count")"
                            echo $percent
                            sleep 1
                          done | zenity --title "Timer" --progress --auto-close

                          Comment


                            #14
                            Sorry, been busy and with Spring weather it is not time for me to be stuck inside on my PC.

                            This is my latest hobby in bash scripting. It was a bit of a challenge.

                            Code:
                            #!/bin/bash 
                            #Should work in most drawing programs. This was tested with "Pencil".
                            #Required programs; Zenity and xdotool
                            #Draw Circle - makes a circle from center using 36 points.
                            draw_circle ()
                            {
                            radius=$(zenity --entry --text "Radius?" --entry-text "50")
                            for a in {0..18}
                            do
                            dgr=$(($a*10))
                            xdotool mousemove_relative --polar $dgr $radius
                            sleep 0.25 
                            xdotool click 1
                            b=$((180+$dgr))
                            sleep 0.25 
                            xdotool mousemove_relative --polar $b $radius
                            sleep 0.25 
                            done
                            for a in {0..18}
                            do
                            dgr=$(($a*10+180))
                            xdotool mousemove_relative --polar $dgr $radius
                            sleep 0.25 
                            xdotool click 1
                            b=$(($dgr-180))
                            sleep 0.25 
                            xdotool mousemove_relative --polar $b $radius
                            sleep 0.25 
                            done
                            }
                            
                            #Fill Solid - Fills a solid Area
                            fill_solid ()
                            {
                            x=$(zenity --entry --text "Width?" --entry-text "500")
                            d=$(zenity --entry --text "Depth?" --entry-text "20")
                            y=$(zenity --entry --text "Spacing?" --entry-text "10")
                            a=0
                            xdotool mousedown 1
                            while [ "$a" -lt "$d" ]
                                do
                            sleep 0.25 
                            xdotool mousemove_relative --polar 90 $x
                            sleep 0.25
                            xdotool mousemove_relative --polar 180 $y
                            sleep 0.25
                            xdotool mousemove_relative --polar 270 $x
                            sleep 0.25
                            xdotool mousemove_relative --polar 180 $y
                            a=$((a+1))
                            done
                            xdotool mouseup 1
                            }
                            #Draw Box - Simple box
                            draw_square ()
                            {
                            x=$(zenity --entry --text "Width?" --entry-text "50")
                            y=$(zenity --entry --text "Height?" --entry-text "50")
                            
                            xdotool mousedown 1
                            sleep 0.25 
                            xdotool --clearmodifiers
                            xdotool mousemove_relative -- $x 0
                            sleep 0.25
                            xdotool --clearmodifiers
                            xdotool mousemove_relative -- 0 $y
                            sleep 0.25
                            x=$((-x))
                            y=$((-y))
                            xdotool --clearmodifiers
                            xdotool mousemove_relative -- $x 0
                            sleep 0.25
                            xdotool --clearmodifiers
                            xdotool mousemove_relative -- 0 $y
                            xdotool mouseup 1
                            }
                            #Draw Line
                            draw_line ()
                            {
                            x=$(zenity --entry --text "Direction?" --entry-text "0")
                            y=$(zenity --entry --text "Length?" --entry-text "50")
                            xdotool mousedown 1
                            sleep 0.25
                            xdotool mousemove_relative --polar $x $y
                            xdotool mouseup 1
                            }
                            #Write Alpha - Draws alphabet characters A-Z and space must be entered in lowercase.
                            draw_alpha ()
                            {
                            x=$(zenity --entry --text "text?")
                            l=${#x}
                            a=0
                            while [ "$a" -lt "$l" ]
                            do
                            c=${x:a:1}
                            a=$((a+1))
                            case $c in
                            'a')
                            #A
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 25 8
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 25 7
                            xdotool mousemove_relative --sync --polar 155 15
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 3
                            ;;
                            'b')
                            #B
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mousemove_relative --sync --polar 225 5
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mousemove_relative --sync --polar 225 6
                            xdotool mousemove_relative --sync --polar 270 6
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 12
                            ;;
                            'c')
                            #C
                            xdotool mousemove_relative --sync --polar 80 15
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 225 5
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 315 5
                            xdotool mousemove_relative --sync --polar 0 6
                            xdotool mousemove_relative --sync --polar 45 5
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 135 12
                            ;;
                            'd')
                            #D
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 135 6
                            xdotool mousemove_relative --sync --polar 180 6
                            xdotool mousemove_relative --sync --polar 225 6
                            xdotool mousemove_relative --sync --polar 270 6
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 15
                            ;;
                            'e')
                            #E
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mousemove_relative --sync --polar 270 6
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mouseup 1
                            xdotool mousemove_relative --sync --polar 90 3
                            ;;
                            'f')
                            #F
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mousemove_relative --sync --polar 270 6
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 9
                            ;;
                            'g')
                            #G
                            xdotool mousemove_relative --sync --polar 80 15
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 3
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 180 3
                            xdotool mousemove_relative --sync --polar 225 5
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 315 5
                            xdotool mousemove_relative --sync --polar 0 6
                            xdotool mousemove_relative --sync --polar 45 5
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 135 12
                            xdotool mousemove_relative --sync --polar 270 4
                            ;;
                            'h')
                            #H
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mousemove_relative --sync --polar 0 7
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'i')
                            #I
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 7
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 90 7
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'j')
                            #J
                            xdotool mousemove_relative --sync --polar 0 7
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 3
                            xdotool mousemove_relative --sync --polar 135 4
                            xdotool mousemove_relative --sync --polar 90 3
                            xdotool mousemove_relative --sync --polar 45 4
                            xdotool mousemove_relative --sync --polar 0 10
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'k')
                            #K
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mousemove_relative --sync --polar 45 7
                            xdotool mousemove_relative --sync --polar 225 7
                            xdotool mousemove_relative --sync --polar 135 8
                            xdotool mousemove_relative --sync --polar 315 8
                            xdotool mousemove_relative --sync --polar 180 7
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 10
                            ;;
                            'l')
                            #L
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 7
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'm')
                            #M
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 135 8
                            xdotool mousemove_relative --sync --polar 45 8
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'n')
                            #N
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 155 16
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 180 12
                            ;;
                            'o')
                            #O
                            xdotool mousemove_relative --sync --polar 80 15
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 225 5
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 315 5
                            xdotool mousemove_relative --sync --polar 0 6
                            xdotool mousemove_relative --sync --polar 45 5
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mousemove_relative --sync --polar 180 6
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 180 3
                            ;;
                            'p')
                            #P
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 135 6
                            xdotool mousemove_relative --sync --polar 225 6
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 180 6
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 10
                            ;;
                            'q')
                            #Q
                            xdotool mousemove_relative --sync --polar 80 15
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 225 5
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 315 5
                            xdotool mousemove_relative --sync --polar 0 6
                            xdotool mousemove_relative --sync --polar 45 5
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mousemove_relative --sync --polar 180 6
                            xdotool mousemove_relative --sync --polar 315 3
                            xdotool mousemove_relative --sync --polar 135 6
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'r')
                            #R
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 135 6
                            xdotool mousemove_relative --sync --polar 225 6
                            xdotool mousemove_relative --sync --polar 270 4
                            xdotool mousemove_relative --sync --polar 135 10
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            's')
                            #S
                            xdotool mousemove_relative --sync --polar 0 5
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 135 6
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 45 6
                            xdotool mousemove_relative --sync --polar 0 3
                            xdotool mousemove_relative --sync --polar 290 12
                            xdotool mousemove_relative --sync --polar 0 3
                            xdotool mousemove_relative --sync --polar 45 4
                            xdotool mousemove_relative --sync --polar 90 4
                            xdotool mousemove_relative --sync --polar 135 4
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 7
                            xdotool mousemove_relative --sync --polar 180 12
                            ;;
                            't')
                            #T
                            xdotool mousemove_relative --sync --polar 90 6
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousemove_relative --sync --polar 270 5
                            xdotool mousemove_relative --sync --polar 90 9
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'u')
                            #U
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 12
                            xdotool mousemove_relative --sync --polar 135 5
                            xdotool mousemove_relative --sync --polar 90 3
                            xdotool mousemove_relative --sync --polar 45 5
                            xdotool mousemove_relative --sync --polar 0 12
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'v')
                            #V
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 160 16
                            xdotool mousemove_relative --sync --polar 20 16
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'w')
                            #W
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 180 14
                            xdotool mousemove_relative --sync --polar 45 8
                            xdotool mousemove_relative --sync --polar 135 8
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            xdotool mousemove_relative --sync --polar 180 14
                            ;;
                            'x')
                            #X
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 25 16
                            xdotool mousemove_relative --sync --polar 205 8
                            xdotool mousemove_relative --sync --polar 335 8
                            xdotool mousemove_relative --sync --polar 155 16
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'y')
                            #Y
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 25 16
                            xdotool mousemove_relative --sync --polar 205 8
                            xdotool mousemove_relative --sync --polar 335 8
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 155 16
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            'z')
                            #Z
                            xdotool mousemove_relative --sync --polar 0 14
                            xdotool mousedown 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 8
                            xdotool mousemove_relative --sync --polar 205 16
                            xdotool mousemove_relative --sync --polar 90 8
                            xdotool mouseup 1
                            sleep 0.1
                            xdotool mousemove_relative --sync --polar 90 5
                            ;;
                            ' ')
                            #space
                            xdotool mousemove_relative --sync --polar 90 15
                            esac
                            done
                            }
                            
                            while [ "1" = "1" ]
                            do
                            menu=$(zenity  --list  --text "Select Task:" --radiolist  --column "#" --column "Tasks" TRUE 'Fill' FALSE 'Alpha' FALSE 'Circle' FALSE 'Square' FALSE 'Line')
                            case $menu in
                              'Alpha') draw_alpha
                              ;;
                              'Fill') fill_solid 
                              ;;
                              'Circle') draw_circle
                              ;;
                              'Square') draw_square
                              ;;
                              'Line') draw_line
                              ;;
                              *) exit
                              ;;
                            esac
                            done
                            Reason? No reason just playing about!

                            Comment


                              #15
                              Here is a nice solution I use for logging on to a password protected application. This is not a browser (they remember passwords for me) and automatically login. If you are not the only person using your PC then this may not be right for you. The app is for Windows so I have to start it with WINE. But this will work with any application.

                              Code:
                              #!/bin/bash
                              #This first part loads the program in WINE
                              
                              export WINEPREFIX="/home/system/.wine-md"
                              cd "/media/system/Drive D"
                              wine medic.exe &
                              
                              #After the ampersand the script continues to execute commands 
                              #This section loops until it finds a window titled "Medical"
                              
                              a=0
                              until ((a>0)) 
                              do
                                sleep 1
                                a=$(wmctrl -l | grep -c Medical)
                              done
                              
                              #Now we make sure xdotool can see the window.
                              x=$(xdotool search --name "Medical")
                              xdotool windowactivate --sync $x
                              sleep 5
                              xdotool type mypasswordhere
                              sleep 0.5
                              xdotool key Return
                              This comes up with a blinking cursor in a password box and no user ID is needed. If you need to move about the screen or add a user name;

                              Code:
                              x=$(xdotool search --name "Medical")
                              xdotool windowactivate --sync $x
                              sleep 5
                              xdotool type myusername
                              sleep 0.5
                              xdotool key Tab
                              xdotool type mypasswordhere
                              sleep 0.5
                              xdotool key Return
                              I just find it annoying to type and retype the same password all day long. Sometimes we get stuck using someone's garbage and we just need a bit of automation to work it out. xdotool is great for mouse and keyboard automation.

                              Comment

                              Working...
                              X