feat: minor plugin tweaks and fixes

This commit is contained in:
imgurbot12 2023-08-19 21:20:20 -07:00
parent faa7fea0fd
commit b13f3cc9ce
3 changed files with 22 additions and 13 deletions

View File

@ -1,4 +1,4 @@
#/bin/sh
#!/bin/sh
get_sinks() {
sinks=`pactl list sinks | grep -e 'Sink' -e 'Name' -e 'Description' | nl -s '>'`

View File

@ -4,19 +4,28 @@ SELF=`realpath $0`
THEME=`realpath "$(dirname $0)/themes/powermenu.css"`
RMENU=${RMENU:-"rmenu"}
options() {
#: desc => generate options for basic operation
main_options() {
rmenu-build options \
-t $THEME \
-n ArrowRight -p ArrowLeft \
-w 550 -h 150 -M 0
}
#: desc => generate options for confirm operation
confirm_options() {
rmenu-build options \
-t $THEME \
-n ArrowRight -p ArrowLeft \
-w 300 -h 150 -M 0
}
#: desc => generate confirmation entries
#: usage => $cmd $name?
confirm() {
cmd=$1
name="${2:-"Confirm"}"
options
confirm_options
rmenu-build entry -n "Cancel" -I "" -a "`rmenu-build action -m echo "$name Cancelled"`"
rmenu-build entry -n "$name" -I "" -a "`rmenu-build action "$cmd"`"
}
@ -46,13 +55,8 @@ action() {
}
case "$1" in
"list")
confirm="$2"
options
action "⏻" "Shutdown" "systemctl poweroff" "$2"
action "" "Reboot" "systemctl reboot" "$2"
action "⏾" "Suspend" "systemctl suspend" "$2"
action "" "Log Out" "sway exit" "$2"
"help")
echo "usage: $0 <args...>" && exit 1
;;
"confirm")
name=`echo $2 | cut -d ':' -f1`
@ -60,6 +64,11 @@ case "$1" in
confirm "$action" "$name" | $RMENU
;;
*)
echo "usage: $0 <list|confirm> <args...>" && exit 1
[ "$1" != "--no-confirm" ] && confirm="Y"
main_options
action "⏻" "Shutdown" "systemctl poweroff" "$confirm"
action "" "Reboot" "systemctl reboot" "$confirm"
action "⏾" "Suspend" "systemctl suspend" "$confirm"
action "" "Log Out" "sway exit" "$confirm"
;;
esac

View File

@ -34,11 +34,11 @@ plugins:
cache: false
placeholder: "Jump to the Specified Window"
audio:
exec: ["sh", "~/.config/rmenu/pactl-audio.sh"]
exec: ["~/.config/rmenu/pactl-audio.sh"]
cache: false
placeholder: "Select an Audio Sink"
powermenu:
exec: ["sh", "~/.config/rmenu/powermenu.sh", "list", "confirm"]
exec: ["~/.config/rmenu/powermenu.sh"]
cache: false
# custom keybindings