def setup(self, _): self.hold() # Keep the app running even without a window # These modules are very heavy, so we don't want to load them in the remote # pylint: disable=import-outside-toplevel from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow self.window = UlauncherWindow.get_instance() self.window.set_application(self)
def _hide_window(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() if window.is_visible(): # update UI in the main thread to avoid race conditions GLib.idle_add(window.hide_and_clear_input)
def _hide_window(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() if window.is_visible(): # update UI in the main thread to avoid race conditions GLib.idle_add(window.hide_and_clear_input)
def setup(self, _): self.hold() # Keep the app running even without a window self.window = window = UlauncherWindow.get_instance() window.set_application(self) window.set_keep_above(True) window.position_window() window.init_theme() # this will trigger to show frequent apps if necessary window.show_results([]) if self.settings.get_property('show-indicator-icon'): self.appindicator = AppIndicator(self) self.appindicator.switch(True) if IS_X11: # bind hotkey Keybinder.init() accel_name = self.settings.get_property('hotkey-show-app') # bind in the main thread GLib.idle_add(self.bind_hotkey, accel_name) ExtensionServer.get_instance().start() time.sleep(0.01) ExtensionRunner.get_instance().run_all()
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("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 quiting 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.warn('On KeyboardInterrupt') finally: Gtk.main_quit()
def run(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() if window.is_visible(): # update UI in the main thread to avoid race conditions GLib.idle_add(window.show_results, self.result_list)
def prefs_set_hotkey_show_app(self, query): hotkey = query['value'] # Bind a new key # pylint: disable=import-outside-toplevel from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.bind_hotkey(hotkey) self.settings.set_property('hotkey-show-app', hotkey)
def main(): """ Main function that starts everything """ # 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: print( "DBus name already taken. Ulauncher is probably backgrounded. Did you mean `ulauncher-toggle`?", file=sys.stderr) 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()
def get_instance(cls): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() indicator = cls("ulauncher") indicator.set_icon('ulauncher-indicator') indicator.add_menu_item(window.on_mnu_preferences_activate, "Preferences") indicator.add_menu_item(window.on_mnu_about_activate, "About") indicator.add_seperator() indicator.add_menu_item(Gtk.main_quit, "Exit") return indicator
def _update_query(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow input = UlauncherWindow.get_instance().get_input() input.set_text(self.new_query) # Ugly hack: # Defer set position, because GTK sets position after change event occurs sleep(0.002) input.set_position(len(self.new_query))
def prefs_set_theme_name(self, url_params): name = url_params['query']['value'] logger.info('Set theme-name to %s' % name) self.settings.set_property('theme-name', name) self.settings.save_to_file() from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.init_theme()
def prefs_set_hotkey_show_app(self, url_params): hotkey = url_params['query']['value'] logger.info('Set hotkey-show-app to %s' % hotkey) # Bind a new key from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.bind_show_app_hotkey(hotkey) self.settings.set_property('hotkey-show-app', hotkey) self.settings.save_to_file()
def prefs_set_theme_name(self, url_params): name = url_params['query']['value'] logger.info('Set theme-name to %s', name) self.settings.set_property('theme-name', name) self.settings.save_to_file() from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.init_theme()
def _update_query(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow input = UlauncherWindow.get_instance().get_input() input.set_text(self.new_query) # Ugly hack: # Defer set position, because GTK sets position after change event occurs sleep(0.002) input.set_position(len(self.new_query))
def get_instance(cls): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() indicator = cls("ulauncher") indicator.set_icon('ulauncher-indicator') indicator.add_menu_item(window.on_mnu_preferences_activate, "Preferences") indicator.add_menu_item(window.on_mnu_about_activate, "About") indicator.add_seperator() indicator.add_menu_item(Gtk.main_quit, "Exit") return indicator
def prefs_set_hotkey_show_app(self, url_params): hotkey = url_params['query']['value'] logger.info('Set hotkey-show-app to %s', hotkey) # Bind a new key from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.bind_show_app_hotkey(hotkey) self.settings.set_property('hotkey-show-app', hotkey) self.settings.save_to_file()
def main(): """ Main function that starts everything """ # 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: print("Ulauncher is already running") show_window = dbus.SessionBus().get_object( DBUS_SERVICE, DBUS_PATH).get_dbus_method("show_window") show_window() return _create_dirs() options = get_options() setup_logging(options) logger = logging.getLogger('ulauncher') logger.info('Ulauncher version %s' % get_version()) logger.info("GTK+ %s.%s.%s" % (Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())) # 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 quiting the app app_killer = GracefulAppKiller() gtk_thread = run_async(Gtk.main)() try: while gtk_thread.is_alive() and not app_killer.killed(): time.sleep(0.5) except KeyboardInterrupt: logger.warn('On KeyboardInterrupt') finally: Gtk.main_quit()
def on_hotkey_show_app_key_press_event(self, widget, event): # remove GDK_MOD2_MASK, because it seems unnecessary mask = event.state if mask & Gdk.ModifierType.MOD2_MASK: mask ^= Gdk.ModifierType.MOD2_MASK label = Gtk.accelerator_get_label(event.keyval, mask) accel_name = Gtk.accelerator_name(event.keyval, mask) # do nothing for invalid hotkeys if not self.is_valid_hotkey(label, accel_name): logger.debug("Invalid hotkey '%s', ('%s') is not allowed" % (label, accel_name)) return # Bind a new key from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow UlauncherWindow.get_instance().bind_show_app_hotkey(accel_name) widget.set_text(label) self.settings.set_property('hotkey-show-app', accel_name) self.settings.save_to_file()
def run(self): """ Runs :meth:`~ulauncher.api.server.ExtensionController.ExtensionController.trigger_event` with :class:`ItemEnterEvent` """ # import here to avoid circular deps from ulauncher.api.server.DeferredResultRenderer import DeferredResultRenderer from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() if not window.is_visible(): return renderer = DeferredResultRenderer.get_instance() controller = renderer.get_active_controller() if controller: controller.trigger_event(ItemEnterEvent(self._data))
def run(self): """ Runs :meth:`~ulauncher.api.server.ExtensionController.ExtensionController.trigger_event` with :class:`ItemEnterEvent` """ # import here to avoid circular deps from ulauncher.api.server.DeferredResultRenderer import DeferredResultRenderer from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow window = UlauncherWindow.get_instance() if not window.is_visible(): return renderer = DeferredResultRenderer.get_instance() controller = renderer.get_active_controller() if controller: controller.trigger_event(ItemEnterEvent(self._data))
def prefs_set(self, query): property = query['property'] value = query['value'] # This setting is not stored to the config if property == 'autostart-enabled': self.prefs_set_autostart(value) return self.settings.set_property(property, value) if property == 'show-indicator-icon': # pylint: disable=import-outside-toplevel from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() GLib.idle_add(AppIndicator.get_instance(ulauncher_window).switch, value) if property == 'theme-name': self.prefs_apply_theme()
def main(): _create_dirs() options = parse_options() set_up_logging(options) logger = logging.getLogger('ulauncher') logger.info('Ulauncher version: %s' % get_version()) # 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: logger.debug("Getting the existing instance...") show_window = dbus.SessionBus().get_object( DBUS_SERVICE, DBUS_PATH).get_dbus_method("show_window") show_window() else: logger.debug("Starting a new instance...") 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() @run_async def run_main(): Gtk.main() main_thread = run_main() # workaround to make Ctrl+C quiting the app try: while main_thread.is_alive(): time.sleep(1) except KeyboardInterrupt: logger.info('On KeyboardInterrupt') Gtk.main_quit() main_thread.join() sys.exit(0)
def run(self): from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow UlauncherWindow.get_instance().show_results(self.restul_list)
def prefs_apply_theme(self): # pylint: disable=import-outside-toplevel from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow ulauncher_window = UlauncherWindow.get_instance() ulauncher_window.init_theme()
def __init__(self, new_query): self.new_query = new_query from ulauncher.ui.windows.UlauncherWindow import UlauncherWindow self._input = UlauncherWindow.get_instance().input
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("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 quiting 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.warn('On KeyboardInterrupt') finally: Gtk.main_quit()