mirror of
https://gitlab.com/dwt1/dotfiles.git
synced 2026-04-22 11:00:27 +10:00
Replace multiple if statements with a switch case
This commit is contained in:
@@ -1,49 +1,43 @@
|
||||
#!/bin/bash
|
||||
# ____ _____
|
||||
# ____ _____
|
||||
# | _ \_ _| Derek Taylor (DistroTube)
|
||||
# | | | || | http://www.youtube.com/c/DistroTube
|
||||
# | |_| || | http://www.gitlab.com/dwt1/
|
||||
# |____/ |_|
|
||||
# | |_| || | http://www.gitlab.com/dwt1/
|
||||
# |____/ |_|
|
||||
#
|
||||
# Dmenu script for launching system monitoring programs.
|
||||
|
||||
|
||||
declare -a options=(" htop
|
||||
glances
|
||||
gtop
|
||||
iftop
|
||||
iotop
|
||||
iptraf-ng
|
||||
nmon
|
||||
s-tui
|
||||
quit ")
|
||||
declare -a options=("htop
|
||||
glances
|
||||
gtop
|
||||
iftop
|
||||
iotop
|
||||
iptraf-ng
|
||||
nmon
|
||||
s-tui
|
||||
quit")
|
||||
|
||||
choice=$(echo -e "${options[@]}" | dmenu -l -i -p 'System monitors: ')
|
||||
|
||||
if [ "$choice" == ' quit ' ]; then
|
||||
echo "Program terminated."
|
||||
fi
|
||||
if [ "$choice" == ' htop ' ]; then
|
||||
exec st -e htop
|
||||
fi
|
||||
if [ "$choice" == ' glances ' ]; then
|
||||
exec st -e glances
|
||||
fi
|
||||
if [ "$choice" == ' gtop ' ]; then
|
||||
exec st -e gtop
|
||||
fi
|
||||
if [ "$choice" == ' iftop ' ]; then
|
||||
exec st -e gksu iftop
|
||||
fi
|
||||
if [ "$choice" == ' iotop ' ]; then
|
||||
exec st -e gksu iotop
|
||||
fi
|
||||
if [ "$choice" == ' iptraf-ng ' ]; then
|
||||
exec st -e gksu iptraf-ng
|
||||
fi
|
||||
if [ "$choice" == ' nmon ' ]; then
|
||||
exec st -e nmon
|
||||
fi
|
||||
if [ "$choice" == ' s-tui ' ]; then
|
||||
exec st -e s-tui
|
||||
fi
|
||||
case $choice in
|
||||
quit)
|
||||
echo "Program terminated." && exit 1
|
||||
;;
|
||||
htop| \
|
||||
glances| \
|
||||
gtop| \
|
||||
nmon| \
|
||||
s-tui)
|
||||
exec st -e $choice
|
||||
;;
|
||||
iftop| \
|
||||
iotop| \
|
||||
iptraf-ng)
|
||||
exec st -e gksu $choice
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user