Skip to content

Instantly share code, notes, and snippets.

@junkblocker
Created September 25, 2025 05:31
Show Gist options
  • Select an option

  • Save junkblocker/6f80c4672420a9cddf94007cc76729b4 to your computer and use it in GitHub Desktop.

Select an option

Save junkblocker/6f80c4672420a9cddf94007cc76729b4 to your computer and use it in GitHub Desktop.
diff --git c/.talon/user/mine/firefox_wayland.talon i/.talon/user/mine/firefox_wayland.talon
new file mode 100644
index 000000000..dbf281dbe
--- /dev/null
+++ i/.talon/user/mine/firefox_wayland.talon
@@ -0,0 +1,4 @@
+user.wayland_window_class: org.mozilla.firefox
+-
+# This activates the tag 'user.tabs'.
+tag(): user.tabs
diff --git c/.talon/user/mine/wayland_tabs.talon i/.talon/user/mine/wayland_tabs.talon
new file mode 100644
index 000000000..3b6ab9fee
--- /dev/null
+++ i/.talon/user/mine/wayland_tabs.talon
@@ -0,0 +1,8 @@
+# This selects for the tag 'user.tabs'.
+tag: user.tabs
+-
+(open | new) tab: app.tab_open()
+last tab: app.tab_previous()
+next tab: app.tab_next()
+close tab: app.tab_close()
+reopen tab: app.tab_reopen()
diff --git c/.talon/user/mine/wayland_window_class.py i/.talon/user/mine/wayland_window_class.py
new file mode 100644
index 000000000..30e8cfadb
--- /dev/null
+++ i/.talon/user/mine/wayland_window_class.py
@@ -0,0 +1,40 @@
+import subprocess
+
+from talon import Module, cron, ui
+
+mod = Module()
+# this declares a tag in the user namespace (i.e. 'user.tabs')
+mod.tag(
+ "tabs",
+ desc="basic commands for working with tabs within a window are available",
+)
+
+
+def get_wawc():
+ """
+ Determine the Wayland Window Class (title) of the currently active window
+ """
+
+ try:
+ process_result = subprocess.run(
+ ["kdotool", "getactivewindow", "getwindowclassname"],
+ check=False,
+ capture_output=True,
+ )
+ if process_result.returncode == 0:
+ for line in process_result.stdout.decode().splitlines():
+ return line
+ except Exception as e:
+ print(f"get_wawc() threw exception: {e}")
+ return "unknown"
+
+ return "unknown"
+
+
[email protected]
+def window_class_scope():
+ return {"wayland_window_class": get_wawc()}
+
+
+ui.register("win_focus", window_class_scope.update)
+cron.interval("2s", window_class_scope.update)
diff --git c/.talon/user/mine/wayland_window_name.py i/.talon/user/mine/wayland_window_name.py
new file mode 100644
index 000000000..777d98c7b
--- /dev/null
+++ i/.talon/user/mine/wayland_window_name.py
@@ -0,0 +1,35 @@
+import subprocess
+
+from talon import Module, app, cron, ui
+
+mod = Module()
+
+
+def get_wayland_active_window_name():
+ """
+ Determine the Wayland Window Name (title) of the currently active window
+ """
+
+ try:
+ process_result = subprocess.run(
+ ["kdotool", "getactivewindow", "getwindowname"],
+ check=False,
+ capture_output=True,
+ )
+ if process_result.returncode == 0:
+ for line in process_result.stdout.decode().splitlines():
+ return line
+ except Exception:
+ return "unknown"
+
+ return "unknown"
+
+
+if app.platform == "linux":
+
+ @mod.scope
+ def window_name_scope():
+ return {"wayland_window_name": get_wayland_active_window_name()}
+
+ ui.register("win_focus", lambda _: window_name_scope.update)
+ cron.interval("2s", window_name_scope.update)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment