#!/bin/sh

PM_BT_RESTART=/etc/pm/sleep.d/11-bluetooth-restart 

cat > $PM_BT_RESTART << EOF
#!/bin/sh
# There is a known issue of bluetoothd in Precise: Menu of BT applet will be
# broken sometimes after system resumed/thawed and this workaround is for the
# issue.

case "\$1" in
    hibernate|suspend)
        ;;
    resume|thaw)
        sleep 2
        sudo service bluetooth restart
        ;;
    *) exit 0
        ;;
    esac
EOF

chmod 755 $PM_BT_RESTART
