133 lines
2.3 KiB
Bash
Executable File
133 lines
2.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
LIST=();
|
|
if [ "$USER" = "yrzam" ]; then
|
|
LIST+=(
|
|
"web" "web projects"
|
|
"web" "web life"
|
|
)
|
|
else
|
|
LIST+=(
|
|
"web" "web"
|
|
)
|
|
fi
|
|
LIST+=(
|
|
"gui" "gimp"
|
|
"gui" "sqlitebrowser"
|
|
"shell_tui" "vifm"
|
|
"shell_tui" "vim"
|
|
"tui" "htop"
|
|
"tui" "nmtui"
|
|
"man" "man"
|
|
"screenpick-todo" "screenshot all"
|
|
"screenpick-todo" "screenshot selection"
|
|
"pass" "pass"
|
|
"term" "term"
|
|
)
|
|
if [ "$FEAT_BRIGHTNESS" ]; then
|
|
LIST+=(
|
|
"brightness" "brightness"
|
|
)
|
|
fi
|
|
LIST+=(
|
|
"direct" "sway reload"
|
|
"power" "logout"
|
|
"power-todo" "inhibit"
|
|
"power" "suspend"
|
|
"power" "poweroff"
|
|
"power" "poweroff --check-inhibitors=no"
|
|
"power" "reboot"
|
|
)
|
|
|
|
# generic
|
|
sure() {
|
|
echo yes | bemenu --prompt "sure?"
|
|
}
|
|
|
|
exec_gui() {
|
|
exec "$@"
|
|
}
|
|
exec_tui() {
|
|
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() {
|
|
/bin/qutebrowser --set tabs.tabs_are_windows true --set tabs.show never "https://google.com"
|
|
}
|
|
exec_power() {
|
|
case "$1" in
|
|
poweroff|reboot|suspend) sure && systemctl "$@";;
|
|
logout) sure && swaymsg exit;;
|
|
esac
|
|
}
|
|
exec_brightness() {
|
|
shift
|
|
target="$1"
|
|
if [ -z "$target" ]; then
|
|
current="$(($(brightnessctl g)*100/$(brightnessctl m)))%"
|
|
list="$(echo ok; echo 1%; seq 5 5 100 | sed 's/$/%/')";
|
|
target="$(
|
|
echo "$list" | bemenu --prompt "$current ->"
|
|
)";
|
|
fi
|
|
if [ -n "$target" ] && [ "$target" != "ok" ]; then
|
|
brightnessctl set "$target"
|
|
[ -z "$1" ] && exec_brightness brightness
|
|
fi
|
|
}
|
|
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_pass() {
|
|
echo 1
|
|
}
|
|
|
|
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
|