Call lock screen with python

How can I open a lock screen from a python application? I would like the application to do this for me, instead of pressing Ctrl-Alt-L separately.

+4
source share
1 answer

For Ubuntu:

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

( Source )

For Windows:

import ctypes
ctypes.windll.user32.LockWorkStation()

( Source )

+3
source

Source: https://habr.com/ru/post/1665437/


All Articles