Advertising
- nuxil
- Tuesday, January 15th, 2008 at 11:35:49am 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="Bluetooth mobile X locking tool";
- if [[ ! -f $Pd ]]
- then echo $PPID > $Pd ;
- kdialog --msgbox "Bluetooth mobil X lock has started.. please wait while hcitool is scaning for mobile phones" --title "$title";
- else kdialog --yesno "Bluetooth mobil X lock is already Running or it was uncleanly stopped.\n Do you want to stop it?" --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 "Found no Mobile phones. check if bluetooth it turned on" --title "$title"
- 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"`
- 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.