Code: Select all
#!/bin/sh
# script by Fortunato Ventre (voRia) - http://www.voria.org - vorione@gmail.com
#
# "Toggle bluetooth on/off on Samsung NC10"
#
if [ $USER != "root" ]; then
echo "You need admin rights to run this script. Try with sudo."
exit 1
fi
LOCALE=`export | grep -w LANG | cut -d\' -f2`
case $LOCALE in
it_IT*)
POPUP_TITLE="Bluetooth"
BT_ON="Bluetooth attivato"
BT_OFF="Bluetooth disattivato"
;;
tr_TR*)
POPUP_TITLE="Mavidiş"
BT_ON="Mavidiş etkin"
BT_OFF="Mavidiş devre dışı"
;;
*)
POPUP_TITLE="Bluetooth"
BT_ON="Bluetooth enabled"
BT_OFF="Bluetooth disabled"
;;
esac
ICON=bluetooth
if which notify-send > /dev/null; then
USE_POPUP=1
else
USE_POPUP=0
fi
# If $SUDO_USER is not specified, defaults to root.
if [ -z $SUDO_USER ]; then
SUDO_USER="root"
fi
if /etc/init.d/bluetooth status | grep not > /dev/null; then
modprobe btusb
/etc/init.d/bluetooth start > /dev/null
if [ $USE_POPUP = 1 ]; then
sudo -u $SUDO_USER -- notify-send -u normal -i $ICON -t 2000 "$POPUP_TITLE" "$BT_ON"
fi
else
/etc/init.d/bluetooth stop > /dev/null
hciconfig hci0 down
sleep 1
modprobe -r btusb
modprobe -r sco
modprobe -r rfcomm
modprobe -r bnep
if [ $USE_POPUP = 1 ]; then
sudo -u $SUDO_USER -- notify-send -u normal -i $ICON -t 2000 "$POPUP_TITLE" "$BT_OFF"
fi
fi
exit 0