From c4f7efe2de8adfd663f039b72048187130e85ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Hedin=20Br=C3=B8nner?= Date: Fri, 15 Jun 2018 23:41:58 +0200 Subject: [PATCH] readme: document new window handlers --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 5ad0fe9..0cdc983 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,30 @@ It's possible to create simple rules for placing new windows. Currently mostly u }); ``` +The `wm_class` of a window can be looked up by clicking SuperInsert and then checking the value of `metaWindow.wm_class` in emacs or looking glass. + +### New Window Handlers + +If opening a new application window with SuperN isn't doing exactly what you want you can create custom functions to fit your needs. Say you want new emacs windows to open the current buffer by default, or have new terminals inherit the current directory: + +```javascript + let App = Extension.imports.app; + App.customHandlers['emacs.desktop'] = + () => imports.misc.util.spawn(['emacsclient', '--eval', '(make-frame)']); + App.customHandlers['org.gnome.Terminal.desktop'] = + (metaWindow, app) => app.action_group.activate_action( + "win.new-terminal", + new imports.gi.GLib.Variant("(ss)", ["window", "current"])); +``` + +The app id of a window can be looked up like this: + +```javascript +var Shell = imports.gi.Shell; +var Tracker = Shell.WindowTracker.get_default(); +Tracker.get_window_app(metaWindow); +``` + ## Prior work ##