diff --git a/.bin/Scripts/ddrescue-tui b/.bin/Scripts/ddrescue-tui new file mode 100755 index 00000000..d83b3a7e --- /dev/null +++ b/.bin/Scripts/ddrescue-tui @@ -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" $* + diff --git a/.bin/Scripts/wk-ddrescue b/.bin/Scripts/ddrescue-tui-menu similarity index 87% rename from .bin/Scripts/wk-ddrescue rename to .bin/Scripts/ddrescue-tui-menu index 28ce6fb7..ea8c1a55 100755 --- a/.bin/Scripts/wk-ddrescue +++ b/.bin/Scripts/ddrescue-tui-menu @@ -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 diff --git a/.bin/Scripts/hw-diags b/.bin/Scripts/hw-diags index c1d7d3ca..e8d838df 100755 --- a/.bin/Scripts/hw-diags +++ b/.bin/Scripts/hw-diags @@ -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" || \