mirror of
git://slackware.nl/current.git
synced 2025-01-15 15:41:54 +01:00
b76270bf9e
Wed May 19 08:58:23 UTC 2010 Slackware 13.1 x86_64 stable is released! Lots of thanks are due -- see the RELEASE_NOTES and the rest of the ChangeLog for credits. The ISOs are on their way to replication, a 6 CD-ROM 32-bit set and a dual-sided 32-bit/64-bit x86/x86_64 DVD. We are taking pre-orders now at store.slackware.com, and offering a discount if you sign up for a subscription. Consider picking up a copy to help support the project. Thanks again to the Slackware community for testing, contributing, and generally holding us to a high level of quality. :-) Enjoy!
114 lines
3.6 KiB
Bash
114 lines
3.6 KiB
Bash
#!/bin/sh
|
|
# Blueman Mount Script for Slackware
|
|
# by Zarren Spry & Robby Workman
|
|
# Based on http://kde-apps.org/content/show.php/kde4+bluetooth+files+open?content=108869
|
|
|
|
# Set to 0 if you want more debugging messages
|
|
DEBUG=1
|
|
|
|
device_addr="$1"
|
|
device_name="$(hcitool name $device_addr)"
|
|
own_name="$(basename $0)"
|
|
basedir="${basedir:-$HOME/obexfs}"
|
|
mountpoint="${basedir}/${device_addr}"
|
|
browser=${browser:-"xdg-open"}
|
|
|
|
# If we're running in kde, use kdialog
|
|
if [ "$KDE_FULL_SESSION" = "true" ]; then
|
|
if which kdialog 1>/dev/null 2>/dev/null; then
|
|
messagetype="kdialog"
|
|
fi
|
|
# If not, then see if libnotify is available
|
|
# Even if it is, there may not be a notification daemon running, but there's
|
|
# no good way to check for this, so oh well...
|
|
elif which notify-send 1>/dev/null 2>/dev/null; then
|
|
messagetype="libnotify"
|
|
# If no libnotify, then use kdialog if it's installed
|
|
elif which kdialog 1>/dev/null 2>/dev/null; then
|
|
messagetype="kdialog"
|
|
# If all else fails, just don't do notifications
|
|
else
|
|
messagetype=""
|
|
fi
|
|
|
|
# Mount function
|
|
mount_device ()
|
|
{
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "Attempting to mount device $device_name to $mountpoint..."
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "Execute: obexfs -b $device_addr $mountpoint"
|
|
|
|
mkdir -p $mountpoint
|
|
obexfs -b $device_addr $mountpoint 2>&1
|
|
|
|
if [ $? != 0 ]; then
|
|
MSG_TXT="Failed to mount $device_name to $mountpoint. $dbg_msg"
|
|
FAILZOR=definitely
|
|
if [ ! -z $DEBUG ]; then
|
|
logger -i -t $own_name "Failed to mount $device_name to $mountpoint."
|
|
fi
|
|
else
|
|
MSG_TXT="Successfully mounted $device_name to $mountpoint"
|
|
if [ ! -z $DEBUG ]; then
|
|
logger -i -t $own_name "Successfully mounted $device_name to $mountpoint."
|
|
fi
|
|
fi
|
|
|
|
if [ $messagetype == "kdialog" ]; then
|
|
kdialog --passivepopup "$MSG_TXT" 2
|
|
elif [ $messagetype == "libnotify" ]; then
|
|
notify-send --expire-time=20000 --icon=blueman "$MSG_TXT"
|
|
fi
|
|
|
|
[ "$FAILZOR" = "definitely" ] && exit 1
|
|
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "Opening $mountpoint with $browser..."
|
|
$browser $mountpoint 2>&1
|
|
|
|
}
|
|
|
|
# Unmount function
|
|
umount_device ()
|
|
{
|
|
if grep -qw $mountpoint /proc/mounts 2>/dev/null ; then
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name \
|
|
"$mountpoint has something mounted on it already - unmounting it..."
|
|
|
|
fusermount -u $mountpoint 1>/dev/null 2>/dev/null
|
|
|
|
if [ $? != 0 ]; then
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "Failed to unmount $mountpoint with fusermount..."
|
|
umount -f $mountpoint 1>/dev/null 2>/dev/null
|
|
if [ $? != 0 ]; then
|
|
[ ! -z $DEBUG ] && \
|
|
logger -i -t $own_name \
|
|
"Failed to unmount $mountpoint with umount - try it manually as root and then start over."
|
|
FAILZOR=definitely
|
|
MSG_TXT="Failed to unmount $mountpoint with fusermount and umount - try it as root first."
|
|
else
|
|
break
|
|
fi
|
|
else
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "Successfully unmounted $device_name."
|
|
fi
|
|
else
|
|
[ ! -z $DEBUG ] && logger -i -t $own_name "$mountpoint has nothing mounted on it - continuing..."
|
|
fi
|
|
|
|
if [ $messagetype == "kdialog" ]; then
|
|
kdialog --passivepopup "$MSG_TXT" 3
|
|
elif [ $messagetype == "libnotify" ]; then
|
|
notify-send --expire-time=20000 --icon=blueman "$MSG_TXT"
|
|
fi
|
|
[ "$FAILZOR" = "definitely" ] && exit 1
|
|
}
|
|
|
|
MSG_TXT="Attempting to mount $device_name - please wait..."
|
|
if [ $messagetype == "kdialog" ]; then
|
|
kdialog --passivepopup "$MSG_TXT" 4
|
|
elif [ $messagetype == "libnotify" ]; then
|
|
notify-send --expire-time=20000 --icon=blueman "$MSG_TXT"
|
|
fi
|
|
|
|
umount_device
|
|
mount_device
|
|
|