diff --git a/.bin/Scripts/echo-and-hold b/.bin/Scripts/echo-and-hold new file mode 100755 index 00000000..97c69830 --- /dev/null +++ b/.bin/Scripts/echo-and-hold @@ -0,0 +1,12 @@ +#!/bin/bash +# +## Wizard Kit: "echo" text to screen and "hold" by waiting for user input + +function usage { + echo "Usage: $(basename "$0") \"text\"" + echo " e.g. $(basename "$0") \"Some text to show\"" +} + +echo -en "$@" && read -r __dont_care +exit 0 + diff --git a/.bin/Scripts/functions/ddrescue.py b/.bin/Scripts/functions/ddrescue.py index f834107e..f05a00d8 100644 --- a/.bin/Scripts/functions/ddrescue.py +++ b/.bin/Scripts/functions/ddrescue.py @@ -3,6 +3,7 @@ import json import pathlib import re +import time from functions.common import * from operator import itemgetter @@ -64,7 +65,35 @@ def menu_clone(source_path, dest_path): # Build outer panes clear_screen() - #TODO + ## Top panes + source_pane = tmux_splitw( + '-bdvl', '2', + '-PF', '#D', + 'echo-and-hold "{BLUE}Source{CLEAR}\n{text}"'.format( + text = source['Display Name'], + **COLORS)) + tmux_splitw( + '-t', source_pane, + '-dhl', '21', + 'echo-and-hold "{BLUE}Started{CLEAR}\n{text}"'.format( + text = time.strftime("%Y-%m-%d %H:%M %Z"), + **COLORS)) + tmux_splitw( + '-t', source_pane, + '-dhp', '50', + 'echo-and-hold "{BLUE}Destination{CLEAR}\n{text}"'.format( + text = dest['Display Name'], + **COLORS)) + ## Side pane + tmux_splitw('-dhl', '21', 'echo-and-hold "Status #TODO"') + pause() + run_program(['tmux', 'kill-window']) + +def tmux_splitw(*args): + """Run tmux split-window command and return output as str.""" + cmd = ['tmux', 'split-window', *args] + result = run_program(cmd) + return result.stdout.decode().strip() def menu_ddrescue(*args): """Main ddrescue loop/menu.""" @@ -190,6 +219,15 @@ def select_device(description='device', provided_path=None, # Leave alone break + # Set display name + if dev['Is Image']: + dev['Display Name'] = '{name} {size} ({image_name})'.format( + image_name = dev['Path'][dev['Path'].rfind('/')+1:], + **dev['Details']) + else: + dev['Display Name'] = '{name} {size} {model}'.format( + **dev['Details']) + return dev def setup_loopback_device(source_path):