Created
December 1, 2019 11:13
-
-
Save danilin-em/1d76f409310eeb6967fe1bbefcbc6744 to your computer and use it in GitHub Desktop.
Lock Screen via DBus (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""DBus Display Manager Session Lock | |
@author Evgenii Danilin <evgenii.danilin.m@gmail.com | |
""" | |
import dbus # type: ignore | |
SERVICE_NAME = 'org.freedesktop.DisplayManager' | |
SERVICE_PATH = '/org/freedesktop/DisplayManager/Session0' | |
def get_session_iface(): | |
bus = dbus.SystemBus() | |
proxy = bus.get_object(SERVICE_NAME, SERVICE_PATH) | |
return dbus.Interface(proxy, dbus_interface=SERVICE_NAME+'.Session') | |
def lock(): | |
session_iface = get_session_iface() | |
session_iface.Lock() | |
def main(): | |
lock() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment