def uninhibit_screensaver(connection, inhibit_id): """ Re-enable the screensaver idle timer. :param connection: A handle for the session message bus :type connection: Gio.DBusConnection :param inhibit_id: The ID returned by the inhibit method :type inhibit_id: int """ try: dbus_call_safe_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE, SCREENSAVER_UNINHIBIT_METHOD, GLib.Variant('(u)', (inhibit_id,)), connection) except DBusCallError as e: log.info("Unable to uninhibit the screensaver: %s", e)
def set_layouts(self, layouts_variants, options=None, convert=False): """ Method that sets X11 layouts and variants (for later X sessions) via systemd-localed's DBus API. :param layout_variant: list of 'layout (variant)' or 'layout' specifications of layouts and variants :type layout_variant: list of strings :param options: list of X11 options that should be set :type options: list of strings :param convert: whether the keymap should be converted to a X11 layout (see set_and_convert_keymap) :type convert: bool """ layouts = [] variants = [] for layout_variant in (nonempty for nonempty in layouts_variants if nonempty): (layout, variant) = parse_layout_variant(layout_variant) layouts.append(layout) variants.append(variant) layouts_str = ",".join(layouts) variants_str = ",".join(variants) if options: opts_str = ",".join(options) else: opts_str = "" # args: layout, model, variant, options, convert, user_interaction # where convert indicates whether the keymap should be converted # to X11 layout and user_interaction indicates whether PolicyKit # should ask for credentials or not args = GLib.Variant( "(ssssbb)", (layouts_str, "", variants_str, opts_str, convert, False)) dbus_call_safe_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "SetX11Keyboard", args, self._connection)
def set_keymap(self, keymap, convert=False): """ Method that sets VConsole keymap via systemd-localed's DBus API. :param keymap: VConsole keymap that should be set :type keymap: str :param convert: whether the keymap should be converted to a X11 layout (see set_and_convert_keymap) :type convert: bool """ # args: keymap, keymap_toggle, convert, user_interaction # where convert indicates whether the keymap should be converted # to X11 layout and user_interaction indicates whether PolicyKit # should ask for credentials or not args = GLib.Variant('(ssbb)', (keymap, "", convert, False)) dbus_call_safe_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "SetVConsoleKeyboard", args, self._connection)
def set_layouts(self, layouts_variants, options=None, convert=False): """ Method that sets X11 layouts and variants (for later X sessions) via systemd-localed's DBus API. :param layout_variant: list of 'layout (variant)' or 'layout' specifications of layouts and variants :type layout_variant: list of strings :param options: list of X11 options that should be set :type options: list of strings :param convert: whether the keymap should be converted to a X11 layout (see set_and_convert_keymap) :type convert: bool """ layouts = [] variants = [] for layout_variant in (nonempty for nonempty in layouts_variants if nonempty): (layout, variant) = parse_layout_variant(layout_variant) layouts.append(layout) variants.append(variant) layouts_str = ",".join(layouts) variants_str = ",".join(variants) if options: opts_str = ",".join(options) else: opts_str = "" # args: layout, model, variant, options, convert, user_interaction # where convert indicates whether the keymap should be converted # to X11 layout and user_interaction indicates whether PolicyKit # should ask for credentials or not args = GLib.Variant("(ssssbb)", (layouts_str, "", variants_str, opts_str, convert, False)) dbus_call_safe_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE, "SetX11Keyboard", args, self._connection)
def inhibit_screensaver(connection): """ Inhibit the screensaver idle timer. :param connection: A handle for the session message bus :type connection: Gio.DBusConnection :return: The inhibit ID or None :rtype: int or None """ try: inhibit_id = dbus_call_safe_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE, SCREENSAVER_INHIBIT_METHOD, GLib.Variant('(ss)', (SCREENSAVER_APPLICATION, SCREENSAVER_REASON)), connection) return inhibit_id[0] except DBusCallError as e: log.info("Unable to inhibit the screensaver: %s", e) return None