This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/home/bin/rofi_run

99 lines
2.9 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
NAME=$(basename "$0")
2018-08-18 15:16:42 -05:00
VER="0.4"
usage()
{
cat <<- EOF
USAGE: $NAME [OPTIONS]
2018-07-15 00:11:15 -05:00
OPTIONS:
-h,--help Display this message
-v,--version Display script version
-w,--window Switch between open windows
-r,--run Program launcher & run dialog
-q,--qalculate Persistant calculator dialog (requires libqalculate)
-c,--clipboard Select previous clipboard entries (requires greenclip)
-b,--browser Browser search by keyword (requires surfraw)
-l,--logout Session logout dialog
Without any options the run dialog will be opened.
EOF
}
for arg in "$@"; do
case $arg in
-h|--help)
usage
exit 0
;;
-v|--version)
echo -e "$NAME -- Version $VER"
exit 0
;;
-r|--run)
rofi -modi run,drun -show drun -line-padding 4 \
-columns 2 -padding 50 -hide-scrollbar \
-show-icons -drun-icon-theme "ArchLabs-Light"
;;
-w|--window)
2018-06-17 01:17:43 -05:00
rofi -modi window -show window -hide-scrollbar -padding 50 -line-padding 4
;;
-q|--qalculate)
2018-08-18 15:16:42 -05:00
hash qalc &>/dev/null || { echo "Requires 'libqalculate' installed"; exit 1; }
rofi -modi "calc:qalc +u8 -nocurrencies" -padding 50 \
-show "calc:qalc +u8 -nocurrencies" -line-padding 4 \
-hide-scrollbar
;;
-c|--clipboard)
2018-08-18 15:16:42 -05:00
hash greenclip &>/dev/null || { echo "Requires 'greenclip' installed"; exit 1; }
rofi -modi "clipboard:greenclip print" -padding 50 \
-line-padding 4 -show "clipboard:greenclip print" \
-hide-scrollbar
;;
-b|--browser)
2018-08-18 15:16:42 -05:00
hash surfraw &>/dev/null || { echo "Requires 'surfraw' installed"; exit 1; }
surfraw -browser="$BROWSER" "$(sr -elvi | awk -F'-' '{print $1}' |
sed '/:/d' | awk '{$1=$1};1' |
rofi -hide-scrollbar -kb-row-select 'Tab' \
-kb-row-tab 'Control+space' -dmenu \
-mesg 'Tab for Autocomplete' -i -p 'Web Search' \
-padding 50 -line-padding 4)"
;;
-l|--logout)
ANS="$(rofi -sep "|" -dmenu -i -p 'System' -width 20 \
-hide-scrollbar -line-padding 4 -padding 20 \
-lines 4 <<< " Lock| Logout| Reboot| Shutdown")"
case "$ANS" in
*Lock) i3lock-fancy ;;
*Logout) session-logout || pkill -15 -t tty"$XDG_VTNR" Xorg ;;
*Reboot) systemctl reboot ;;
2018-05-18 22:36:34 -05:00
*Shutdown) systemctl -i poweroff
esac
;;
*)
echo
echo "Option does not exist: $arg"
echo
exit 2
esac
done
(( $# == 0 )) && "$0" -r
exit 0