Renamed script ddrescue-tui, added launcher script

Launcher script runs the python script in tmux (same as hw-diags)
This commit is contained in:
2Shirt 2018-07-16 17:58:29 -06:00
parent 0c3b90eb63
commit b2fc7ea860
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
3 changed files with 46 additions and 3 deletions

43
.bin/Scripts/ddrescue-tui Executable file
View file

@ -0,0 +1,43 @@
#!/bin/bash
#
## Wizard Kit: ddrescue TUI Launcher
SESSION_NAME="ddrescue-tui"
WINDOW_NAME="GNU ddrescue TUI"
MENU="ddrescue-tui-menu"
function ask() {
while :; do
read -p "$1 " -r answer
if echo "$answer" | egrep -iq '^(y|yes|sure)$'; then
return 0
elif echo "$answer" | egrep -iq '^(n|no|nope)$'; then
return 1
fi
done
}
die () {
echo "$0:" "$@" >&2
exit 1
}
# Check for running session
if tmux list-session | grep -q "$SESSION_NAME"; then
echo "WARNING: tmux session $SESSION_NAME already exists."
echo ""
if ask "Kill current session?"; then
tmux kill-session -t "$SESSION_NAME" || \
die "Failed to kill session: $SESSION_NAME"
else
echo "Aborted."
echo ""
echo -n "Press Enter to exit... "
read -r
exit 0
fi
fi
# Start session
tmux new-session -s "$SESSION_NAME" -n "$WINDOW_NAME" "$MENU" $*

View file

@ -21,8 +21,8 @@ if __name__ == '__main__':
menu_ddrescue(*sys.argv)
# Done
#print_standard('\nDone.')
#pause("Press Enter to exit...")
print_standard('\nDone.')
pause("Press Enter to exit...")
exit_script()
except SystemExit:
pass

View file

@ -24,7 +24,7 @@ die () {
# Check for running session
if tmux list-session | grep -q "$SESSION_NAME"; then
echo "WARNING: hw-diags tmux session already exists."
echo "WARNING: tmux session $SESSION_NAME already exists."
echo ""
if ask "Kill current session?"; then
tmux kill-session -t "$SESSION_NAME" || \