Pequeño script para bloquear la pantalla por Bluetooth

Abril 18, 2008

Un pequeño script en bash para bloquear la pantalla automáticamente cuando se aleje tu teléfono del ordenador, y se desbloquee cuando vuelvas :)

#!/bin/bash

#Change to your interface
INTERFACE=”00:00:00:00:00:00″

block=0

while true; do
hcitool cc ${INTERFACE} 2>>/dev/null

Signal=”`hcitool lq ${INTERFACE} 2>>/dev/null`”

#echo Signal: $Signal

if [ "0" = "0$Signal" ]; then
echo Desconectado
(( block ++ ))
#if fail at least two times
if [ $block -gt 1 ]; then
#sudo -u username gnome-screensaver-command –lock
dcop kdesktop KScreensaverIface lock
fi
else
if [ "${Signal##*: }" -gt 220 ]; then
echo “Conectado”
if [ $block -gt 0 ]; then
#sudo -u username gnome-screensaver-command –deactivate
dcop kdesktop KScreensaverIface quit
block=0
fi
sleep 5

else
echo “Baja señal”

(( block ++ ))
#if fail at least two times
if [ $block -gt 1 ]; then
#sudo -u username gnome-screensaver-command –lock
dcop kdesktop KScreensaverIface lock
fi
fi
fi

hcitool dc ${INTERFACE} 2>>/dev/null
sleep 1

done

Entry Filed under: Uncategorized. .

Leave a Comment

hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


 

Abril 2008
L M X J V S D
« Ene   May »
 123456
78910111213
14151617181920
21222324252627
282930  

Posts Más Vistos