summaryrefslogtreecommitdiff
path: root/volume_change.sh
blob: a33b017cad295e27f4aebb45ca5b25ddea943667 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/sh
pgrep -c pulse && {
	# printf "Caught pulseaudio (or pipewire-pulseaudio)\n"
	defsink=$(pactl get-default-sink)
	case $1 in
		raise)
			pactl set-sink-volume @DEFAULT_SINK@ "+${2}%"
			;;
		lower)
			pactl set-sink-volume @DEFAULT_SINK@ "-${2}%"
			;;
		toggle_mute)
			pactl set-sink-mute @DEFAULT_SINK@ toggle
			msg=$(pactl get-sink-mute @DEFAULT_SINK@)
			notify-send -h 'string:synchronous:volume' "$msg"
			exit
			;;
	esac
	msg=$(pactl get-sink-volume @DEFAULT_SINK@|awk '{print $5}')
	notify-send -h 'string:synchronous:volume' "$msg"
  #notify-send -h "int:value:$curvol" # progress bar in notification
	exit
}
case $1 in
	raise)
		amixer set Master "${2}%+"
		;;
	lower)
		amixer set Master "${2}%-"
		;;
esac
curvol=$(amixer get Master | sed -rn 's/.*\[([0-9]+%)\].*/\1/p')
notify-send -h 'string:synchronous:volume' "Volume: $curvol"