Advertising
- Stuff
- Tuesday, January 15th, 2008 at 2:15:52pm UTC
- #!/bin/bash
- # This script should work with a single mobile phone.
- # Possible BUG: i tried to make it so if you have 2 or more phones you can select the one you want from a gui menu.
- # Dont know if it will work with 2 or more phones. it works when only 1 phone is detected, "well it works for me"
- #set -x
- Pd="/home/`whoami`/mobkey.pid" ;
- title="bmxl a bluetooth looking tool";
- message0="bmxl has started. \nplease wait while hcitool is scaning for mobile phones, it may take over 10 seconds"
- message1="Bluetooth mobil X lock is already Running or it was uncleanly stopped.\n Do you want to stop it?"
- message2="Found no Mobile phones. check if bluetooth is turned on"
- icon="--icon /usr/share/icons/crystalsvg/16x16/actions/encrypted.png "
- if [[ ! -f $Pd ]]
- then echo $PPID > $Pd ;
- kdialog --msgbox "$message0" --title "$title" $icon
- else kdialog --yesno "$message1" --title "$title"
- if [[ `echo $?` == 0 ]] ; then rm -f $Pd ; fi ;
- exit 0 ;
- fi ;
- MOBS=`hcitool scan`
- INFOMOB=`echo $MOBS | sed 's/Scanning ... /\n/g'`
- NROFMOB=`echo $MOBS | sed 's/Scanning ... /\n/g' | wc -l`
- ARRAY=""
- if [[ "${NROFMOB}" -lt "2" ]]
- then kdialog --sorry "$message2" --title "$title" $icon
- rm -f $Pd
- exit 0;
- fi
- for (( i = 1 ; i <= $NROFMOB ; i++ )) ; do
- NAMEMOB=`echo $INFOMOB | awk '{print $2}' | sed -n ""$i"p"`
- MACMOB=`echo $INFOMOB | awk '{print $1}' | sed -n ""$i"p"`
- ARRAY=`echo $ARRAY $MACMOB $NAMEMOB`
- done
- MOBMAC=`kdialog --menu "Select your mobile" $ARRAY --title "$title" $icon`
- if [[ `echo $?` == 1 ]]
- then rm -f $Pd
- exit 0;
- fi
- while :; do
- if [[ ! -f $Pd ]] ; then break ; fi
- if [[ `hcitool scan | grep -oc $MOBMAC` == 0 ]] ;
- then if [[ `dcop kdesktop KScreensaverIface isBlanked` == false ]]
- then `dcop kdesktop KScreensaverIface lock`
- fi
- else if [[ `dcop kdesktop KScreensaverIface isBlanked` == true ]]
- then dcop kdesktop KScreensaverIface quit
- fi
- fi
- sleep 1;
- done
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.