I have a Raspberry Pi with openvpn installed and running perfect and I want to launch a command after the desktop mode enters and after all is loaded and running including openvpn on Raspbian. I installed the x11 screen saver package and the command I want to execute after desktop mode auto enters is:

    xscreensaver-command -lock

Simply like that just run that after all is loaded. I mean with after all is loaded to all raspbian OS loads perfect with my whole configurations I have including openvpn because I don't know if put before something the lock can cause not load the whole raspbian and also cause that until I give a password resume the loading of the raspbian and I don't want that. I just want that the raspbian load everything like it is now running Desktop mode and lock the screen with that command. NOTE: And I just want to execute after desktop mode enters NOT AT SHUTDOWN.

What I did was:

sudo nano /etc/init.d/testlock

My testlock file is:

#! /bin/sh
# /etc/init.d/testlock

        ### BEGIN INIT INFO
        # Provides:          testlock
        # Required-Start:    $remote_fs $syslog
        # Required-Stop:     $remote_fs $syslog
        # Default-Start:     2 3 4 5
        # Default-Stop:      0 1 6
        # Short-Description: testlock script
        # Description:       testlock script
        ### END INIT INFO
    xscreensaver-command -lock

After I gave this command to make executable:

sudo chmod 755 /etc/init.d/testlock

I made a test to see if works:

sudo /etc/init.d/testlock start

And runs perfect the test it locks the screen very well the script. Now I did to run after reboot:

sudo update-rc.d testlock defaults

And after reboot the Raspberry Pi nothing happens the script is never executed Just I see the normal Desktop mode like always. Anyone have an idea how can I make to work? But like I said after all is loaded to avoid interfere in the loading of the raspbian and configurations because like this is an openvpn server and what I just want to do is to keep running all normally like I have now but just with the executed command protect with password.

Anyone know what I need to modify or do to execute my testlock script after all Desktop mode is loaded?

1 Answer 1


The screen saver needs the X11 server to be up and running, so you need to replace

Required-Start:    $remote_fs $syslog

by at least

Required-Start:    $remote_fs $syslog x11-common

though if you are using a login manager like lightdm, you should add that to the requirement too.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .