]> code.delx.au - monosys/commitdiff
gnome-shell-raise-window
authorJames Bunton <jamesbunton@delx.net.au>
Sat, 25 Jan 2020 04:48:30 +0000 (15:48 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Sat, 25 Jan 2020 09:51:53 +0000 (20:51 +1100)
gnome-shell-raise-window [new file with mode: 0755]

diff --git a/gnome-shell-raise-window b/gnome-shell-raise-window
new file mode 100755 (executable)
index 0000000..5c5c166
--- /dev/null
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+set -eu
+
+if [ -z "${1:-}" ]; then
+    echo "Usage: $0 title.endsWith('Page Title - Mozilla Firefox')"
+    exit 1
+fi
+
+MATCHER="$1"
+
+dbus-send --session --type=method_call --dest=org.gnome.Shell /org/gnome/Shell org.gnome.Shell.Eval string:"
+const windows = global.display.get_tab_list(0, null);
+const matching = windows.filter((win) => {
+  const title = win.get_title();
+  return $MATCHER;
+});
+
+if (matching.length > 0) {
+  const win = matching[0];
+  win.get_workspace().activate_with_focus(win, true);
+  win.activate(0);
+}
+"