167 lines
2.9 KiB
Bash
Executable File
167 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
LIST=();
|
|
# gui
|
|
if [ "$USER" = "yrzam" ]; then
|
|
LIST+=(
|
|
"web" "web projects"
|
|
"web" "web life"
|
|
)
|
|
WEB_HAS_PROFILES=1
|
|
else
|
|
LIST+=(
|
|
"web" "web"
|
|
)
|
|
fi
|
|
LIST+=(
|
|
"gui" "gimp"
|
|
"gui" "sqlitebrowser"
|
|
# tui
|
|
"shell_tui" "vifm"
|
|
"shell_tui" "vim"
|
|
"tui" "htop"
|
|
"float_tui" "nmtui"
|
|
"float_tui" "bluetoothctl"
|
|
"man" "man"
|
|
"term" "term"
|
|
# native
|
|
"screen_pick" "screenshot output"
|
|
"screen_pick" "screenshot selection"
|
|
"todo" "pass"
|
|
"tui" "calc"
|
|
"todo" "translate ru-en"
|
|
"todo" "translate en-ru"
|
|
"word_pick" "pick-word"
|
|
)
|
|
if [ "$FEAT_BRIGHTNESS" ]; then
|
|
LIST+=(
|
|
"brightness" "brightness"
|
|
)
|
|
fi
|
|
LIST+=(
|
|
"direct" "sway reload"
|
|
"power" "logout"
|
|
"todo" "inhibit"
|
|
"power" "suspend"
|
|
"power" "poweroff"
|
|
"power" "poweroff --check-inhibitors=no"
|
|
"power" "reboot"
|
|
)
|
|
|
|
sure() {
|
|
echo yes | bemenu --prompt "sure?"
|
|
}
|
|
|
|
# generic
|
|
exec_gui() {
|
|
exec "$@"
|
|
}
|
|
exec_tui() {
|
|
exec footclient -D ~/ "$@"
|
|
}
|
|
exec_float_tui() { # todo
|
|
exec footclient -D ~/ "$@"
|
|
}
|
|
exec_shell_tui() {
|
|
exec footclient -D ~/ "$SHELL" -c "$@"
|
|
}
|
|
exec_shell_full() {
|
|
exec footclient -D ~/ "$SHELL" -c "($1); read -n1"
|
|
}
|
|
exec_direct() {
|
|
exec "$@"
|
|
}
|
|
exec_term() {
|
|
exec footclient -D ~/
|
|
}
|
|
# custom
|
|
exec_web() {
|
|
shift
|
|
if [ "$WEB_HAS_PROFILES" ]; then
|
|
shift
|
|
fi
|
|
qutebrowser "$*"
|
|
}
|
|
exec_man() {
|
|
shift
|
|
page="$1"
|
|
if [ -z "$page" ]; then
|
|
page="$(
|
|
man -k . | \
|
|
bemenu --prompt "man" | \
|
|
sed ' s/\s\+\-.*//;s/ //g'
|
|
)"
|
|
fi
|
|
[ -n "$page" ] && exec footclient "$SHELL" -c "man '$page' || read -n1"
|
|
}
|
|
exec_screen_pick() {
|
|
shift 1
|
|
if [ "$1" = "output" ]; then
|
|
mon="$(swaymsg -t get_outputs | jq -r '. | map(select(.focused == true)) | .[0].name')"
|
|
grim -o "$mon" - | wl-copy -t image/png
|
|
elif [ "$1" = "selection" ]; then
|
|
grim -g "$(slurp)" - | wl-copy -t image/png
|
|
fi
|
|
notify-send -a Screenshot "Done" "PNG image copied to clipboard" -t 3000
|
|
}
|
|
exec_pass() {
|
|
echo 1
|
|
}
|
|
exec_transl() {
|
|
echo 1
|
|
}
|
|
exec_word_pick() {
|
|
shift 1
|
|
|
|
}
|
|
exec_brightness() {
|
|
shift
|
|
target="$1"
|
|
if [ -z "$target" ]; then
|
|
current="$(($(brightnessctl g)*100/$(brightnessctl m)))"
|
|
current_i="$((current/5))"
|
|
list="$(echo 1%; seq 5 5 100 | sed 's/$/%/')";
|
|
target="$(
|
|
echo "$list" | bemenu --index $current_i --prompt "$current% ->"
|
|
)";
|
|
fi
|
|
if [ -n "$target" ]; then
|
|
brightnessctl set "$target"
|
|
[ -z "$1" ] && exec_brightness brightness
|
|
fi
|
|
}
|
|
exec_power() {
|
|
case "$1" in
|
|
poweroff|reboot|suspend) sure && systemctl "$@";;
|
|
logout) sure && swaymsg exit;;
|
|
esac
|
|
}
|
|
|
|
if [ -n "$1" ]; then
|
|
out="$*";
|
|
else
|
|
out=$(
|
|
for (( i=1; i<${#LIST[@]}; i+=2 )); do
|
|
echo "${LIST[$i]}";
|
|
done | bemenu --prompt ">"
|
|
)
|
|
fi
|
|
|
|
|
|
if [ "$out" ]; then
|
|
for (( i=1; i<${#LIST[@]}; i+=2 )); do
|
|
if [[ "$out" == "${LIST[$i]}"* ]]; then
|
|
executor=${LIST[$((i-1))]}
|
|
fi
|
|
done
|
|
[ -z "$executor" ] && executor=shell_full
|
|
|
|
if [ "$executor" = "shell_full" ]; then
|
|
"exec_$executor" "$out"
|
|
else
|
|
eval "executor_args=($out)"
|
|
#shellcheck disable=SC2154
|
|
"exec_$executor" "${executor_args[@]}"
|
|
fi
|
|
fi
|