text version working
This commit is contained in:
parent
345680076a
commit
9808d1ff85
@ -2,38 +2,31 @@
|
|||||||
|
|
||||||
function usage () {
|
function usage () {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo "$0 <action>"
|
echo "$0 <action> [mode]"
|
||||||
echo "action is either mount or unmount"
|
echo "action is either mount or unmount"
|
||||||
|
echo "action is text or nothing"
|
||||||
}
|
}
|
||||||
|
|
||||||
# If no display found, full text interface. use dmenu and dunstify else.
|
# If no display found, full text interface. use dmenu and dunstify else.
|
||||||
if [ -z "$DISPLAY" ] ; then
|
if [ "$2" = text ] || [ -z "$DISPLAY" ] ; then
|
||||||
interface=text
|
|
||||||
function notify () {
|
function notify () {
|
||||||
echo "$1\n$2"
|
echo -e "== $1 ==\n$2"
|
||||||
}
|
}
|
||||||
function ask () {
|
function ask () {
|
||||||
echo "Text interface not implemented. use X :(" >/dev/stderr
|
# $1 is the title
|
||||||
exit 1
|
# $2 is the \n separated list of choices
|
||||||
#TODO
|
# $3 is the number of choices
|
||||||
i=0
|
IFS=$'\n' read -r -d '' -a args <<< $(echo -e "$2")
|
||||||
while read l ; do
|
dialog --no-items --menu "$1" 15 40 4 "${args[@]}" 2>&1 >/dev/tty
|
||||||
echo "$i) $l"
|
|
||||||
((i++))
|
|
||||||
done
|
|
||||||
echo -n "Your choice: "
|
|
||||||
read choice
|
|
||||||
if [ "$choice" -le "$i" ] && [ "$choice" -ge 0 ] ; then
|
|
||||||
echo $i
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
interface=x
|
|
||||||
function notify () {
|
function notify () {
|
||||||
dunstify "$1" "$2"
|
dunstify "$1" "$2"
|
||||||
}
|
}
|
||||||
function ask () {
|
function ask () {
|
||||||
dmenu
|
# See interface specification up
|
||||||
|
echo -en "$2" | dmenu -i -l "$3" -p "$1"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -70,14 +63,22 @@ done <<< $(lsblk -prno NAME,SIZE,MOUNTPOINTS)
|
|||||||
|
|
||||||
# Prompt user for disk action
|
# Prompt user for disk action
|
||||||
if [ "$action" = "mount" ] ; then
|
if [ "$action" = "mount" ] ; then
|
||||||
read disk size <<< $(echo -en $umounted | dmenu -i -l "$umounted_nb" -p 'Mount: ')
|
if [ -z "$umounted" ] ; then
|
||||||
|
notify "Mounting" "Nothing to mount"
|
||||||
|
else
|
||||||
|
read disk size <<< $(ask 'Mount' "$umounted" "$umounted_nb")
|
||||||
if [ -b "$disk" ] ; then
|
if [ -b "$disk" ] ; then
|
||||||
notify "Mounting $disk" "$(udisksctl mount -b "$disk" 2>&1)"
|
notify "Mounting $disk" "$(udisksctl mount -b "$disk" 2>&1)"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
elif [ "$action" = "umount" ] ; then
|
elif [ "$action" = "umount" ] ; then
|
||||||
read disk size mountpoint <<< $(echo -en $mounted | dmenu -i -l "$mounted_nb" -p 'Unmount: ')
|
if [ -z "$mounted" ] ; then
|
||||||
|
notify "Unmounting" "Nothing to unmount"
|
||||||
|
else
|
||||||
|
read disk size mountpoint <<< $(ask 'Unmount' "$mounted" "$mounted_nb")
|
||||||
if [ -b "$disk" ] ; then
|
if [ -b "$disk" ] ; then
|
||||||
notify "Unmounting $disk" "$(udisksctl unmount -b "$disk" 2>&1)"
|
notify "Unmounting $disk" "$(udisksctl unmount -b "$disk" 2>&1)"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user