SHARE
TWEET

volume_wrapper.sh

a guest Aug 13th, 2012 39 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # print volume (for dwm)
  3. volume_file=/tmp/.dwm/volume
  4.  
  5. # Create directory if non-existing
  6. mkdir -p $(dirname $volume_file)
  7.  
  8. case $1 in
  9.         up)
  10.                 amixer -q sset Master 1+ unmute
  11.                 volume=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print " M" } else { print $2 }}' )
  12.                 echo "$volume" > $volume_file
  13.                 ;;
  14.         down)
  15.                 amixer -q sset Master 1- unmute
  16.                 volume=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print " M" } else { print $2 }}' )
  17.                 echo "$volume" > $volume_file
  18.                 ;;
  19.         mute)
  20.                 amixer -q sset Master toggle
  21.                 volume=$(amixer get Master | awk -F'[]%[]' '/%/ {if ($7 == "off") { print " M" } else { print $2 }}' )
  22.                 echo "$volume" > $volume_file
  23.                 ;;
  24. esac
  25.  
  26. # Change volume in statusbar
  27. xsetroot -name "$(echo -e "$(cat /tmp/.dwm/ssid) $(cat /tmp/.dwm/wlan)\x03 | \x01B:$(cat /tmp/.dwm/battery)\x03 | \x01V:\x04$(cat /tmp/.dwm/volume)\x03 | \x04$(date +"%H:%M") ")"
  28.  
  29. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top