Esempio n. 1
0
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:
        safe_dbus.call_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE,
                SCREENSAVER_UNINHIBIT_METHOD, GLib.Variant('(u)', (inhibit_id,)), connection)
    except safe_dbus.DBusCallError as e:
        log.info("Unable to uninhibit the screensaver: %s", e)
Esempio n. 2
0
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:
        safe_dbus.call_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE,
                            SCREENSAVER_UNINHIBIT_METHOD, GLib.Variant('(u)', (inhibit_id,)), connection)
    except safe_dbus.DBusCallError as e:
        log.info("Unable to uninhibit the screensaver: %s", e)
Esempio n. 3
0
    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))
        try:
            safe_dbus.call_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH,
                                LOCALED_IFACE, "SetX11Keyboard", args,
                                self._connection)
        except safe_dbus.DBusCallError as e:
            log.error("Failed to set layouts: %s", e)
Esempio n. 4
0
    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))
        try:
            safe_dbus.call_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE,
                                "SetX11Keyboard", args, self._connection)
        except safe_dbus.DBusCallError as e:
            log.error("Failed to set layouts: %s", e)
Esempio n. 5
0
    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))

        try:
            safe_dbus.call_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE,
                                "SetVConsoleKeyboard", args, self._connection)
        except safe_dbus.DBusCallError as e:
            log.error("Failed to set keymap: %s", e)
    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))

        try:
            safe_dbus.call_sync(LOCALED_SERVICE, LOCALED_OBJECT_PATH, LOCALED_IFACE,
                                "SetVConsoleKeyboard", args, self._connection)
        except safe_dbus.DBusCallError as e:
            log.error("Failed to set keymap: %s", e)
Esempio n. 7
0
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 = safe_dbus.call_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE,
                SCREENSAVER_INHIBIT_METHOD, GLib.Variant('(ss)',
                    (SCREENSAVER_APPLICATION, SCREENSAVER_REASON)),
                connection)
        return inhibit_id[0]
    except safe_dbus.DBusCallError as e:
        log.info("Unable to inhibit the screensaver: %s", e)

    return None
Esempio n. 8
0
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 = safe_dbus.call_sync(SCREENSAVER_SERVICE, SCREENSAVER_PATH, SCREENSAVER_IFACE,
                                         SCREENSAVER_INHIBIT_METHOD, GLib.Variant('(ss)',
                                         (SCREENSAVER_APPLICATION, SCREENSAVER_REASON)),
                                         connection)
        return inhibit_id[0]
    except safe_dbus.DBusCallError as e:
        log.info("Unable to inhibit the screensaver: %s", e)

    return None