Invoking the lock screen using python
Asked Answered
T

1

6

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.

Trisyllable answered 1/1, 2017 at 1:13 Comment(0)
O
8

For Ubuntu:

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

(Source)

For Windows:

import ctypes
ctypes.windll.user32.LockWorkStation()

(Source)

Obla answered 1/1, 2017 at 1:37 Comment(1)
what if gnome is not install, e.g if xfce is install what to do then?Pelerine

© 2022 - 2024 — McMap. All rights reserved.