Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- if [ -h ~/.mplayer/config ]
- then
- if $(grep -q bluetooth ~/.mplayer/config)
- then
- #echo "We are enabled."
- enabled=1
- fi
- rm ~/.mplayer/config
- else
- if [ ! -d ~/.mplayer ]
- then
- mkdir -p ~/.mplayer
- else
- if [ -e ~/.mplayer/config ]
- then
- mv ~/.mplayer/config ~/.mplayer/config.bak
- else
- if [ ! -e ~/.mplayer/config.bt ] || [ ! -e ~/.mplayer/config.def ]
- then
- echo "ao=alsa:device=bluetooth" > ~/.mplayer/config.bt
- echo "afm=libmad,dspmp3" >> ~/.mplayer/config.bt
- echo "" > ~/.mplayer/config.def
- fi
- fi
- fi
- fi
- case "$1" in
- "firstrun" | "first" | "runfirst" )
- echo "Welcome to the A2DP setup program."
- echo "This program will help you get a2dp working on your N8x0."
- echo "If you already have it setup just hit Ctrl-c now to exit."
- echo "Before we get started:"
- echo "Have you paired your headphones to your N8x0 yet?"
- echo "Do you have their bluetooth address handy?"
- echo "If you answered yes to both of these questions, "
- echo "then type in that address now."
- echo "Otherwise just hit Ctrl-c to exit"
- echo -n "BT address:"
- read btaddress
- if [ -e ~/.asoundrc ] ; then
- mv ~/.asoundrc ~/.asoundrc.bak
- fi
- echo "pcm.bluetooth {" > ~/.asoundrc
- echo "profile a2dp" >> ~/.asoundrc
- echo "type bluetooth" >> ~/.asoundrc
- echo -n "device " >> ~/.asoundrc
- echo $btaddress >> ~/.asoundrc
- echo "}" >> ~/.asoundrc
- ;;
- "enable" )
- sed -i 's/^pcm_device=default/pcm_device=bluetooth/' /home/user/.xmms/config
- ln -s ~/.mplayer/config.bt ~/.mplayer/config
- run-standalone.sh dbus-send --system \
- --type=method_call --dest=org.bluez \
- /org/bluez/hci0 org.bluez.Adapter.SetMode string:connectable
- run-standalone.sh dbus-send --print-reply \
- --type=method_call --dest=org.freedesktop.Notifications \
- /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint \
- string:'A2DP enabled!' 2> /dev/null 1> /dev/null
- ;;
- "disable" )
- sed -i 's/^pcm_device=bluetooth/pcm_device=default/' /home/user/.xmms/config
- ln -s ~/.mplayer/config.bak ~/.mplayer/config
- run-standalone.sh dbus-send --print-reply \
- --type=method_call --dest=org.freedesktop.Notifications \
- /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint \
- string:'A2DP disabled.' 2> /dev/null 1> /dev/null
- ;;
- "toggle" )
- if [ $enabled -eq 1 ] ; then
- #"Calling $0 to disable"
- $0 disable
- else
- #"Calling $0 to enable"
- $0 enable
- fi
- ;;
- * )
- echo "$0 usage: runfirst | enable | disable | toggle | --help"
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement