def prefs_get_all(self, url_params):
     logger.info('API call /get/all')
     return {
         'show_indicator_icon':
         self.settings.get_property('show-indicator-icon'),
         'hotkey_show_app':
         self.get_app_hotkey(),
         'autostart_allowed':
         self.autostart_pref.is_allowed(),
         'autostart_enabled':
         self.autostart_pref.is_on(),
         'show_recent_apps':
         self.settings.get_property('show-recent-apps'),
         'clear_previous_query':
         self.settings.get_property('clear-previous-query'),
         'blacklisted_desktop_dirs':
         self.settings.get_property('blacklisted-desktop-dirs'),
         'available_themes':
         self._get_available_themes(),
         'theme_name':
         Theme.get_current().get_name(),
         'is_wayland':
         is_wayland(),
         'env': {
             'version': get_version(),
             'user_home': os.path.expanduser('~')
         }
     }
 def prefs_get_all(self, url_params):
     logger.info('API call /get/all')
     return {
         'show_indicator_icon': self.settings.get_property('show-indicator-icon'),
         'hotkey_show_app': self.get_app_hotkey(),
         'autostart_allowed': self.autostart_pref.is_allowed(),
         'autostart_enabled': self.autostart_pref.is_on(),
         'show_recent_apps': self.settings.get_property('show-recent-apps'),
         'clear_previous_query': self.settings.get_property('clear-previous-query'),
         'blacklisted_desktop_dirs': self.settings.get_property('blacklisted-desktop-dirs'),
         'available_themes': self._get_available_themes(),
         'theme_name': Theme.get_current().get_name(),
         'is_wayland': is_wayland(),
         'env': {
             'version': get_version(),
             'user_home': os.path.expanduser('~')
         }
     }
Пример #3
0
def main():
    """
    Main function that starts everything
    """
    if is_wayland(
    ) and gdk_backend().lower() != 'x11' and not is_wayland_compatibility_on():
        warn = """
                    [!]
        Looks like you are in Wayland session
        Please run Ulauncher with env var
        GDK_BACKEND set to 'x11' like this:

        GDK_BACKEND=x11 ulauncher
        """
        print(warn, file=sys.stderr)
        sys.exit(1)

    # start DBus loop
    DBusGMainLoop(set_as_default=True)
    bus = dbus.SessionBus()
    instance = bus.request_name(DBUS_SERVICE)

    if instance != dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        toggle_window = dbus.SessionBus().get_object(
            DBUS_SERVICE, DBUS_PATH).get_dbus_method("toggle_window")
        toggle_window()
        return

    _create_dirs()

    options = get_options()
    setup_logging(options)
    logger = logging.getLogger('ulauncher')
    logger.info('Ulauncher version %s', get_version())
    logger.info('Extension API version %s', api_version)
    logger.info("GTK+ %s.%s.%s", Gtk.get_major_version(),
                Gtk.get_minor_version(), Gtk.get_micro_version())
    logger.info("Is Wayland: %s", is_wayland())
    logger.info("Wayland compatibility: %s",
                ('on' if is_wayland_compatibility_on() else 'off'))

    # log uncaught exceptions
    def except_hook(exctype, value, tb):
        logger.error("Uncaught exception", exc_info=(exctype, value, tb))

    sys.excepthook = except_hook

    window = UlauncherWindow.get_instance()
    UlauncherDbusService(window)
    if not options.hide_window:
        window.show()

    if Settings.get_instance().get_property('show-indicator-icon'):
        AppIndicator.get_instance().show()

    # workaround to make Ctrl+C quitting the app
    signal_handler = SignalHandler(window)
    gtk_thread = run_async(Gtk.main)()
    try:
        while gtk_thread.is_alive() and not signal_handler.killed():
            time.sleep(0.5)
    except KeyboardInterrupt:
        logger.warning('On KeyboardInterrupt')
    finally:
        Gtk.main_quit()