From 3def53e0d8a3d3f252a6701ec8932593786aa14a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=A4user?= Date: Sun, 8 Nov 2026 23:40:08 +0100 Subject: [PATCH] initial import: wide tiling extension (gnome shell 50) --- .gitignore | 1 + Makefile | 15 +++++++++ README.md | 32 +++++++++++++++++++ extension.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 6 ++++ 5 files changed, 140 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100644 extension.js create mode 100644 metadata.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c3a81e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.shell-extension.zip diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b24acca --- /dev/null +++ b/Makefile @@ -0,0 +1,15 @@ +UUID = widetile@netz.org +BUNDLE = widetile.shell-extension.zip + +all: $(BUNDLE) + +$(BUNDLE): extension.js metadata.json + zip -j $@ extension.js metadata.json + +install: $(BUNDLE) + gnome-extensions install --force $(BUNDLE) + +clean: + rm -f $(BUNDLE) + +.PHONY: all install clean diff --git a/README.md b/README.md new file mode 100644 index 0000000..bddc11d --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +# widetile + +GNOME Shell extension: `Super+Left` / `Super+Right` tile windows wider than +half the screen. The tile reaches to the left edge of the conky panel +(detected live per keypress, falling back to 2/3 of the work area when conky +is not running); the height extends to the bottom monitor edge, even when the +work area is a few pixels short. Pressing the same arrow again restores the +pre-tile geometry. Maximized windows are untiled first. + +Requires GNOME Shell 50. + +## Install + +From this checkout: + + make install + +then log out and back in (GNOME on Wayland does not reload extension code +mid-session) and enable it: + + gnome-extensions enable widetile@netz.org + +Manual installation: copy `extension.js` and `metadata.json` to +`~/.local/share/gnome-shell/extensions/widetile@netz.org/`, add the uuid to +`org.gnome.shell enabled-extensions`, and relogin. + +## Tuning + +- `TILE_FRACTION` in `extension.js` — fallback tile width if conky is absent +- `MIN_FRACTION` — sanity bound for the conky-aligned width +- The conky window is found by `WM_CLASS` `conky` on the focused window's + monitor; its left frame edge is the tile boundary diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..a64790e --- /dev/null +++ b/extension.js @@ -0,0 +1,86 @@ +import Meta from 'gi://Meta'; +import Shell from 'gi://Shell'; + +import {Extension} from 'resource:///org/gnome/shell/extensions/extension.js'; +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +// fallback width when the conky window is not found +const TILE_FRACTION = 2 / 3; +// ignore the conky window as alignment target if the tile would get narrower +const MIN_FRACTION = 0.5; + +export default class WideTileExtension extends Extension { + enable() { + this._handlers = new Map(); + for (const [binding, dir] of [['toggle-tiled-left', -1], + ['toggle-tiled-right', 1]]) { + const handler = () => this._tileSide(dir); + Main.wm.setCustomKeybindingHandler(binding, + Shell.ActionMode.NORMAL, handler); + this._handlers.set(binding, handler); + } + this._prevRects = new WeakMap(); + } + + disable() { + for (const [binding] of this._handlers) + Main.wm.setCustomKeybindingHandler(binding, + Shell.ActionMode.NORMAL, null); + this._handlers = null; + this._prevRects = null; + } + + _tileSide(dir) { + const win = global.display.focus_window; + if (!win || !win.allows_move() || !win.allows_resize()) + return; + + const wa = win.get_work_area_current_monitor(); + const mon = global.display.get_monitor_geometry(win.get_monitor()); + + // target width: up to the left edge of the conky window on this + // monitor, falling back to a fraction of the work area + let width = Math.floor(wa.width * TILE_FRACTION); + const monIndex = win.get_monitor(); + for (const actor of global.get_window_actors()) { + const mw = actor.meta_window; + if (mw.get_wm_class() === 'conky' && + mw.get_monitor() === monIndex) { + const w = mw.get_frame_rect().x - wa.x; + if (w >= wa.width * MIN_FRACTION) + width = w; + break; + } + } + + // reach the monitor's bottom edge even if the work area is a few + // pixels short + const height = mon.y + mon.height - wa.y; + + const target = { + x: dir < 0 ? wa.x : wa.x + wa.width - width, + y: wa.y, + width, + height, + }; + + // toggle: second press restores the pre-tile geometry + const frame = win.get_frame_rect(); + if (frame.x === target.x && frame.y === target.y && + frame.width === target.width && frame.height === target.height) { + const prev = this._prevRects.get(win); + if (prev) + win.move_resize_frame(false, prev.x, prev.y, + prev.width, prev.height); + this._prevRects.delete(win); + return; + } + this._prevRects.set(win, frame); + + if (win.maximized_horizontally || win.maximized_vertically) + win.unmaximize(Meta.MaximizeFlags.HORIZONTAL | + Meta.MaximizeFlags.VERTICAL); + win.move_resize_frame(false, target.x, target.y, + target.width, target.height); + } +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..bb1385a --- /dev/null +++ b/metadata.json @@ -0,0 +1,6 @@ +{ + "uuid": "widetile@netz.org", + "name": "Wide Tiling", + "description": "Super+Left/Right tile windows to a configurable width (default 2/3 of the work area) instead of half.", + "shell-version": ["50"] +}