Made scripts more readable by moving most logic to functions.

This commit is contained in:
cronyakatsuki 2022-11-04 14:54:08 +01:00
parent 86e3a3a79c
commit 5c738fdc77
11 changed files with 234 additions and 133 deletions

View file

@ -2,7 +2,9 @@
# a simple dmenu usb managment script
. $HOME/.config/dmenu/config
load_config () {
. $HOME/.config/dmenu/config
}
driveCount(){
count="$(printf '%s\n' "$1" | wc -l)"
@ -30,7 +32,7 @@ mount(){
unmount(){
mounted="$(lsblk -lp | awk '/run/ { print $1 " ("$4")" }')"
if [ "$mounted" = "" ]; then
quick-notify "Dmenu Usb Manager" "No drives to unmount"
exit
@ -47,7 +49,17 @@ unmount(){
fi
}
case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in
"mount") mount ;;
"unmount") unmount ;;
esac
menu () {
case $(printf "mount\\nunmount" | $DMENU -p "Chose your usb action") in
"mount") mount ;;
"unmount") unmount ;;
esac
}
main () {
load_config
menu
}
main $@