diff options
-rw-r--r-- | blueman_open | 84 |
1 files changed, 79 insertions, 5 deletions
diff --git a/blueman_open b/blueman_open index 8ca9769..50d6b43 100644 --- a/blueman_open +++ b/blueman_open @@ -5,12 +5,59 @@ own_name=$(basename $0) dir=$(mktemp -d)/$phone_addr browser=${browser:-"xdg-open"} +# Check for kdialog + +if which kdialog &>/dev/null; then + messagetype="kdialog2" +else + messagetype="gtkdialog" +fi + +# gtkdialog stuff + +function gtkbox1() { + export messagebox=' + <vbox> + <frame Blueman Open Device.> + <text> + <label>"'`echo $1`'"</label> + </text> + </frame> + </vbox> + ' +} + +function gtkbox2() { + export messagebox=' + <vbox> + <frame Blueman Open Device.> + <text> + <label>"'`echo $1`'"</label> + </text> + <hbox> + <button ok></button> + </hbox> + </frame> + </vbox> + ' +} +function gtkmessage() { + I=$IFS; IFS="" + for STATEMENT in $(gtkdialog --center --program=messagebox); do + eval $STATEMENT + done + IFS=$I +} + +#mount function + mount_phone () { i=0 LIMIT=5 while [ $i -lt $LIMIT ] do + printf "$i " logger -i -t $own_name "Perform $i try to mount phone $phone_addr to $dir using obexfs" logger -i -t $own_name "Execute: obexfs -b $phone_addr -B 10 $dir" @@ -20,7 +67,13 @@ mount_phone () logger -i -t $own_name "Found $mounts mounted $dir inside /proc/mounts" if [ $mounts -ne 0 ] ;then - kdialog --passivepopup "Successfully mounted $phone_addr to $dir" 2 + progress=99 + if [ $messagetype == "kdialog" ]; then + kdialog --passivepopup "Successfully mounted $phone_addr to $dir" 2 + else + gtkbox2 $"Successfully mounted $phone_addr to $dir" + gtkmessage + fi logger -i -t $own_name "Open $dir with $browser" out=$($browser $dir 2>&1) logger -i -t $own_name "$out" @@ -28,14 +81,22 @@ mount_phone () else logger -i -t $own_name "Failed to mount $phone_addr to $dir from the $i try" fi - sleep1 + sleep 1 ((i += 1)) done if [ $mounts -eq 0 ] ;then - kdialog --passivepopup "Failed to mount $phone_addr to $dir.\nCheck /var/log/messages for errors." 4 + if [ $messagetype == "kdialog" ]; then + kdialog --passivepopup "Failed to mount $phone_addr to $dir.\nCheck /var/log/messages for errors." 4 + else + gtkbox2 $"Failed to mount $phone_addr to $dir. Check /var/log/messages for errors." + gtkmessage + fi + killall gtkdialog fi } +#unmount function + umount_phone () { mounts=$(grep $dir /proc/mounts | wc -l) @@ -48,7 +109,12 @@ umount_phone () logger -i -t $own_name "Successfully unmounted $dir." else logger -i -t $own_name "$dir is already mounted. Failed to umount $dir.$out. Please perform its umount manually." - kdialog --passivepopup "Failed to umount $dir - check /var/log/messages for errors" 4 + if [ $messagetype == "kdialog" ]; then + kdialog --passivepopup "Failed to umount $dir - check /var/log/messages for errors" 4 + else + gtkbox2 $"Failed to umount $dir - check /var/log/messages for errors" + gtkmessage + fi exit fi else @@ -56,15 +122,23 @@ umount_phone () fi } +#mkdir function + create_dir () { + progress=1 logger -i -t $own_name "Create directory $dir to mount the phone by bluetooth..." out=$(mkdir -p $dir 2>&1) logger -i -t $own_name "$out" } +if [ $messagetype == "kdialog" ]; then + kdialog --passivepopup "Mount phone is in progress... Please wait..." 4 +else + gtkbox1 $"Mount phone is in progress... Please wait..." + gtkmessage& +fi -kdialog --passivepopup "Mount phone is in progress... Please wait..." 4 create_dir umount_phone mount_phone |