You are not logged in.

Dear visitor, welcome to KDE-Forum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, January 13th 2008, 4:12pm

"Lock session" programmatically?

Hello. How can i lock session (black screen with password prompt) programmatically?
By DCOP?

My intent is to make this:
Computer boots, x-window starts automatically and user is logged-in automatically but the session becomes locked.
_benefits_ : Saves time, because the programs and kde would load automatically "in the background" ; without losing security due to auto-login.

Any hints on how to achieve this?

2

Tuesday, January 22nd 2008, 12:45pm

RE: "Lock session" programmatically?

In "kdcop" there is

kdesktop / KDesktopIface

There is "void logout()" but it isn't useful for what i am trying to do.

I wonder why there are "so few" reponses to this thread.

Ronald

Beginner

Posts: 13

Location: Netherlands

  • Send private message

3

Tuesday, January 22nd 2008, 3:31pm

RE: "Lock session" programmatically?


4

Tuesday, January 22nd 2008, 4:53pm

RE: "Lock session" programmatically?

Thanks. That's useful.
I tried searching for "lock" in kdcop but the search now turns out to be "shallow" (doesn't go into subbranches) and that's why i didn't find "lock".

Thanks again.

The next question is where should I put this command
/usr/bin/dcop --all-users --all-sessions kdesktop KScreensaverIface lock >> /home/karolrvn/adfadf/logs/xinitrc_log.txt

?
~/.xinitrc -> doesn't seem to work
~/.kdeinitrc -> is this for "scripts" also? Or only for "option=value"?

Ronald

Beginner

Posts: 13

Location: Netherlands

  • Send private message

5

Tuesday, January 22nd 2008, 8:51pm

Hi again! You should put that command in a .sh and save that file to ~/.kde/Autostart (chmod it executable for your user off course). I believe that works. One thing of concern would be that you don't know when KScreensaverIface becomes available in the starting process and that you don't know when the programs/links in that directory are being executed. So maybe you have to incorporate a pause, but that can easily be done with sleep :)

Hope this helps, I'm curious to see if it works.

6

Tuesday, January 22nd 2008, 9:09pm

Thanks.

lockWorkstation script:

Source code

1
2
3
4
5
6
7
8
9
#!/bin/sh
logfiletxt=/home/karolrvn/adfadf/logs/lockWorkstation_log.txt

for ((i=0;i<15;i+=1)); do
date +%F_%H_%M_%S_%N >> $logfiletxt
echo "lockingWorkstation" >> $logfiletxt
/usr/bin/dcop --all-users --all-sessions kdesktop KScreensaverIface lock >> $logfiletxt
sleep 1
done

I run it in background from Autostart as You suggested (from another script). :
/home/karolrvn/adfadf/bin/lockWorkstation &

As You can see i run it 15 times with 1 second sleep, in background (&).

It works but there is a problem: there is a delay (about 3-5 seconds) between when the desktop shows and the session is locked which theoretically makes the desktop "vulnerable". Looks like a delay caused by general "traffic jam" on system startup ( many programs are starting simultanously ). I wanted to try "nice --adjustment=-19" but negative niceness is not permitted for normal users so i didn't persist.

Any more hints?
It would be nice to start the script _before_ KDE starts resuming session ( bringing back apps ).
Perhaps there is a way to do it X-Windows-way instead of KDE-way. This could perhaps be executed earlier.

PS
I wonder what is the purpose of ~/.xinitrc (maybe i got it wrong? or there is no such thing actually?) ; it does not seem to execute.

Ronald

Beginner

Posts: 13

Location: Netherlands

  • Send private message

7

Tuesday, January 22nd 2008, 10:17pm

I suspect your script is run last in the KDE start process and I'm afraid there is not much you can do about this fact. If you really want a full proof system, you could look into Xscreensaver. It surely starts during or before KDE starts and also is capable of locking the screen via a command (xscreensaver-command -lock).

8

Wednesday, January 23rd 2008, 2:17pm

a script that runs when user logs into X

Maybe there is a script/place that executes when user _logs_ into X-window?
( xinitrc seems to be meant to be executed when x-window itself starts )

Ronald

Beginner

Posts: 13

Location: Netherlands

  • Send private message

9

Wednesday, January 23rd 2008, 6:28pm

I don't know such a script or place, but there might indeed ;) Point is that you cannot lock the KDE way because that way becomes available seconds after the desktop has appeared.

10

Monday, January 28th 2008, 4:32pm

/etc/gdm/PostLogin/Default

I placed

Source code

1
xlock -mode blank

in

Source code

1
/etc/gdm/PostLogin/Default


But it runs as root ( works instantly but needs root password to unlock ).
Is there any similar place that would run as the user that logs in instead of root???

I tested some scripts in /etc/ , mostly /etc/gdm but some scripts don't run at all and others run as different users (root, gdm).

No "standard" script in home directory ( .xinitrc, .Xclients ) runs at all -> does anyone know why it's like this in Ubuntu?

Sorry that this is offtopic (non-KDE) but i decided to post my findings anyway.

This post has been edited 1 times, last edit by "karolrvn" (Jan 28th 2008, 4:34pm)


Ronald

Beginner

Posts: 13

Location: Netherlands

  • Send private message

11

Monday, January 28th 2008, 4:36pm

Can't you use sudo for this?

12

Monday, January 28th 2008, 4:45pm

sudo -u karolrvn xlock -mode blank

I tried

Source code

1
sudo -u karolrvn xlock -mode blank

but it didn't seem to work.