Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking the lock screen using python

How can I bring up the lock screen from within a python app? I would like the application to do that for me instead of pressing the Ctrl-Alt-L separately.

like image 770
ArekBulski Avatar asked Jan 01 '17 01:01

ArekBulski


1 Answers

For Ubuntu:

os.popen('gnome-screensaver-command --lock')

(Source)

For Windows:

import ctypes
ctypes.windll.user32.LockWorkStation()

(Source)

like image 51
Stephen Rauch Avatar answered Oct 23 '22 11:10

Stephen Rauch