I have program which is starting on boot when raspberry powered up. What I want to do is prevent someone to plug a hdmi cable and see desktop of raspberry. Is it possible to set screensaver? Of course it should ask a password to unlock the screensaver?

  • On what OS + version? Do you use a GUI/Desktop? Please update your question with these and other relevant details.
    – Dirk
    Commented Nov 15, 2018 at 9:16
  • If you use Raspbian with Desktop then xscreensaver may work for you. Install it with sudo apt install
    – Dirk
    Commented Nov 15, 2018 at 10:30

1 Answer 1


Open the terminal on Raspberry Pi itself or you can do this in SSH also:

sudo pkill -f lxsession

GUI session will logout and display the Login screen. SSH session will remain logged in.

If you want to blank the display, type following in the terminal:

xset -display :0 dpms force off


  • this will work only if the desktop session is logged in
  • The screen will turn on if the mouse or keyboard is used.

This command will disable HDMI port

To disable port

vcgencmd display_power 0

To enable port

vcgencmd display_power 1
  • This does not really answer the question. However +1 for the good alternatives.
    – Ingo
    Commented Nov 15, 2018 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.