bins

handy scripts
git clone git://popovic.xyz/bins.git
Log | Files | Refs | LICENSE

toggle (1811B)


      1 #!/bin/zsh
      2 
      3 volume () {
      4     pactl set-sink-mute @DEFAULT_SINK@ toggle
      5 }
      6 
      7 monitor () {
      8     file="$XDG_DATA_HOME/status/monitor-status.info"
      9     stat1=$(sed -n '1p' $file)
     10     stat2=$(sed -n '2p' $file)
     11 
     12     while true ; do
     13         case "$1" in
     14             -l|--left)
     15                 if [[ "$stat1" == "on" ]]; then
     16                     xrandr --output DVI-D-1 --off
     17                     printf "off\non" > $file
     18                 elif [[ "$stat1" == "off" ]]; then
     19                     xrandr --output DVI-D-1 --auto --left-of DVI-I-1 printf "on\non" > $file
     20                 fi
     21                 return 1;
     22                 ;;
     23             -r|--right)
     24                 if [[ "$stat2" == "on" ]]; then
     25                     xrandr --output DVI-I-1 --off
     26                     printf "on\noff" > $file
     27                 elif [[ "$stat2" == "off" ]]; then
     28                     xrandr --output DVI-I-1 --auto --right-of DVI-D-1
     29                     printf "on\non" > $file
     30                 fi
     31                 return 1;
     32                 ;;
     33         esac
     34     done
     35 }
     36 
     37 sink () {
     38     file=$XDG_DATA_HOME/status/sink.info
     39     CURRENT=$(cat $file)
     40 
     41     if [[ $CURRENT = "" ]]; then
     42         pacmd "set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo" && echo "" > $file
     43     elif [[ $CURRENT = "" ]]; then
     44         pacmd "set-default-sink alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" && echo "" > $file
     45     fi
     46 }
     47 
     48 input () {
     49     file=$XDG_DATA_HOME/status/input.info
     50     CURRENT=$(cat $file)
     51 
     52     if [[ $CURRENT = "" ]]; then
     53         pacmd "set-default-source alsa_input.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo" && echo "" > $file
     54     elif [[ $CURRENT = "" ]]; then
     55         pacmd "set-default-source alsa_input.pci-0000_00_1b.0.analog-stereo" && echo "" > $file
     56     fi
     57 }
     58 
     59 "$@"