gui preferences: adw prefs dialog with tiling mode (conky-align / fixed fraction) and fraction spinrow, backed by gsettings schema

This commit is contained in:
Bastian Mäuser committed 2026-11-08 23:42:07 +01:00
1 parent 3def53e0d8
commit a8a4c20f5e
7 files changed
+98 -21

No files matched your search

+3 -2
View File
@@ -3,8 +3,9 @@ BUNDLE = widetile.shell-extension.zip
all: $(BUNDLE)
$(BUNDLE): extension.js metadata.json
zip -j $@ extension.js metadata.json
$(BUNDLE): extension.js metadata.json prefs.js schemas/org.gnome.shell.extensions.widetile.gschema.xml
glib-compile-schemas schemas
zip $@ extension.js metadata.json prefs.js schemas/gschemas.compiled schemas/org.gnome.shell.extensions.widetile.gschema.xml
install: $(BUNDLE)
gnome-extensions install --force $(BUNDLE)
+12 -4
View File
@@ -26,7 +26,15 @@ Manual installation: copy `extension.js` and `metadata.json` to
## 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
Open the settings GUI from the Extensions app (gear icon next to
"Wide Tiling"):
- **Mode** — *Align with conky window* (tile reaches the conky panel's left
edge) or *Fixed fraction of work area*
- **Fraction** — work-area width fraction, used in fraction mode and as
fallback when conky is not running
Under the hood these live in `org.gnome.shell.extensions.widetile`
(`gsettings` works too). The conky window is found by `WM_CLASS` `conky` on
the focused window's monitor; `MIN_FRACTION` in `extension.js` bounds the
conky-aligned width.
+16 -14
View File
@@ -4,13 +4,12 @@ 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._settings = this.getSettings();
this._handlers = new Map();
for (const [binding, dir] of [['toggle-tiled-left', -1],
['toggle-tiled-right', 1]]) {
@@ -28,6 +27,7 @@ export default class WideTileExtension extends Extension {
Shell.ActionMode.NORMAL, null);
this._handlers = null;
this._prevRects = null;
this._settings = null;
}
_tileSide(dir) {
@@ -38,18 +38,20 @@ export default class WideTileExtension extends Extension {
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;
// target width: conky-aligned or a fraction of the work area
const fraction = this._settings.get_double('fraction');
let width = Math.floor(wa.width * fraction);
if (this._settings.get_string('mode') === 'conky') {
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;
}
}
}
+2 -1
View File
@@ -2,5 +2,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"]
"shell-version": ["50"],
"settings-schema": "org.gnome.shell.extensions.widetile"
}
+50
View File
@@ -0,0 +1,50 @@
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences, gettext as _} from
'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
export default class WideTilePreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
const settings = this.getSettings();
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup({
title: _('Tile width'),
description: _('Width used by Super+Left / Super+Right'),
});
const modeRow = new Adw.ComboRow({
title: _('Mode'),
model: Gtk.StringList.new([
_('Align with conky window'),
_('Fixed fraction of work area'),
]),
});
modeRow.selected = settings.get_string('mode') === 'fraction' ? 1 : 0;
modeRow.connect('notify::selected', () => {
settings.set_string('mode',
modeRow.selected === 1 ? 'fraction' : 'conky');
});
group.add(modeRow);
const fracRow = new Adw.SpinRow({
title: _('Fraction of work area'),
subtitle: _('Used in "fraction" mode and as fallback when conky is not running'),
adjustment: new Gtk.Adjustment({
lower: 0.3,
upper: 1.0,
step_increment: 0.05,
page_increment: 0.1,
value: settings.get_double('fraction'),
}),
digits: 2,
});
settings.bind('fraction', fracRow, 'value', Gio.SettingsBindFlags.DEFAULT);
group.add(fracRow);
page.add(group);
window.add(page);
}
}
Binary file not shown.
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.gnome.shell.extensions.widetile" path="/org/gnome/shell/extensions/widetile/">
<key name="mode" type="s">
<default>'conky'</default>
<summary>Tiling width mode</summary>
<description>"conky" aligns the tile with the left edge of the conky window, "fraction" uses a fixed fraction of the work area width.</description>
</key>
<key name="fraction" type="d">
<default>0.66</default>
<summary>Tile width fraction</summary>
<description>Fraction of the work area width used in "fraction" mode and as fallback when conky is not running.</description>
</key>
</schema>
</schemalist>