sys.sh (426B)
1 #!/bin/sh 2 # 3 # sys 4 5 CMDS="\ 6 Lock lock.sh 7 Shutdown doas shutdown -h now 8 Restart doas shutdown -r now 9 " 10 11 main() { 12 lines=$(printf '%s' "${CMDS}" | grep -c '^') 13 14 choice="$(printf '%s' "${CMDS}" | cut -d ' ' -f 1-2 | dmenu -c -i -l "${lines}")" || exit 1 15 16 cmd="$(printf '%s\n' "${CMDS}" | grep -i "^${choice}[\s]*" | awk '{ $1=""; $2=""; print }' | sed 's/^[[:space:]]*//g')" 17 18 ${cmd} 19 } 20 21 main "${@}"