diff options
Diffstat (limited to 'src/lib/lib-ui.sh')
-rw-r--r-- | src/lib/lib-ui.sh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/lib/lib-ui.sh b/src/lib/lib-ui.sh new file mode 100644 index 0000000..10ad1a1 --- /dev/null +++ b/src/lib/lib-ui.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# DIALOG() taken from setup +# an el-cheapo dialog wrapper +# +# parameters: see dialog(1) +# returns: whatever dialog did +DIALOG() +{ + dialog --backtitle "$TITLE" --aspect 15 "$@" + return $? +} + + +# taken from setup +printk() +{ + case $1 in + "on") echo 4 >/proc/sys/kernel/printk ;; + "off") echo 0 >/proc/sys/kernel/printk ;; + esac +} + + +# geteditor(). taken from original setup code. prepended gui_ because power users just export $EDITOR on the cmdline. +# prompts the user to choose an editor +# sets EDITOR global variable +# +gui_geteditor() { + DIALOG --menu "Select a Text Editor to Use" 10 35 3 \ + "1" "nano (easier)" \ + "2" "vi" 2>$ANSWER + case $(cat $ANSWER) in + "1") EDITOR="nano" ;; + "2") EDITOR="vi" ;; + *) EDITOR="nano" ;; + esac +} + +# Get a list of available disks for use in the "Available disks" dialogs. This +# will print the disks as follows, getting size info from hdparm: +# /dev/sda: 640133 MBytes (640 GB) +# /dev/sdb: 640135 MBytes (640 GB) +gui_getavaildisks() +{ + # NOTE: to test as non-root, stick in a 'sudo' before the hdparm call + for i in $(finddisks); do echo -n "$i: "; hdparm -I $i | grep -F '1000*1000' | sed "s/.*1000:[ \t]*\(.*\)/\1/"; echo "\n"; done +} +
\ No newline at end of file |