mirror of
				https://github.com/Mastermindzh/dotfiles.git
				synced 2025-11-04 10:49:00 +01:00 
			
		
		
		
	adding polybar setup
This commit is contained in:
		
							
								
								
									
										59
									
								
								config/polybar/scripts/pulse-microphone.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										59
									
								
								config/polybar/scripts/pulse-microphone.sh
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,59 @@
 | 
			
		||||
#!/bin/sh
 | 
			
		||||
 | 
			
		||||
status() {
 | 
			
		||||
  MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}')
 | 
			
		||||
 | 
			
		||||
  if [ "$MUTED" = "yes" ]; then
 | 
			
		||||
    echo "🙊 muted"
 | 
			
		||||
  else
 | 
			
		||||
    OUTPUT=$(pacmd list-sources | grep "\* index:" -A 7 | grep volume | awk -F/ '{print $2}' | awk -F, '{ print $1 }' | tr -d ' ')
 | 
			
		||||
    echo "🎙️ $OUTPUT"
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
listen() {
 | 
			
		||||
  status
 | 
			
		||||
 | 
			
		||||
  LANG=EN
 | 
			
		||||
  pactl subscribe | while read -r event; do
 | 
			
		||||
    if echo "$event" | grep -q "source" || echo "$event" | grep -q "server"; then
 | 
			
		||||
      status
 | 
			
		||||
    fi
 | 
			
		||||
  done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
toggle() {
 | 
			
		||||
  MUTED=$(pacmd list-sources | awk '/\*/,EOF {print}' | awk '/muted/ {print $2; exit}')
 | 
			
		||||
  DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
 | 
			
		||||
 | 
			
		||||
  if [ "$MUTED" = "yes" ]; then
 | 
			
		||||
    pactl set-source-mute "$DEFAULT_SOURCE" 0
 | 
			
		||||
  else
 | 
			
		||||
    pactl set-source-mute "$DEFAULT_SOURCE" 1
 | 
			
		||||
  fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
increase() {
 | 
			
		||||
  DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
 | 
			
		||||
  pactl set-source-volume "$DEFAULT_SOURCE" +5%
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
decrease() {
 | 
			
		||||
  DEFAULT_SOURCE=$(pacmd list-sources | awk '/\*/,EOF {print $3; exit}')
 | 
			
		||||
  pactl set-source-volume "$DEFAULT_SOURCE" -5%
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
case "$1" in
 | 
			
		||||
--toggle)
 | 
			
		||||
  toggle
 | 
			
		||||
  ;;
 | 
			
		||||
--increase)
 | 
			
		||||
  increase
 | 
			
		||||
  ;;
 | 
			
		||||
--decrease)
 | 
			
		||||
  decrease
 | 
			
		||||
  ;;
 | 
			
		||||
*)
 | 
			
		||||
  listen
 | 
			
		||||
  ;;
 | 
			
		||||
esac
 | 
			
		||||
		Reference in New Issue
	
	Block a user