Advertisement
Guest User

Faheem

a guest
Dec 30th, 2008
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.61 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. if [ -h ~/.mplayer/config ]
  4. then
  5.     if $(grep -q bluetooth ~/.mplayer/config)
  6.     then
  7.         #echo "We are enabled."
  8.         enabled=1
  9.     fi
  10.     rm ~/.mplayer/config
  11. else
  12.     if [ ! -d ~/.mplayer ]
  13.     then
  14.         mkdir -p ~/.mplayer
  15.     else
  16.         if [ -e ~/.mplayer/config ]
  17.         then
  18.             mv ~/.mplayer/config ~/.mplayer/config.bak
  19.         else
  20.             if [ ! -e ~/.mplayer/config.bt ] || [ ! -e ~/.mplayer/config.def ]
  21.             then
  22.                 echo "ao=alsa:device=bluetooth" > ~/.mplayer/config.bt
  23.                 echo "afm=libmad,dspmp3" >> ~/.mplayer/config.bt
  24.                 echo "" > ~/.mplayer/config.def
  25.             fi
  26.         fi
  27.     fi
  28. fi
  29.    
  30.    
  31. case "$1" in
  32.     "firstrun" | "first" | "runfirst" )
  33.         echo "Welcome to the A2DP setup program."
  34.         echo "This program will help you get a2dp working on your N8x0."
  35.         echo "If you already have it setup just hit Ctrl-c now to exit."
  36.         echo "Before we get started:"
  37.         echo "Have you paired your headphones to your N8x0 yet?"
  38.         echo "Do you have their bluetooth address handy?"
  39.         echo "If you answered yes to both of these questions, "
  40.         echo "then type in that address now."
  41.         echo "Otherwise just hit Ctrl-c to exit"
  42.         echo -n "BT address:"
  43.         read btaddress
  44.         if [ -e ~/.asoundrc ] ; then
  45.             mv ~/.asoundrc ~/.asoundrc.bak
  46.         fi
  47.         echo "pcm.bluetooth {" > ~/.asoundrc
  48.         echo "profile a2dp" >> ~/.asoundrc
  49.         echo "type bluetooth" >> ~/.asoundrc
  50.         echo -n "device " >> ~/.asoundrc
  51.         echo $btaddress >> ~/.asoundrc
  52.         echo "}" >> ~/.asoundrc
  53.         ;;
  54.  
  55.     "enable" )
  56.         sed -i 's/^pcm_device=default/pcm_device=bluetooth/' /home/user/.xmms/config
  57.         ln -s ~/.mplayer/config.bt ~/.mplayer/config
  58.         run-standalone.sh dbus-send --system  \
  59.         --type=method_call --dest=org.bluez  \
  60.          /org/bluez/hci0 org.bluez.Adapter.SetMode string:connectable
  61.         run-standalone.sh dbus-send --print-reply  \
  62.         --type=method_call --dest=org.freedesktop.Notifications  \
  63.         /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint  \
  64.         string:'A2DP enabled!' 2> /dev/null 1> /dev/null
  65.         ;;
  66.     "disable" )
  67.         sed -i 's/^pcm_device=bluetooth/pcm_device=default/' /home/user/.xmms/config
  68.         ln -s ~/.mplayer/config.bak ~/.mplayer/config
  69.         run-standalone.sh dbus-send --print-reply  \
  70.                 --type=method_call --dest=org.freedesktop.Notifications  \
  71.                 /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint  \
  72.                 string:'A2DP disabled.' 2> /dev/null 1> /dev/null
  73.         ;;
  74.     "toggle" )
  75.         if [ $enabled  -eq 1 ] ; then
  76.             #"Calling $0 to disable"
  77.             $0 disable
  78.         else
  79.             #"Calling $0 to enable"
  80.             $0 enable
  81.         fi
  82.         ;;
  83.     * )
  84.         echo "$0 usage: runfirst | enable | disable | toggle | --help"
  85.         ;;
  86. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement