Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Paste Description for bmxl

A bluetooth X locking tool for kde

bmxl
Tuesday, January 15th, 2008 at 7:03:21pm UTC 

  1. #!/bin/bash
  2.  
  3. #       This script should work with a single mobile phone.
  4. #       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.
  5. #       Dont know if it will work with 2 or more phones. it works when only 1 phone is detected, "well it works for me"
  6.  
  7. #       having problems try chmod +s $(which l2ping)
  8. #       if X keeps locking up.. you need to set suid-root on l2ping
  9. #       CTRL +ALT +F2 :then rm -f /home/user/mobkey.pid to stop it..
  10.  
  11. #set -x
  12. Pd="$HOME/mobkey.pid" ;
  13.  
  14.  
  15. title="bmxl a bluetooth looking tool";
  16. message0="bmxl has started. \nplease wait while hcitool is scaning for mobile phones, it may take over 10 seconds"
  17. message1="Bluetooth mobil X lock is already Running or it was uncleanly stopped.\n Do you want to stop it?"
  18. message2="Found no Mobile phones. check if bluetooth is turned on"
  19. message3="Do you want to disable bmxl ?"
  20. icon="--icon /usr/share/icons/crystalsvg/16x16/actions/encrypted.png "
  21.  
  22.  
  23. if [[ ! -f $Pd ]]
  24.         then echo $PPID > $Pd ;
  25.         kdialog --msgbox "$message0" --title "$title" $icon
  26.         else kdialog --yesno "$message1" --title "$title"
  27.                 if [[ $? == 0 ]] ; then rm -f $Pd ; fi ;
  28.                 exit 0 ;
  29. fi ;
  30.  
  31. MOBS=`hcitool scan`
  32. INFOMOB=`echo $MOBS |  sed 's/Scanning ... /\n/g'`
  33. NROFMOB=`echo $MOBS |  sed 's/Scanning ... /\n/g' | wc -l`
  34. ARRAY=""
  35.  
  36. if [[ "${NROFMOB}" -lt "2" ]]
  37.         then kdialog --sorry "$message2" --title "$title" $icon
  38.         rm -f $Pd
  39.         exit 0;
  40. fi
  41.  
  42. for (( i = 1 ; i <= $NROFMOB ; i++ )) ; do
  43.         NAMEMOB=`echo $INFOMOB | awk '{print $2}' | sed -n ""$i"p"`
  44.         MACMOB=`echo $INFOMOB | awk '{print $1}' | sed -n ""$i"p"`
  45.         ARRAY=`echo $ARRAY $MACMOB $NAMEMOB`
  46. done
  47.  
  48. MOBMAC=`kdialog --menu "Select your mobile" $ARRAY  --title "$title" $icon`
  49. if [[ $? == 1 ]]
  50.         then rm -f $Pd
  51.              exit 0;
  52. fi
  53.  
  54. while :; do
  55.         if  [[ ! -f $Pd ]] ; then break ; fi
  56.         l2ping -c1 -t1 -i hci0 $MOBMAC
  57.         if [[ $? == 1 ]] ;
  58.         then if [[ `dcop kdesktop KScreensaverIface isBlanked` == false ]]
  59.                 then `dcop kdesktop KScreensaverIface lock`
  60.                       #kdialog --yesno "$message3" --title "$title"
  61.                       #if [[ $? == 0 ]]
  62.                       #then rm -f $Pd
  63.                         #   exit 0;
  64.                       #fi
  65.              fi
  66.         else if [[ `dcop kdesktop KScreensaverIface isBlanked` == true ]]
  67.                 then dcop kdesktop KScreensaverIface quit
  68.              fi
  69.         fi
  70.         sleep 4;
  71. 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.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

comments powered by Disqus
worth-right
worth-right