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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.3.1

- Resume videos and restart HTML wallpapers after focus or visibility interruptions without changing the selected wallpaper. HTML simulation state resets on recovery; sandbox restrictions stay unchanged.
- Fix a catalog refresh-completion race and simplify thumbnail ownership, header alignment, gallery controls and styles.
- Consolidate overlapping tests and verify folder deletion/recreation under Desktop's Node runtime, including direct folders, aliases and atomic replacements.

## 0.3.0

- Add muted, looping MP4 and WebM wallpapers, animated GIF and APNG uploads, and self-contained HTML wallpapers.
Expand Down
53 changes: 18 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,41 @@
# OpenCode Backdrop

<p>Use your own wallpapers in OpenCode Desktop. Supports OpenCode 2.2.x from 2.2.6, 2.3.x from 2.3.2, and 2.4.x from 2.4.3 through the GUI plugin API.</p>
<img width="3020" height="1910" alt="image" src="https://github.com/user-attachments/assets/8d1626f2-7048-496c-8aa9-7745f19e1531" />
<p>Use your own wallpapers in OpenCode Desktop.</p>

<img alt="Wallpaper preview" src="https://github.com/user-attachments/assets/8d1626f2-7048-496c-8aa9-7745f19e1531" />

https://github.com/user-attachments/assets/72617017-5f4d-4153-94dd-635d6eaea54d

## Install

```sh
opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.0'
opencode plugin add 'github:viralcodex/opencode-backdrop#v0.3.1'
```

This installs the plugin globally. Alternatively, add it to your global `opencode.json` or `opencode.jsonc`, keeping any existing plugins. Do not add it to `cli.json`.

```jsonc
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["github:viralcodex/opencode-backdrop#v0.3.0"],
"plugins": ["github:viralcodex/opencode-backdrop#v0.3.1"],
}
```

## Use
Images and HTML (WebGL self-contained animated wallpapers) must be non-empty and no larger than 8 MiB and videos can be up to 256 MiB.

1. Open **Settings > Wallpapers**.
2. Choose **Change folder** to use a local folder, or **+** to upload an image.
3. Select a wallpaper and adjust tint, brightness and fit.

Wallpaper starts off with an empty gallery. Wallpapers and preferences stay local and are not sent to models. Images and HTML must be non-empty and no larger than 8 MiB; videos can be up to 256 MiB.

- Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders. Changes appear automatically.
- Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
- Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support. Animated images keep their original animation.
- HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. CSP blocks external scripts, styles, assets, and fetch requests. Embed everything in the HTML and use files from sources you trust. This is not a network firewall; a script can still navigate its own frame to another URL.
- Filter the gallery by **All wallpapers**, **Static**, or **Live**. Live tiles have a small play icon beside their name. Hover or keyboard-focus a live tile to preview it without changing your selected wallpaper.
- Videos and animated images show static thumbnail frames until previewed. For an HTML poster, put `Name.poster.png`, `.jpg`, `.jpeg`, or `.webp` beside `Name.html`. Poster files stay out of the gallery. Without a poster, HTML tiles show a live-wallpaper label until previewed.
- The gallery shows at most two rows, including the **+** tile. Use **Show more** to see all wallpapers, or **Show less** to collapse it.
- More tint improves text contrast. **Fill background** crops the image; **Show whole image** keeps it fully visible.
- Use `/wallpaper` in chat to switch images or turn wallpaper off. Escape cancels the picker.
- Turn **Show wallpaper** off to restore the app's backgrounds without losing your choices.
- Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter. Choose **None** or **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds. Slideshow needs at least two wallpapers. Fades apply between images and respect reduced-motion settings; video and HTML switch instantly. Live playback itself does not pause under reduced motion.

To remove an upload, hover or focus its tile and click **X**. Remove folder wallpapers by moving or deleting their source files.

## Koi Pond example

[Koi Pond](https://github.com/Himanshu-Sangshetti/koipond) is a live WebGL wallpaper, not a video. Download `koipond-linux.tar.gz` from its [wallpaper release](https://github.com/Himanshu-Sangshetti/koipond/releases/tag/wallpaper-v0.2.0), extract `web/index.html`, and save it in your wallpaper folder as `Koi Pond.html`. No installer is needed. Select it in **Settings > Wallpapers**.

Save the repo's [poster image](https://raw.githubusercontent.com/Himanshu-Sangshetti/koipond/main/.github/assets/hero.webp) beside it as `Koi Pond.poster.webp` to show the pond before hovering.

Other HTML animations work the same way when bundled into one file. The wallpaper cannot intercept clicks or read the OpenCode interface. HTML fills the panel; the fit setting applies to images and videos.
## Features
1. Use `/wallpaper` in chat to switch images or turn wallpaper off.
2. Folders support PNG, JPEG, WebP, SVG, GIF, APNG, MP4, WebM, and self-contained HTML, including subfolders.
3. Uploads support PNG, JPEG, WebP, GIF and APNG. Add video and HTML through the wallpaper folder.
4. Videos play muted and loop continuously. MP4 with H.264 is recommended; other codecs depend on Desktop support.
5. HTML wallpapers run in a sandbox without access to the OpenCode interface or local storage. <i>(CSP blocks external scripts, styles, assets, and fetch requests. Add only from trusted sources.)</i>
6. Turn **Wallpaper slideshow** on to cycle through all wallpapers in gallery order, regardless of the gallery filter.
7. Choose **Fade** and set **Display time** in seconds, from 5 to 86400. The default is 60 seconds.

## Optional folder configuration

Expand All @@ -57,7 +46,7 @@ You can set an initial folder with an absolute path instead of choosing one in S
"$schema": "https://opencode.ai/config.json",
"plugins": [
{
"package": "github:viralcodex/opencode-backdrop#v0.3.0",
"package": "github:viralcodex/opencode-backdrop#v0.3.1",
"options": { "folder": "/absolute/path/to/wallpapers" },
},
],
Expand All @@ -68,15 +57,9 @@ The folder chosen in Settings takes precedence over this option.

## Development

Use Bun 1.4.4, as pinned in `package.json`, so the generated bundle matches CI.
Use Bun 1.4.4, as pinned in `package.json`.

```sh
bun run check
bun run test:storage /path/to/opencode
```

`check` rebuilds the GUI bundle and runs unit, native Node filesystem-watcher, headless Chrome, and package checks. Set `CHROME_BIN` to a Chrome or Chromium executable if it is installed elsewhere. The PR workflow runs these checks and rejects a stale committed bundle. `test:storage` checks migration against an OpenCode checkout's actual persistence decoder. Pass the checkout path or set `OPENCODE_CHECKOUT`.

## Release

See [CHANGELOG.md](CHANGELOG.md) for the 0.3.0 release notes. Before tagging `v0.3.0`, run `bun install --frozen-lockfile --ignore-scripts` and `bun run check`, then commit the rebuilt `dist/gui-experimental.cjs` with the source changes. Run the host-storage check against a supported OpenCode checkout and smoke-test the installed package in Desktop. Keep the local `showcase/` captures and artwork out of this PR.
44 changes: 19 additions & 25 deletions dist/gui-experimental.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://json.schemastore.org/package.json",
"name": "opencode-backdrop",
"version": "0.3.0",
"version": "0.3.1",
"description": "Use your own local wallpapers in OpenCode Desktop",
"type": "module",
"license": "MIT",
Expand Down
48 changes: 26 additions & 22 deletions script/check-catalog-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ assert(bundle.success, "Catalog test bundle failed to build")
const output = bundle.outputs[0]
assert(output, "Catalog test bundle is missing")
const scenario = `
{
for (const useAlias of [false, true]) {
const assert = (await import('node:assert/strict')).default
const fs = await import('node:fs/promises')
const path = (await import('node:path')).default
Expand All @@ -24,48 +24,52 @@ const scenario = `
const aliases = path.join(directory, 'aliases')
const alias = path.join(aliases, 'alias')
const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'
const pending = new Set()
const catalog = createCatalog(alias, () => { for (const notify of [...pending]) notify() })
let notify = () => {}
const catalog = createCatalog(useAlias ? alias : target, () => notify())
const waitFor = (predicate) => new Promise((resolve, reject) => {
if (predicate()) { resolve(); return }
const notify = () => {
notify = () => {
if (!predicate()) return
clearTimeout(timer)
pending.delete(notify)
resolve()
}
const timer = setTimeout(() => {
pending.delete(notify)
reject(new Error('Filesystem event did not update the catalog: ' + JSON.stringify(catalog.state())))
}, 5000)
pending.add(notify)
notify()
})
try {
await fs.mkdir(target)
await fs.mkdir(aliases)
await fs.symlink(target, alias, ${JSON.stringify(process.platform === "win32" ? "junction" : "dir")})
if (useAlias) {
await fs.mkdir(aliases)
await fs.symlink(target, alias, ${JSON.stringify(process.platform === "win32" ? "junction" : "dir")})
}
await fs.writeFile(path.join(target, 'before.svg'), svg)
assert.equal(await catalog.refresh(), true)
assert.equal(catalog.state().images.length, 1)
const removed = waitFor(() => catalog.state().images.length === 0 && catalog.state().error.includes('ENOENT'))
await fs.rm(target, { recursive: true })
await removed
const restored = waitFor(() => !catalog.state().error && catalog.state().images.some(image => image.title === 'restored'))
await fs.mkdir(target)
await fs.writeFile(path.join(target, 'restored.svg'), svg)
await restored
assert.ok((await catalog.read(catalog.state().images[0])).includes(Buffer.from(svg).toString('base64')))
const changed = waitFor(() => catalog.state().images.length === 2)
await fs.writeFile(path.join(target, 'another.svg'), svg)
await changed
for (const atomic of [false, true]) {
const removed = waitFor(() => catalog.state().images.length === 0 && catalog.state().error.includes('ENOENT'))
await fs.rm(target, { recursive: true })
await removed
const restored = waitFor(() => !catalog.state().error && catalog.state().images.some(image => image.title === 'restored'))
const replacement = atomic ? path.join(directory, 'replacement') : target
await fs.mkdir(replacement)
await fs.writeFile(path.join(replacement, 'restored.svg'), svg)
if (atomic) await fs.rename(replacement, target)
await restored
assert.ok((await catalog.read(catalog.state().images[0])).includes(Buffer.from(svg).toString('base64')))
const changed = waitFor(() => catalog.state().images.length === 2)
await fs.writeFile(path.join(target, 'another.svg'), svg)
await changed
assert.deepEqual(catalog.state().images.map(image => image.title), ['another', 'restored'])
}
catalog.dispose()
assert.equal(await catalog.refresh(), false)
console.log('Node catalog passed: symlink target removal, recreation, subsequent changes, reads, and disposal.')
} finally {
catalog.dispose()
await fs.rm(directory, { recursive: true, force: true })
}
}
console.log('Node catalog passed: direct folders and symlink targets, deletion, normal/atomic recreation, subsequent changes, reads, and disposal.')
`
const node = Bun.spawn([process.env.NODE_BIN ?? "node", "--input-type=module", "--eval", `${await output.text()}\n${scenario}`],
{ cwd: root, stdout: "pipe", stderr: "pipe" },
Expand Down
Loading