Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to continuously adjust volume? #120

Open
moetayuko opened this issue Nov 15, 2022 · 3 comments
Open

How to continuously adjust volume? #120

moetayuko opened this issue Nov 15, 2022 · 3 comments

Comments

@moetayuko
Copy link

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.

@AdrianoTisera
Copy link

AdrianoTisera commented Aug 2, 2023

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.

@TheM1Stery
Copy link

TheM1Stery commented Oct 9, 2023

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

@AdrianoTisera
Copy link

Oh yeah, I did that too but forgot to share the code. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants