Open moetayuko opened 1 year ago
Hi, maybe it's too late but I modified this part of the volume.sh script so it reopens itself when changing the volume.
# Execute Command
run_cmd() {
if [[ "$1" == '--opt1' ]]; then
amixer -Mq set Master,0 5%+ unmute
./volume.sh # Reopen
elif [[ "$1" == '--opt2' ]]; then
amixer set Master toggle
elif [[ "$1" == '--opt3' ]]; then
amixer -Mq set Master,0 5%- unmute
./volume.sh # Reopen... Again.
elif [[ "$1" == '--opt4' ]]; then
amixer set Capture toggle
elif [[ "$1" == '--opt5' ]]; then
pavucontrol
fi
}
Anyways, it's not perfect because if you want to decrease the volume, you have to go down again.
I know this is an old issue but i did it like this. I modified the script a little bit. This also remembers the last pressed option
arg="0"
while [[ "$arg" == 0 || "$arg" == 2 ]]; do
chosen="$(run_rofi $arg)"
# Exit if Cancel is pressed
if [[ "$chosen" == "" ]]; then
exit
fi
case ${chosen} in
$option_1)
run_cmd --opt1
arg=0
;;
$option_2)
run_cmd --opt2
arg=1
;;
$option_3)
run_cmd --opt3
arg=2
;;
$option_4)
run_cmd --opt4
arg=3
;;
$option_5)
run_cmd --opt5
arg=4
;;
esac
done
run_rofi
and run_cmd
also needs an argument passed
rofi_cmd() {
rofi -theme-str "window {width: $win_width;}" \
-theme-str "listview {columns: $list_col; lines: $list_row;}" \
-theme-str 'textbox-prompt-colon {str: "";}' \
-dmenu \
-p "$prompt" \
-mesg "$mesg" \
${active} ${urgent} \
-selected-row "$1" \
-markup-rows \
-theme ${theme}
}
# Pass variables to rofi dmenu
run_rofi() {
echo -e "$option_1\n$option_2\n$option_3\n$option_4\n$option_5" | rofi_cmd "$1"
}
I basically just added selected_row $1
to rofi_cmd
for it to remember the last position and just looped run_rofi
Oh yeah, I did that too but forgot to share the code. Thanks!
Currently, the volume applet closes right after an action is applied. This is fine and desired for mute/settings, but not for vol+/-. One may need to adjust the volume for multiple steps and manually close the applet when it's done.