I have worked on getting the X display to lock automatically when I
use APM on my laptop.  I used the standard scripts provided by the
package apm-scripts.

I run KDE and the locking is thus governed by the following part of
the shell-script:

        w |tail +3 |awk '{print $1, $3}'|grep -v '-'|grep : | \
            sort -u | \
            while read line; do
            Usern=`echo $line |awk '{print $1}'`
            XDisp=`echo $line |awk '{print $2}'`
            if [ "x`/sbin/pidof 'kdeinit: kdesktop'`" != "x" ]; then
                # We're running KDE - a dcop call is sufficient.
                su $Usern -c "DISPLAY=$XDisp dcop kdesktop KScreensaverIface 'lock()'"
            else

When trying to run the script I encountered two problems:
- the listing from w do not include my DISPLAY, cf the following
  example output

        1:25am  up  7:40,  4 users,  load average: 0.58, 0.61, 0.61
        USER     TTY      FROM              LOGIN@   IDLE   JCPU   PCPU  WHAT
        turtle   pts/1    -                12:59am 26:11   0.00s  0.00s  /bin/cat 

  so the line was removed by grep -v '-' in the pipe.

  I solved this problem by using:

        who |awk '{print $1, $2}'|grep -v '-'|grep : | \

  instead.

- the call to su produced an error that DISPLAY could not be found as
  a command.  I solved that changing the line to:

        su $Usern -c "env DISPLAY=$XDisp dcop kdesktop KScreensaverIface 'lock() '" &
 
So now the scripts are working for me, but I wonder if I am the only
one who have experienced these problems. 

/Peter
-- 
http://www.linearity.org/turtle/contact.html
``When you have had all the experiences, met all the famous people,
made some money, toured the world and got all the acclaim you still
think--is that it? Some might be satisfied--but I wasn't'' -- G. Harrison

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to