def bind_show_app_hotkey(self, accel_name): if is_wayland_compatibility_on(): return if self._current_accel_name == accel_name: return if self._current_accel_name: Keybinder.unbind(self._current_accel_name) self._current_accel_name = None logger.info("Trying to bind app hotkey: %s", accel_name) Keybinder.bind(accel_name, self.toggle_window) self._current_accel_name = accel_name self.notify_hotkey_change(accel_name)
def show_window(self): # works only when the following methods are called in that exact order self.window.set_sensitive(True) self.window.present() self.position_window() if not is_wayland_compatibility_on(): self.present_with_time(Keybinder.get_current_event_time()) if not self.input.get_text(): # make sure frequent apps are shown if necessary self.show_results([]) elif self.settings.get_property('clear-previous-query'): self.input.set_text('') else: self.input.grab_focus()
def bind_show_app_hotkey(self, accel_name): if is_wayland_compatibility_on(): return if self._current_accel_name == accel_name: return if self._current_accel_name: Keybinder.unbind(self._current_accel_name) self._current_accel_name = None logger.info("Trying to bind app hotkey: %s" % accel_name) Keybinder.bind(accel_name, self.toggle_window) self._current_accel_name = accel_name self.notify_hotkey_change(accel_name)
def show_window(self): # works only when the following methods are called in that exact order self.position_window() self.window.set_sensitive(True) self.window.present() if not is_wayland_compatibility_on(): self.present_with_time(Keybinder.get_current_event_time()) if not self.input.get_text(): # make sure frequent apps are shown if necessary self.show_results([]) elif self.settings.get_property('clear-previous-query'): self.input.set_text('') else: self.input.grab_focus()
def finish_initializing(self, builder): """Called while initializing this instance in __new__ finish_initializing should be called after parsing the UI definition and creating a UlauncherWindow object with it in order to finish initializing the start of the new UlauncherWindow instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self, True) self.PreferencesDialog = None # class self.preferences_dialog = None # instance self.results_nav = None self.window = self.ui['ulauncher_window'] self.window_body = self.ui['body'] self.input = self.ui['input'] self.prefs_btn = self.ui['prefs_btn'] self.result_box = self.ui["result_box"] self.input.connect('changed', self.on_input_changed) self.prefs_btn.connect('clicked', self.on_mnu_preferences_activate) self.set_keep_above(True) self.PreferencesDialog = PreferencesUlauncherDialog self.settings = Settings.get_instance() self.fix_window_width() self.position_window() self.init_theme() # this will trigger to show frequent apps if necessary self.show_results([]) if not is_wayland_compatibility_on(): # bind hotkey Keybinder.init() accel_name = self.settings.get_property('hotkey-show-app') # bind in the main thread GLib.idle_add(self.bind_show_app_hotkey, accel_name) start_app_watcher() ExtensionServer.get_instance().start() time.sleep(0.01) ExtensionRunner.get_instance().run_all() if not get_options().no_extensions: ExtensionDownloader.get_instance().download_missing()
def finish_initializing(self, builder): """Called while initializing this instance in __new__ finish_initializing should be called after parsing the UI definition and creating a UlauncherWindow object with it in order to finish initializing the start of the new UlauncherWindow instance. """ # Get a reference to the builder and set up the signals. self.builder = builder self.ui = builder.get_ui(self, True) self.PreferencesDialog = None # class self.preferences_dialog = None # instance self.results_nav = None self.window = self.ui['ulauncher_window'] self.input = self.ui['input'] self.prefs_btn = self.ui['prefs_btn'] self.result_box = self.ui["result_box"] self.input.connect('changed', self.on_input_changed) self.prefs_btn.connect('clicked', self.on_mnu_preferences_activate) self.set_keep_above(True) self.PreferencesDialog = PreferencesUlauncherDialog self.settings = Settings.get_instance() self.fix_window_width() self.position_window() self.init_theme() # this will trigger to show frequent apps if necessary self.show_results([]) if not is_wayland_compatibility_on(): # bind hotkey Keybinder.init() accel_name = self.settings.get_property('hotkey-show-app') # bind in the main thread GLib.idle_add(self.bind_show_app_hotkey, accel_name) start_app_watcher() ExtensionServer.get_instance().start() time.sleep(0.01) ExtensionRunner.get_instance().run_all() ExtensionDownloader.get_instance().download_missing()
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()