11/17/2023, 9:39:00 PM Tags: EmacsLinux

Global org-todo capture in wayland

I am using Ubuntu 23.04 with Wayland. Here the tool "wmctrl" is not working anymore. With this is was possible to select a window and bring it directly to focus from commandline. For my TODO Capture I used this, to use a global keyboard shortcut and enter Emacs to put in a TODO

Following lisp code shows the updated setup with a new extension.

lisp
(server-start)
(defadvice raise-frame (after make-it-work (&optional frame) activate)
  "Replaced wmctrl with gnome extension for Ubuntu wayland"
     (call-process
     "busctl" nil nil nil "--user" "call" "org.gnome.Shell" "/de/lucaswerkmeister/ActivateWindowByTitle" "de.lucaswerkmeister.ActivateWindowByTitle" "activateBySubstring" "s" "GNU Emacs"))
(add-hook 'server-switch-hook 'raise-frame)

This starts an emacs server and installs the hook like before, but not using wmctrl. Instead a dbus event is fired to call the gnome shell extension from LukasWerkmeister - ActivateWindowByTitle and get the Emacs window in front.

To set this to a global shortcut it's only necessary to configure the keyboard shortcut in settings, keyboard and call emacsclient org-protocol://capture?template=t with it (be sure to have a template t configured in org-mode). This will cause getting directly to Emacs and being able to add a todo item there.