Advertisement
v1ral_ITS

ddgui

Jun 27th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # dd-gui.sh v1.1 , 17.9.2015
  4. # Author: Rolf Klein soundrolf@web.de
  5. # Use dd with a GUI
  6. # Dialog is zenity-3.8.0
  7.  
  8. function menu {
  9.  
  10. # Input Dialog
  11. input=$(zenity --title=" ddGUI " --width=560 --text "   Enter Source and Target" --forms --add-entry "Source" --add-entry "Target")
  12.  
  13. ret=$?
  14.  
  15. # Is clicked exit, then exit.
  16. [[ $ret -eq 1 ]] && exit 0
  17.  
  18. # Error handling source. If nothing was entered return to menu.
  19. if [ -z "$(echo $input | awk 'BEGIN {FS="|" } { print $1 }')" ]; then
  20.     zenity --width=560 --warning="No source typed" --text="<b> No source specified.</b>\n\n Please specify source. EX: /dev/sr0\n\n Back to menu ..."
  21.     menu
  22. fi
  23.  
  24. # Error handling target. If nothing was entered return to menu
  25. if [ -z "$(echo $input | awk 'BEGIN {FS="|" } { print $2 }')" ]; then
  26.     zenity --width=560 --warning="No target typed" --text="<b> No target specified.</b>\n\n Please specify target. EX: /home/$USER/movie.iso\n\n Back to menu ..."
  27.     menu
  28. fi
  29.  
  30. }
  31. menu
  32.  
  33. # We don't need the pipe symbol |
  34. SOURCE=$(echo $input | awk 'BEGIN {FS="|" } { print $1 }')
  35. TARGET=$(echo $input | awk 'BEGIN {FS="|" } { print $2 }')
  36.  
  37. export SOURCE
  38. export TARGET
  39.  
  40. # Pre warning dialog.
  41. zenity --info --width=560 --height=40 --title="Starting .. " --timeout 2 --text="<b> Operation is startet ...  Please wait ..... </b>"
  42.  
  43. # Start and show a pulsating progressbar.
  44. dd if=$SOURCE of=$TARGET 2>&1 | zenity --width=560 --progress --title="Working ... " --text="<b><span color=\"blue\"> Operation is running .....    Please wait .....</span></b>" --percentage=0 --pulsate --no-cancel --auto-kill --auto-close
  45.  
  46. # Success dialog.
  47. zenity --info --width=560 --title="End .. " --timeout 20 --text="<b>Success:</b><span color=\"blue\">  Operation has been successfully finalized.</span> \n\n<b>Source: $SOURCE    ------>    Target: $TARGET</b>"
  48.  
  49. exit 0
  50. # End here.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement