Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # dd-gui.sh v1.1 , 17.9.2015
- # Author: Rolf Klein soundrolf@web.de
- # Use dd with a GUI
- # Dialog is zenity-3.8.0
- function menu {
- # Input Dialog
- input=$(zenity --title=" ddGUI " --width=560 --text " Enter Source and Target" --forms --add-entry "Source" --add-entry "Target")
- ret=$?
- # Is clicked exit, then exit.
- [[ $ret -eq 1 ]] && exit 0
- # Error handling source. If nothing was entered return to menu.
- if [ -z "$(echo $input | awk 'BEGIN {FS="|" } { print $1 }')" ]; then
- 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 ..."
- menu
- fi
- # Error handling target. If nothing was entered return to menu
- if [ -z "$(echo $input | awk 'BEGIN {FS="|" } { print $2 }')" ]; then
- 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 ..."
- menu
- fi
- }
- menu
- # We don't need the pipe symbol |
- SOURCE=$(echo $input | awk 'BEGIN {FS="|" } { print $1 }')
- TARGET=$(echo $input | awk 'BEGIN {FS="|" } { print $2 }')
- export SOURCE
- export TARGET
- # Pre warning dialog.
- zenity --info --width=560 --height=40 --title="Starting .. " --timeout 2 --text="<b> Operation is startet ... Please wait ..... </b>"
- # Start and show a pulsating progressbar.
- 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
- # Success dialog.
- 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>"
- exit 0
- # End here.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement