initial import: wide tiling extension (gnome shell 50)
This commit is contained in:
commit
3def53e0d8
5 files changed
+140
No files matched your search
@@ -0,0 +1 @@
|
||||
*.shell-extension.zip
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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"]
|
||||
}
|
||||
Reference in new issue
Block a user