******* DONE Switching Windows and Desktops According to Window Names and Text Search :blog:pim:software:diy: CLOSED: [2022-10-28 Fri 14:37] :PROPERTIES: :CREATED: [2022-10-28 Fri 14:05] :ID: 2022-10-28-window-teleporting :END: :LOGBOOK: - State "DONE" from "DONE" [2025-07-18 Fri 15:02] - State "DONE" from "DONE" [2024-02-07 Wed 14:35] - State "DONE" from "NEXT" [2022-10-28 Fri 14:37] :END: - Updates - 2024-02-07: remark on Wayland below. - 2025-07-18: solution for Debian 13 with Gnome and Wayland Here is a neat little [[id:tags-pim][PIM]] improvement which has a great impact on my personal way on how to deal with [[https://en.wikipedia.org/wiki/Virtual_desktop][Virtual Desktops]] and windows on my GNU/Linux systems. After using it for a few months, I do find this method brilliant and therefore, I need to blog about it. Working with many application windows on different Virtual Desktops comes with a burden. In most setups, you have to manually switch desktop before you can see the corresponding windows and switch to them. However, in my usual work I know exactly to what window I'm going to jump to, independent of my current Virtual Desktop. Same as with using a (local) search engine to "teleport" to a specific web site, computer file or start an application, I introduced myself to a method to teleport to any open window on my computer. In combination with [[https://addons.mozilla.org/en-US/firefox/addon/window-titler][the Firefox add-on "window-titler"]], I may switch to arbitrary windows by simply invoking a custom keyboard combination, enter a search term (if it's unique with few letters, it's really quick), press Enter and my focus is switched to the Virtual Desktop and the window of choice. ----------------- When I enter "evo" I may jump to my [[id:2021-06-01-Thunderbird-to-Evolution][Evolution email client]]. When I enter "ema" I jump to my [[id:tags-emacs][Emacs]]. Entering "rc" jumps to my Firefox window thich I named "[rc]" using the add-on from above. You get the idea. #+CAPTION: An example popup window when searching for "Untitled". #+ATTR_HTML: :align center :width 630 :linked-image-width original [[tsfile:2022-10-28T14.51.01 rofi window selector -- screenshots publicvoit.png][2022-10-28T14.51.01 rofi window selector -- screenshots publicvoit.png]] I rarely switch desktops or apps otherwise, since I've got that method in place. Few small PIM tricks have had such a great impact on my daily computer usage than this one. ******** My Current Implementation Update 2024-02-07: My implementation mentioned below is only working with [[https://en.wikipedia.org/wiki/X.Org_Server][X.org]] and not with [[https://en.wikipedia.org/wiki/Wayland_(protocol)][Wayland]]. See [[https://ubuntuforums.org/showthread.php?t=2475972][discussions like that]]. If you know how to implement the workflow on Wayland-based machines, please do write a comment! (Note: see next section for a solution with Gnome + Wayland) For the implementation, I found inspiration from [[https://askubuntu.com/questions/660643/switch-between-applications-by-using-the-keyboard][that web page]]. My method requires the following tools: - [[https://github.com/davatorium/rofi][rofi]]: window switcher, application launcher and dmenu replacement - [[https://en.wikipedia.org/wiki/Wmctrl][wmctrl]]: controlling windows - optional: =rofi-theme-selector= for changing the look and feel of the rofi popup window As soon as you understood the principle, you can think of alternative implementation using different tools, of course. In my [[https://en.wikipedia.org/wiki/Xfce][xfce]] environment, I create a new keyboard shortcut. System Settings → "Keyboard" → "Shortcuts" → "Custom Shortcuts". Click the "+" and add the command: : rofi -monitor -2 -show window -kb-accept-alt 'Return' \ : -kb-accept-entry 'Shift+Return' \ : -window-command "/home/vk/src/misc/vk-switch-to-windowid.sh {window}" The name and location of the mentioned shell script may vary. My personal preference for the keyboard shortcut is mapped via [[id:2021-05-23-advantage2-modifications][my QMK keyboard firmware]] to =LAYER + SPACE= for opening the rofi search window. The =vk-switch-to-windowid.sh= script is: #+BEGIN_SRC sh #!/bin/bash WINID="${1}" ## switch to the virtual desktop of the chosen window and show the window: /usr/bin/wmctrl -i -a "${WINID}" ## xfce window manager has a bug where the focus is not correct with "focus ## follows mouse": ## https://github.com/davatorium/rofi/discussions/1585 ## https://www.reddit.com/r/qtools/comments/siksac/using_rofi_show_window_with_focus_follows_mouse/ ## https://gitlab.xfce.org/xfce/xfwm4/-/issues/224 ## This is a workaround to fix that by placing the mouse: /usr/bin/xdotool mousemove -window "${WINID}" 100 -20 #end #+END_SRC You don't need the =xdotool= workaround if you're not affected by [[https://gitlab.xfce.org/xfce/xfwm4/-/issues/224][the xfce/xfwm4 issue]] mentioned. If you want to [[https://github.com/lr-tech/rofi-themes-collection][switch to a different look and feel for rofi]], you might want to invoke =rofi-theme-selector=. I personally use the theme named "arthur" at the moment. Have fun improving your PIM workflows! ******** Update 2025-07: Gnome with Wayland :PROPERTIES: :END: As I'm about to switch to Debian 13 Trixie running Gnome on Wayland, I needed a new method since the one above doesn't work with Wayland. If you're happy with the default search when pressing the Super (Windows) key, you might like [[https://extensions.gnome.org/extension/6730/][WSP (Windows Search Provider) GNOME Shell Extensions]] which includes a window title search to it. For now, I might stick to that method although it searches for way more than just windows.