Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: ci

on:
push:
branches: [main]
pull_request:

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Syntax
run: |
cp "gnome-shell/smbact@giglabo.com/extension.js" "$RUNNER_TEMP/extension.mjs"
node --check "$RUNNER_TEMP/extension.mjs"
python3 -m py_compile scripts/call.py
python3 -c "import json; json.load(open('gnome-shell/smbact@giglabo.com/metadata.json'))"
- name: Pack
run: scripts/pack.sh
- uses: actions/upload-artifact@v4
with:
name: smbact-shell-gnome
path: dist/*.zip
34 changes: 34 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: release

# A tag vX.Y.Z publishes the extension zip and its sha256 as a GitHub release. SMBAct pins a tag and checks the
# sha256 of the zip it downloads. The tag must match "version-name" in metadata.json.
on:
push:
tags: ['v*']

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Tag matches metadata.json
run: |
want="v$(python3 -c "import json; print(json.load(open('gnome-shell/smbact@giglabo.com/metadata.json'))['version-name'])")"
if [ "$want" != "$GITHUB_REF_NAME" ]; then
echo "tag $GITHUB_REF_NAME does not match metadata.json version-name ($want)" >&2
exit 1
fi
- name: Pack
run: |
scripts/pack.sh
(cd dist && sha256sum ./*.zip > SHA256SUMS && cat SHA256SUMS)
- name: Release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "$GITHUB_REF_NAME" dist/*.zip dist/SHA256SUMS \
--title "smbact-shell $GITHUB_REF_NAME" \
--notes "GNOME Shell extension smbact@giglabo.com, protocol com.giglabo.SMBAct.Shell1 API 1. See PROTOCOL.md."
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
131 changes: 131 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# Protocol: `com.giglabo.SMBAct.Shell1`, API 1

How SMBAct talks to its shell plugins. The GNOME Shell extension implements it today; a KWin script will
implement the same operations. SMBAct (a separate program) is the only intended client.

## D-Bus

| | |
|---|---|
| Bus | session |
| Name (owned by the plugin) | `com.giglabo.SMBAct.Shell` |
| Object | `/com/giglabo/SMBAct/Shell1` |
| Interface | `com.giglabo.SMBAct.Shell1` |
| Method | `Call(in s request, out s reply)` |
| Signal | `Event(s event)` |

Requests and replies are JSON strings, so a client needs nothing beyond string calls.

**Who may call.** Only the current owner of the well-known name `com.giglabo.SMBAct` (SMBAct requests it with
`DO_NOT_QUEUE`). Every other caller gets the D-Bus error `org.freedesktop.DBus.Error.AccessDenied`. This keeps
unrelated programs out while SMBAct runs. It does not stop a program of the same user that takes the name while SMBAct
is not running; GNOME's own allow-lists have the same limit.

## Requests and replies

```json
{ "op": "moveResize", "id": 2653220665, "x": 90, "y": 80, "width": 640, "height": 420 }
```

```json
{ "ok": true, "result": { "window": { ... } } }
{ "ok": false, "error": { "code": "NO_WINDOW", "message": "no window 2653220665" } }
```

Error codes: `BAD_REQUEST` (not JSON, missing or wrong arguments), `UNKNOWN_OP`, `NO_WINDOW`, `FAILED` (the shell
threw; `message` has its text).

Unknown fields in a request are ignored; new optional fields and new operations do not change the API number. A
change that breaks an existing operation does, and `hello` reports which API the plugin speaks.

## Coordinates

Logical pixels of the compositor's layout (Mutter's stage), the same space as Electron's DIPs for windows under
XWayland. Rectangles are `{ "x", "y", "width", "height" }`.

## Window

```json
{
"id": 2653220665,
"title": "Licenses — Mozilla Firefox",
"wmClass": "firefox",
"wmClassInstance": "Navigator",
"appId": "org.mozilla.firefox",
"sandboxedAppId": null,
"app": "firefox.desktop",
"pid": 3068,
"client": "wayland",
"x11Window": null,
"type": "normal",
"frame": { "x": 67, "y": 32, "width": 1213, "height": 768 },
"clientRect": { "x": 67, "y": 69, "width": 1213, "height": 731 },
"focus": true,
"minimized": false,
"maximized": true,
"maximizedHorizontally": true,
"maximizedVertically": true,
"fullscreen": false,
"above": false,
"skipTaskbar": false,
"monitor": 0,
"workspace": 0,
"onAllWorkspaces": false,
"stack": 4,
"icon": "/usr/share/icons/hicolor/48x48/apps/firefox.png"
}
```

- `id`: the compositor's window id, unique in the session (fits in a JSON number). Requests also accept the X11 id
of an XWayland window as `id`.
- `client`: `wayland` or `x11`; `x11Window`: the X11 window id of an XWayland window, else `null`.
- `type`: `normal`, `dialog`, `modal-dialog`, `utility`, `splashscreen`, `menu`, `toolbar`, `desktop`, `dock`, or
`other`. The plugin lists every managed window; the client picks what it shows.
- `frame`: the visible window including server-side decorations; `clientRect`: the client area (larger than `frame`
when the window draws its own shadow).
- `stack`: position in the stacking order, 0 = bottom.
- `icon`: a file path from the icon theme, PNG when the theme has one (only when asked for, see `listWindows`), or
`null`. `iconPng` turns any icon file (SVG too) into PNG bytes.

## Operations (API 1)

| op | arguments | result |
|---|---|---|
| `hello` | | `{ api, plugin, version, shell, session, ops }` |
| `listWindows` | `icons?` (bool), `iconSize?` (px, default 48) | `{ windows: Window[] }` |
| `getWindow` | `id`, `icons?`, `iconSize?` | `{ window }` |
| `activeWindow` | `icons?`, `iconSize?` | `{ window }` (`null` when nothing has focus) |
| `moveResize` | `id`, `x`, `y`, `width`, `height`, `space?` (`frame` default, or `client`) | `{ window }` |
| `activate` | `id`, `time?` | `{ window }` |
| `raise` | `id` | `{ window }` |
| `setState` | `id`, `state`, `on` | `{ window }` |
| `close` | `id`, `force?` | `{ closed: true }` |
| `showDesktop` | `show` | `{ windows }` (how many were minimized or restored) |
| `displays` | | `{ monitors: [{ index, geometry, workArea, scale, primary }] }` |
| `iconPng` | `path` (an `icon` path), `size?` (px, default 48) | `{ png, width, height }` (`png`: base64 PNG bytes) |
| `pointer` | | `{ x, y }` |

- `setState` states: `minimized`, `maximized`, `maximizedHorizontally`, `maximizedVertically`, `fullscreen`,
`above`.
- `moveResize` takes the frame rect, or with `space: "client"` the client rect (the compositor converts it with the
window's own decorations and shadow).
- `moveResize` leaves maximized and fullscreen first, then moves and resizes in two steps, so windows with resize
increments (terminals) keep the requested position.
- Wayland windows apply a new geometry or state asynchronously (the client acknowledges it about a frame later), so
the `window` in the reply of `moveResize` and `setState` may still show the previous geometry; read it again
with `getWindow` (or wait for `windowsChanged`) when the new one matters.
- `activate` uses the server's current time unless `time` is given (an input event's timestamp).
- `close` asks the window to close; `force` kills its client.
- `showDesktop` with `show: true` minimizes the visible windows of the active workspace and remembers them; `false`
restores those.

## Events

`Event` carries `{ "type": ..., ... }`:

- `windowsChanged`: a window appeared, went away, moved, resized or changed state (coalesced, at most every 100 ms).
- `focusChanged` with `id` (or `null`).

## History

- API 1 (2026-11): window list, geometry, activation, states, close, displays, pointer, events.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
# smbact-shell
SMBAct shell plugins: a GNOME Shell extension (and later a KWin script) that lets SMBAct see and arrange every window on Wayland. GPL-2.0-or-later.

Shell plugins for SMBAct, the window management app: a GNOME Shell extension now,
a KWin script later. On a Wayland session only the compositor knows every window, so SMBAct asks it through these
plugins: the window list, moving and resizing, activation, window states, displays.

The plugins are thin executors. They hold no product logic and do nothing on their own; SMBAct installs them and
calls them over D-Bus. The protocol is in [PROTOCOL.md](PROTOCOL.md).

## GNOME Shell extension

`gnome-shell/smbact@giglabo.com/` — GNOME Shell 46 to 51.

SMBAct installs it for you. By hand:

```bash
scripts/pack.sh
gnome-extensions install --force dist/smbact@giglabo.com.shell-extension.zip
gnome-extensions enable smbact@giglabo.com
```

On Wayland a newly installed or updated extension starts after you log out and back in.

Only SMBAct may call it: the extension answers the current owner of the D-Bus name `com.giglabo.SMBAct` and refuses
everyone else.

## Releases

A tag `vX.Y.Z` (equal to `version-name` in `metadata.json`) makes GitHub Actions publish
`smbact@giglabo.com.shell-extension.zip` and `SHA256SUMS` as a release. SMBAct pins a tag and checks the sha256.
Every push to `main` and every pull request runs the checks and packs the zip (`.github/workflows/`).

## License

GPL-2.0-or-later (see [LICENSE](LICENSE)). SMBAct itself is a separate program that talks to these plugins over
D-Bus.
Loading
Loading