70 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
			
		
		
	
	
			70 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
| #!/bin/bash
 | |
| 
 | |
| ICONS=~/.local/share/dunst
 | |
| 
 | |
| if [[ ! -x $(which pulsemixer) ]]; then
 | |
|   echo -e "\e[1;31merror\e[m: pulsemixer is not installed."
 | |
|   exit 1
 | |
| fi
 | |
| 
 | |
| notify() {
 | |
|   get_icon
 | |
|   if [[ $is_mute == 1 ]]; then
 | |
|     dunstify -a Volume -i $icon -u low "Volume mute!"
 | |
|   else
 | |
|     dunstify -a Volume -i $icon -u low -h int:value:$curr_volume "currtent volume: ${curr_volume}%"
 | |
|   fi
 | |
| }
 | |
| 
 | |
| get_volume() {
 | |
|   echo $(pulsemixer --get-volume | cut -d' ' -f1)
 | |
| }
 | |
| 
 | |
| get_icon() {
 | |
|   curr_volume=$(get_volume)
 | |
|   is_mute=$(pulsemixer --get-mute)
 | |
|   if [[  $is_mute == 1 || "$curr_volume" -eq "0" ]]; then
 | |
|     icon="${ICONS}/volume-mute.png"
 | |
|     curr_volume=0
 | |
|   elif [[ "$curr_volume" -le "35" ]]; then
 | |
|     icon="${ICONS}/volume-low.png"
 | |
|   elif [[ "$curr_volume" -le "70" ]]; then
 | |
|     icon="${ICONS}/volume-mid.png"
 | |
|   else
 | |
|     icon="${ICONS}/volume-high.png"
 | |
|   fi
 | |
| }
 | |
| 
 | |
| 
 | |
| volume_up() {
 | |
|   [[ $(pulsemixer --get-mute) == 1 ]] && pulsemixer --unmute
 | |
|   pulsemixer --max-volume 100 --change-volume +5
 | |
|   notify
 | |
| }
 | |
| 
 | |
| 
 | |
| volume_down() {
 | |
|   [[ $(pulsemixer --get-mute) == 1 ]] && pulsemixer --unmute
 | |
|   pulsemixer --max-volume 100 --change-volume -5
 | |
|   notify
 | |
| }
 | |
| 
 | |
| toggle_mute() {
 | |
|   pulsemixer --toggle-mute
 | |
|   notify
 | |
| }
 | |
| 
 | |
| 
 | |
| case "$1" in 
 | |
|   "up")
 | |
|     volume_up
 | |
|     ;;
 | |
|   "down")
 | |
|     volume_down
 | |
|     ;;
 | |
|   "mute")
 | |
|     toggle_mute
 | |
|     ;;
 | |
|   *)
 | |
|     get_volume
 | |
| esac |