al-skel/base/.local/bin/rofi_run

96 lines
2.4 KiB
Plaintext
Raw Normal View History

2019-12-26 23:28:08 -06:00
#!/bin/bash
NAME="${0##*/}"
2020-04-24 21:17:13 -05:00
VER="0.8"
OPTS=(
-padding 50
-line-padding 4
-hide-scrollbar
)
2019-12-26 23:28:08 -06:00
usage()
{
cat <<EOF
USAGE: $NAME [OPTIONS]
OPTIONS:
-h,--help Display this message
-v,--version Display script version
2020-04-24 21:17:13 -05:00
-r,--run Run launcher
-d,--drun Desktop application launcher
2019-12-26 23:28:08 -06:00
-w,--window Switch between windows
-l,--logout System logout dialog
-b,--browser Browser search by keyword (requires surfraw)
-q,--qalculate Persistant calculator dialog (requires libqalculate)
-c,--clipboard Select previous clipboard entries (requires greenclip)
Without any options the run dialog will be opened.
EOF
}
if (( $# == 0 )); then
2020-04-24 21:17:13 -05:00
rofi -show run -columns 2 "${OPTS[@]}"
2019-12-26 23:28:08 -06:00
else
for arg in "$@"; do
case $arg in
-h|--help)
usage
exit 0
;;
-v|--version)
echo -e "$NAME -- Version $VER"
exit 0
;;
2020-04-24 21:17:13 -05:00
-d|--drun)
rofi -modi drun -show drun -columns 2 "${OPTS[@]}" -show-icons -drun-icon-theme "ArchLabs-Dark"
;;
2019-12-26 23:28:08 -06:00
-r|--run)
2020-04-24 21:17:13 -05:00
rofi -show run -columns 2 "${OPTS[@]}"
2019-12-26 23:28:08 -06:00
;;
-w|--window)
2020-04-24 21:17:13 -05:00
rofi -show window "${OPTS[@]}"
2019-12-26 23:28:08 -06:00
;;
-q|--qalculate)
hash qalc >/dev/null 2>&1 || { echo "Requires 'libqalculate' installed"; exit 1; }
2020-04-24 21:17:13 -05:00
rofi -modi "calc:qalc +u8 -nocurrencies" -show "calc:qalc +u8 -nocurrencies" "${OPTS[@]}"
2019-12-26 23:28:08 -06:00
;;
-c|--clipboard)
hash greenclip >/dev/null 2>&1 || { echo "Requires 'greenclip' installed"; exit 1; }
2020-04-24 21:17:13 -05:00
rofi -modi "clipboard:greenclip print" -show "clipboard:greenclip print" "${OPTS[@]}"
2019-12-26 23:28:08 -06:00
;;
-b|--browser)
hash surfraw >/dev/null 2>&1 || { echo "Requires 'surfraw' installed"; exit 1; }
surfraw -browser="$BROWSER" "$(sr -elvi | awk -F'-' '{print $1}' | sed '/:/d' | awk '{$1=$1};1' |
2020-04-24 21:17:13 -05:00
rofi -hide-scrollbar -kb-row-select 'Tab' -kb-row-tab 'Control+space' \
-dmenu -mesg 'Tab for Autocomplete' -i -p 'Web Search')"
2019-12-26 23:28:08 -06:00
;;
-l|--logout)
2020-04-24 21:17:13 -05:00
case "$(rofi -sep "|" -dmenu -i -p 'System' -width 20 -hide-scrollbar \
-line-padding 4 -padding 20 -lines 4 <<< " Lock| Logout| Reboot| Shutdown")" in
2019-12-26 23:28:08 -06:00
*Lock) i3lock-fancy ;;
*Reboot) systemctl reboot ;;
*Shutdown) systemctl -i poweroff ;;
*Logout) session-logout >/dev/null 2>&1 || pkill -15 -t tty"$XDG_VTNR" Xorg ;;
esac
;;
*)
printf "\nOption does not exist: %s\n\n" "$arg"
exit 2
esac
done
fi
exit 0