Compare commits
33 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1294ba741a | |||
| 6ea44ac60c | |||
| 56399996f5 | |||
| 2b1f67b1ea | |||
| 71f942ff36 | |||
| 7968270aa4 | |||
| b406970b93 | |||
| d75ba7fff6 | |||
| 98307b8a2e | |||
| 6c4fa04221 | |||
| b6fe86f418 | |||
| 3d41f39ad9 | |||
| c9f3b6b1ad | |||
| bb792cee95 | |||
| 376c6442f9 | |||
| 7b3a25eaaf | |||
| ec8d208f35 | |||
| 6796a44802 | |||
| 306cedfd68 | |||
| 189a52798b | |||
| 7abd247247 | |||
| 452fb171a6 | |||
| 0e9c83f2d8 | |||
| 72a2d073e2 | |||
| 28b68b4dc4 | |||
| 8943136384 | |||
| 43a68e7970 | |||
|
|
3fff367364 | ||
| 40722526d4 | |||
| 77f26422bf | |||
| 9f60f42071 | |||
| 885e64ff85 | |||
| a055dc5f2b |
6
.github/workflows/ci.yml
vendored
|
|
@ -15,7 +15,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Install system dependencies
|
- name: Install system dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -28,7 +28,7 @@ jobs:
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
|
|
||||||
- name: Cache cargo registry
|
- name: Cache cargo registry
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v6
|
||||||
with:
|
with:
|
||||||
path: |
|
path: |
|
||||||
~/.cargo/registry
|
~/.cargo/registry
|
||||||
|
|
@ -54,7 +54,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v7
|
||||||
|
|
||||||
- name: Install glib-compile-schemas
|
- name: Install glib-compile-schemas
|
||||||
run: sudo apt-get update -q && sudo apt-get install -y libglib2.0-bin
|
run: sudo apt-get update -q && sudo apt-get install -y libglib2.0-bin
|
||||||
|
|
|
||||||
40
.github/workflows/eslint.yml
vendored
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
name: ESLint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ 'main' ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ 'main' ]
|
||||||
|
schedule:
|
||||||
|
- cron: '33 14 * * 5'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
eslint:
|
||||||
|
name: Run eslint scanning
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
# Required for private repositories by github/codeql-action/upload-sarif
|
||||||
|
actions: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v7
|
||||||
|
|
||||||
|
- name: Install
|
||||||
|
run: |
|
||||||
|
npm install eslint@^10.0.0 @eslint/js@^10.0.0
|
||||||
|
npm install @microsoft/eslint-formatter-sarif@2.1.7
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: >
|
||||||
|
npx eslint .
|
||||||
|
--format @microsoft/eslint-formatter-sarif
|
||||||
|
--output-file eslint-results.sarif
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Report
|
||||||
|
uses: github/codeql-action/upload-sarif@v4
|
||||||
|
with:
|
||||||
|
sarif_file: eslint-results.sarif
|
||||||
|
wait-for-processing: true
|
||||||
8
.gitignore
vendored
|
|
@ -4,12 +4,18 @@ strata-daemon/target/
|
||||||
# Bundled binary (no longer shipped - daemon must be installed separately)
|
# Bundled binary (no longer shipped - daemon must be installed separately)
|
||||||
strata@edu4rdshl.dev/bin/
|
strata@edu4rdshl.dev/bin/
|
||||||
|
|
||||||
# Screenshots / scratch images
|
# Screenshots / scratch images (project assets under assets/ are kept)
|
||||||
*.png
|
*.png
|
||||||
|
!assets/*.png
|
||||||
|
|
||||||
# External reference code (not part of this project)
|
# External reference code (not part of this project)
|
||||||
external_sources/
|
external_sources/
|
||||||
|
|
||||||
|
# Node / lint tooling
|
||||||
|
node_modules/
|
||||||
|
package-lock.json
|
||||||
|
*.shell-extension.zip
|
||||||
|
|
||||||
# Editor / OS
|
# Editor / OS
|
||||||
.vscode/
|
.vscode/
|
||||||
.idea/
|
.idea/
|
||||||
|
|
|
||||||
60
AGENTS.md
|
|
@ -13,6 +13,13 @@ contrib/systemd/ systemd user service unit for distro packaging
|
||||||
ARCHITECTURE.md In-depth design document
|
ARCHITECTURE.md In-depth design document
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Upstream guidelines
|
||||||
|
|
||||||
|
- EGO review: https://gjs.guide/extensions/review-guidelines/review-guidelines.html
|
||||||
|
- GJS D-Bus: https://gjs.guide/guides/gio/dbus.html
|
||||||
|
|
||||||
|
The conventions in this file follow both.
|
||||||
|
|
||||||
## Core principle
|
## Core principle
|
||||||
|
|
||||||
"JS draws, Rust thinks." The extension must never block the GNOME Shell
|
"JS draws, Rust thinks." The extension must never block the GNOME Shell
|
||||||
|
|
@ -101,10 +108,61 @@ CSS files must be added to the `pack` target as `--extra-source` (only
|
||||||
|
|
||||||
- No `--` em-dashes, no emojis in code comments or docs.
|
- No `--` em-dashes, no emojis in code comments or docs.
|
||||||
- Rust: use `tracing::info!`, `tracing::warn!`, `tracing::error!` (qualified path, not bare imports). No `println!` in daemon code.
|
- Rust: use `tracing::info!`, `tracing::warn!`, `tracing::error!` (qualified path, not bare imports). No `println!` in daemon code.
|
||||||
- GJS: `console.log('[Strata] ...')` / `console.error('[Strata] ...')` prefix for all extension logs.
|
- GJS: route all errors through the `logError(label, err)` helper at the top
|
||||||
|
of `extension.js` and `ui/panel.js`. It prepends `[Strata]` and strips the
|
||||||
|
`GDBus.Error:` prefix from D-Bus errors. Do not call `console.error`
|
||||||
|
directly. Do not use `console.log` for normal flow events; only errors
|
||||||
|
should appear in the journal.
|
||||||
- Size limits travel as bytes over D-Bus. MB conversion happens extension-side.
|
- Size limits travel as bytes over D-Bus. MB conversion happens extension-side.
|
||||||
- `Ordering::Relaxed` is intentional on `Arc<AtomicUsize>` limits (advisory, not critical path).
|
- `Ordering::Relaxed` is intentional on `Arc<AtomicUsize>` limits (advisory, not critical path).
|
||||||
- Never execute clipboard content. Writes go through `wl-clipboard-rs` (`copy_multi`) in the daemon, never via shell subprocess or `eval`.
|
- Never execute clipboard content. Writes go through `wl-clipboard-rs` (`copy_multi`) in the daemon, never via shell subprocess or `eval`.
|
||||||
- Excluded apps list is checked before storing any clipboard item.
|
- Excluded apps list is checked before storing any clipboard item.
|
||||||
- Ingest paths are mutually exclusive by environment: on GNOME the monitor cannot bind (Mutter exposes neither data-control protocol) so ingest is GJS `SubmitItem`; on wlroots the built-in monitor is the path.
|
- Ingest paths are mutually exclusive by environment: on GNOME the monitor cannot bind (Mutter exposes neither data-control protocol) so ingest is GJS `SubmitItem`; on wlroots the built-in monitor is the path.
|
||||||
- List queries (`get_history_page`, `search_history`) return `content_text` truncated to `PREVIEW_CHARS` via `substr`; full content is served only by `GetItemContent` for paste-back.
|
- List queries (`get_history_page`, `search_history`) return `content_text` truncated to `PREVIEW_CHARS` via `substr`; full content is served only by `GetItemContent` for paste-back.
|
||||||
|
|
||||||
|
## D-Bus client conventions
|
||||||
|
|
||||||
|
- Use the `makeProxyWrapper` proxy from `dbus.js`. Do not construct
|
||||||
|
`Gio.DBusProxy` directly elsewhere.
|
||||||
|
- Method calls: `*Async` for await-style, `*Remote` for fire-and-forget.
|
||||||
|
Never call a synchronous variant.
|
||||||
|
- Signal subscriptions: `this._proxy.connectSignal('Name', handler)` paired
|
||||||
|
with `disconnectSignal(id)` in `_disconnectSignals`. Do not use the
|
||||||
|
low-level `Gio.DBus.session.signal_subscribe`.
|
||||||
|
- Monitor `notify::g-name-owner` on the proxy to react to daemon
|
||||||
|
availability (initial load, config re-push after respawn).
|
||||||
|
|
||||||
|
## Extension lifecycle (disable cleanup)
|
||||||
|
|
||||||
|
Every resource opened while enabled must be released in `disable()` or in a
|
||||||
|
helper called from `disable()`. The EGO static analyzer (shexli) flags
|
||||||
|
implicit cleanup as a warning, so be explicit:
|
||||||
|
|
||||||
|
- Every `obj.connect('signal', ...)` must store its ID; `disable()` must
|
||||||
|
call `obj.disconnect(id)`, even on actors that get `destroy()`ed.
|
||||||
|
- Every `GLib.timeout_add(...)` must store its source ID so it can be
|
||||||
|
removed in `disable()` (or in the fire callback for one-shot sources).
|
||||||
|
- Every `GLib.idle_add(...)` must go through `this._addIdleSource(callback)`,
|
||||||
|
which tracks the source ID in `_idleSources`. `_clearIdleSources()` flushes
|
||||||
|
pending sources in `disable()`.
|
||||||
|
- Every `proxy.connectSignal(...)` must be paired with `disconnectSignal`.
|
||||||
|
|
||||||
|
## EGO submission
|
||||||
|
|
||||||
|
Before submitting to extensions.gnome.org, pack and run the `shexli` static
|
||||||
|
analyzer:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
make pack
|
||||||
|
pip install -U shexli
|
||||||
|
shexli strata@edu4rdshl.dev.shell-extension.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
Address any `warning` or `error` findings. A `manual_review` finding is
|
||||||
|
expected for direct `St.Clipboard` access (Strata is a clipboard manager);
|
||||||
|
declare it in the long description on the EGO upload form so the reviewer
|
||||||
|
doesn't have to guess.
|
||||||
|
|
||||||
|
`shell-version` in `metadata.json` must list only Shell versions the
|
||||||
|
extension has actually been tested on. Aspirational entries are a known
|
||||||
|
rejection cause.
|
||||||
|
|
|
||||||
|
|
@ -295,38 +295,24 @@ image.
|
||||||
|
|
||||||
## Theming
|
## Theming
|
||||||
|
|
||||||
St's CSS engine has no custom properties (`var()`) and no reliable
|
Light and dark are handled by GNOME Shell's built-in per-variant stylesheet
|
||||||
`!important`, so the light theme is not a runtime-generated stylesheet.
|
loading, not by any code in the extension. When it enables an extension the
|
||||||
Instead `stylesheet.css` is the dark theme (default, auto-loaded by GNOME),
|
Shell loads `stylesheet-<variant>.css`, where the variant comes from
|
||||||
and `light.css` carries light overrides with every rule scoped under a
|
`Main.getStyleVariant()` (the shell's own light/dark), and falls back to
|
||||||
`.strata-theme-light` ancestor class -- e.g. dark `.strata-panel { ... }` is
|
`stylesheet.css`; it reloads that sheet when the color scheme changes.
|
||||||
overridden by `.strata-panel.strata-theme-light { ... }`. That scoping makes
|
|
||||||
each light rule strictly more specific than its dark counterpart, so it wins
|
|
||||||
deterministically regardless of stylesheet load order.
|
|
||||||
|
|
||||||
The switch between themes is a single class. `extension.js` loads `light.css`
|
Strata ships two sheets and no `stylesheet.css`:
|
||||||
into the St theme context once at `enable()` (and unloads it on `disable()`),
|
|
||||||
but loading it changes nothing on screen: its rules are present in the engine
|
|
||||||
yet match no actors, because nothing carries `.strata-theme-light` yet. The
|
|
||||||
panel resolves the effective theme from the `theme` setting (`auto` consults
|
|
||||||
`org.gnome.desktop.interface color-scheme`) and adds or removes that one class
|
|
||||||
on its root box. With the class present the more-specific light rules win and
|
|
||||||
the panel is light; with it absent only the base dark rules apply. So
|
|
||||||
switching is one class toggle on an existing subtree -- instant, off the
|
|
||||||
ingest/render hot paths, and needing no reload.
|
|
||||||
|
|
||||||
`light.css` is loaded exactly once and the theme context's `changed` signal is
|
- `stylesheet-dark.css` is the full dark theme (the base).
|
||||||
deliberately not used: `load_stylesheet` itself emits `changed`, so reloading
|
- `stylesheet-light.css` does `@import url("stylesheet-dark.css")` and then
|
||||||
on it feeds back into itself and hits "too much recursion" (it fired on screen
|
overrides the colors for a light panel. Its rules follow the import, so they
|
||||||
unlock, which restyles widgets). The one caveat of loading once is a full
|
win by load order.
|
||||||
GNOME Shell *theme* switch (the User Themes extension swapping the whole Shell
|
|
||||||
theme), which replaces the theme object and drops every dynamically loaded
|
This is the structure the built-in `window-list` extension uses. Because the
|
||||||
sheet, including `light.css`. After that, light mode falls back to the dark
|
variant tracks the *shell* style, the panel matches the shell chrome: a normal
|
||||||
base rules until the extension is re-enabled; dark mode is unaffected because
|
session prefers dark, so the panel is dark, and it turns light only when the
|
||||||
GNOME re-loads `stylesheet.css` itself. This is rare and recoverable, and far
|
shell itself is light (a `prefer-light` color scheme, the Classic session, or
|
||||||
preferable to re-subscribing to `changed`. The ordinary light/dark switch
|
high contrast). There is no theme setting and no manual stylesheet loading.
|
||||||
(including the system Settings light/dark that `auto` follows) is just the
|
|
||||||
class toggle and is unaffected.
|
|
||||||
|
|
||||||
## Wayland clipboard monitor
|
## Wayland clipboard monitor
|
||||||
|
|
||||||
|
|
|
||||||
91
CHANGELOG.md
|
|
@ -6,6 +6,97 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## [0.11.0] - 2026-07-02
|
||||||
|
|
||||||
|
The daemon is unchanged from 0.10.0; all changes are in the GNOME Shell extension.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- Light and dark styling follows the GNOME Shell style variant via
|
||||||
|
`stylesheet-dark.css` and `stylesheet-light.css`, loaded automatically by the
|
||||||
|
Shell, instead of loading `light.css` into the theme context by hand. The
|
||||||
|
manual theme setting and its preferences row are gone; the panel matches the
|
||||||
|
shell.
|
||||||
|
- Signal connections use `connectObject`/`disconnectObject`.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `disable()` stops the daemon synchronously with `SIGTERM` instead of deferring
|
||||||
|
the kill to a timeout.
|
||||||
|
- The daemon-restart timeout is cleared before a new one is scheduled.
|
||||||
|
- Removed the `try`/`catch` around `send_signal`, which does not throw.
|
||||||
|
|
||||||
|
### Performance
|
||||||
|
|
||||||
|
- The thumbnail cache is cleared asynchronously in batches instead of a
|
||||||
|
synchronous enumerate and delete on the compositor thread.
|
||||||
|
- The thumbnail path cache is pruned on delete and clear-all.
|
||||||
|
- Each row computes its type (image, URL, color) once.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## [0.10.0] - 2026-06-25
|
||||||
|
|
||||||
|
The daemon is unchanged from 0.9.0; all changes are in the GNOME Shell extension.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- URL items now show their hostname as a subtitle. The old code used the WHATWG
|
||||||
|
`URL` API, which GJS does not provide, so it always threw and the subtitle
|
||||||
|
never appeared. It now uses `GLib.Uri`.
|
||||||
|
- The packaged extension was missing `dbus.js`. The extension imports it, but
|
||||||
|
`make pack` did not bundle it, so installing from the packaged zip would
|
||||||
|
fail to load. It is now included.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- `ClipboardItem` uses a `constructor()` with an explicit `GTypeName` instead of
|
||||||
|
`_init()`.
|
||||||
|
- The error-logging helper lives in a single `util.js` module shared by the
|
||||||
|
extension, panel, and item widget.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Adopted the GJS ESLint style guide: an `eslint.config.js` flat config, an
|
||||||
|
`npm run lint` script, and a GitHub Actions workflow that lints on push and
|
||||||
|
pull requests. The extension passes with no warnings.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## [0.9.0] - 2026-06-25
|
||||||
|
|
||||||
|
The daemon is unchanged from 0.8.0; all changes are in the GNOME Shell extension.
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- App exclusion is enforced before a copy is sent to the daemon, instead of
|
||||||
|
storing the item and deleting it afterward. Excluded content no longer
|
||||||
|
reaches the database, and the focused app is checked at copy time.
|
||||||
|
- The D-Bus client follows the GJS guide: signals are handled through the proxy
|
||||||
|
(`connectSignal`) and D-Bus errors are stripped of their `GDBus.Error` prefix
|
||||||
|
before logging.
|
||||||
|
- `shell-version` declares GNOME Shell 50 only, the version the extension is
|
||||||
|
tested on. Installs on older releases are no longer offered.
|
||||||
|
- The daemon-missing notification points to the project page for install
|
||||||
|
instructions.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- The initial history load retries on the next daemon connection if the first
|
||||||
|
fetch fails, instead of leaving the panel empty until it is reopened.
|
||||||
|
- The D-Bus proxy callback is ignored when the extension was disabled (or
|
||||||
|
re-enabled) while the proxy was still being created.
|
||||||
|
- `disable()` disconnects the panel indicator signal and drops pending idle
|
||||||
|
callbacks, so nothing runs against a torn-down extension.
|
||||||
|
|
||||||
|
### Internal
|
||||||
|
|
||||||
|
- Extension logging goes through one helper per file. Removed dead fields,
|
||||||
|
stale comments, and leftover narration flagged by the EGO review guidelines
|
||||||
|
and the shexli static analyzer.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## [0.8.0] - 2026-05-26
|
## [0.8.0] - 2026-05-26
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
|
||||||
674
LICENSE
Normal file
|
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
3
Makefile
|
|
@ -37,7 +37,8 @@ install: schemas
|
||||||
pack: schemas
|
pack: schemas
|
||||||
gnome-extensions pack $(EXTENSION_UUID) \
|
gnome-extensions pack $(EXTENSION_UUID) \
|
||||||
--extra-source=ui \
|
--extra-source=ui \
|
||||||
--extra-source=light.css \
|
--extra-source=dbus.js \
|
||||||
|
--extra-source=util.js \
|
||||||
--force
|
--force
|
||||||
@echo "Packed: $(EXTENSION_UUID).shell-extension.zip"
|
@echo "Packed: $(EXTENSION_UUID).shell-extension.zip"
|
||||||
|
|
||||||
|
|
|
||||||
122
README.md
|
|
@ -1,3 +1,7 @@
|
||||||
|
<p align="center">
|
||||||
|
<img src="assets/icon.svg" alt="Strata logo" width="96" height="96">
|
||||||
|
</p>
|
||||||
|
|
||||||
# Strata
|
# Strata
|
||||||
|
|
||||||
A fast, stutter-free clipboard manager for GNOME Shell.
|
A fast, stutter-free clipboard manager for GNOME Shell.
|
||||||
|
|
@ -6,6 +10,83 @@ All heavy work (hashing, decoding, storage, search, thumbnails) lives in a Rust
|
||||||
daemon. The GNOME Shell extension only renders UI and forwards events over
|
daemon. The GNOME Shell extension only renders UI and forwards events over
|
||||||
D-Bus, so the compositor is never blocked, even with thousands of items.
|
D-Bus, so the compositor is never blocked, even with thousands of items.
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://extensions.gnome.org/extension/10291/strata/">
|
||||||
|
<img src="assets/ego.svg" width="200" alt="Download from extensions.gnome.org">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
> **Requires a companion daemon.** Installing from GNOME Extensions is only half
|
||||||
|
> the setup. See [Installing the daemon](#installing-the-daemon).
|
||||||
|
|
||||||
|
The motivation behind this is explained in the technical blog post [Rethinking the GNOME clipboard issues](https://edu4rdshl.dev/posts/rethinking-the-gnome-clipboard-issues/)
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
**Content types.** Strata captures and previews:
|
||||||
|
|
||||||
|
- **Text** (UTF-8). When an app offers both rich and plain text, Strata stores
|
||||||
|
the plain text rather than styled HTML.
|
||||||
|
- **URLs** are shown link-styled, with the hostname as a subtitle.
|
||||||
|
- **Colors**: hex values (`#rgb` / `#rrggbb`) get a color swatch.
|
||||||
|
- **Images**: PNG, JPEG, GIF, WebP, BMP, TIFF, ICO, shown as thumbnails.
|
||||||
|
Decoding and resizing happen once, in the daemon, at copy time.
|
||||||
|
- **Files**: file-manager copy/cut (URI lists, e.g. from Nautilus).
|
||||||
|
|
||||||
|
Unknown MIME types are ignored (a strict allowlist).
|
||||||
|
|
||||||
|
**Search.**
|
||||||
|
|
||||||
|
- Full-text search over the entire stored history, backed by SQLite FTS5.
|
||||||
|
- Prefix matching, diacritic-insensitive (`cafe` matches `café`).
|
||||||
|
- Text only; images and binaries are not indexed.
|
||||||
|
|
||||||
|
**Appearance.**
|
||||||
|
|
||||||
|
- Light and dark styling follows the GNOME Shell automatically, matching the
|
||||||
|
rest of the shell UI.
|
||||||
|
- Configurable panel position (top/center/bottom by left/center/right), width,
|
||||||
|
and maximum height.
|
||||||
|
- Optional "move an item to the top" when you paste it.
|
||||||
|
|
||||||
|
**Performance.**
|
||||||
|
|
||||||
|
- All hashing, decoding, storage, search, and thumbnailing run in the Rust
|
||||||
|
daemon, off the compositor's main loop.
|
||||||
|
- Lazy loading: the panel loads one page of history at a time and fetches more
|
||||||
|
on scroll; thumbnails are fetched on demand and cached on disk; search
|
||||||
|
renders a page at a time. The full table never sits in memory.
|
||||||
|
- Deduplication: copying the same content twice moves the existing entry to the
|
||||||
|
top (blake3 content hash) instead of adding a duplicate.
|
||||||
|
|
||||||
|
**Reliability.**
|
||||||
|
|
||||||
|
- SQLite in WAL mode with atomic upserts; history survives a crash.
|
||||||
|
- The extension supervises the daemon, respawning it with exponential backoff.
|
||||||
|
Only one daemon runs at a time; a second exits rather than contend for the
|
||||||
|
bus name.
|
||||||
|
- Configurable history limit (default 200, up to 2000); oldest items are pruned
|
||||||
|
automatically.
|
||||||
|
|
||||||
|
**Privacy and safety.**
|
||||||
|
|
||||||
|
- Password-manager aware: entries marked sensitive (the
|
||||||
|
`x-kde-passwordManagerHint` used by KeePassXC and others) are never stored.
|
||||||
|
- App exclusions: items copied while a listed app has focus are skipped. The
|
||||||
|
default list covers common password managers (1Password, KeePassXC,
|
||||||
|
Bitwarden, and others).
|
||||||
|
- Size caps: text and image payloads larger than a configurable limit (1 MB and
|
||||||
|
5 MB by default) are not stored.
|
||||||
|
- Never executes clipboard content: no shell exec, no `launch_uri`, no markup
|
||||||
|
parsing; paste-back only writes to the clipboard.
|
||||||
|
|
||||||
|
**Controls.**
|
||||||
|
|
||||||
|
- Top-bar icon and popup panel, opened with a configurable shortcut (default
|
||||||
|
`Super+Shift+V`).
|
||||||
|
- Keyboard navigation (arrow keys, `Esc` to close), click-outside to dismiss,
|
||||||
|
per-row delete, and "Clear all".
|
||||||
|
|
||||||
## Architecture
|
## Architecture
|
||||||
|
|
||||||
Strata is **two components**, and you need **both** for it to work:
|
Strata is **two components**, and you need **both** for it to work:
|
||||||
|
|
@ -26,9 +107,35 @@ GNOME Shell (GJS) ──D-Bus──▶ strata-daemon ──▶ SQLite (~/.lo
|
||||||
└──▶ thumbnails (~/.cache/strata)
|
└──▶ thumbnails (~/.cache/strata)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Installing the daemon
|
||||||
|
|
||||||
|
Strata is two parts: the GNOME Shell extension and a small background daemon
|
||||||
|
(`strata-daemon`) that does the storage, search, and thumbnailing. Installing
|
||||||
|
the extension from [GNOME Extensions](https://extensions.gnome.org/extension/10291/strata/)
|
||||||
|
is only half the setup; **without the daemon the extension does nothing.**
|
||||||
|
|
||||||
|
Install the daemon with whichever fits your system:
|
||||||
|
|
||||||
|
- **Arch (AUR):** `paru -S strata-daemon` (or `strata-daemon-git` for the latest `main`).
|
||||||
|
- **From source** (needs Rust/Cargo 1.74+):
|
||||||
|
|
||||||
|
```sh
|
||||||
|
git clone https://github.com/Edu4rdSHL/Strata.git
|
||||||
|
cd Strata
|
||||||
|
make install-daemon # builds and installs to ~/.local/bin
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure `~/.local/bin` is in your `$PATH`.
|
||||||
|
|
||||||
|
Then log out and back in (Wayland) or `Alt+F2` → `r` (X11). The extension finds
|
||||||
|
`strata-daemon` in `$PATH` and starts it automatically; no separate service is
|
||||||
|
needed.
|
||||||
|
|
||||||
|
For distro packages and the systemd user service, see [Install](#install).
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- GNOME Shell 50 (tested). May work on 45–49 but untested — if you try it and it works, please open an issue to let us know.
|
- GNOME Shell 50. Older releases may work if built from source but are not tested or supported.
|
||||||
- `strata-daemon` binary in `$PATH` (see Install below)
|
- `strata-daemon` binary in `$PATH` (see Install below)
|
||||||
- Rust 1.74+ (build only)
|
- Rust 1.74+ (build only)
|
||||||
- `glib-compile-schemas` (from `glib2-devel` / `libglib2.0-dev-bin`)
|
- `glib-compile-schemas` (from `glib2-devel` / `libglib2.0-dev-bin`)
|
||||||
|
|
@ -119,6 +226,19 @@ the wire protocol and a `busctl` example.
|
||||||
The shipped UI is a GNOME Shell extension. Ports to other desktops only
|
The shipped UI is a GNOME Shell extension. Ports to other desktops only
|
||||||
need a new front-end against the same D-Bus interface.
|
need a new front-end against the same D-Bus interface.
|
||||||
|
|
||||||
|
## How it looks
|
||||||
|
|
||||||
|
A responsive panel that drops down from the top bar and follows the GNOME
|
||||||
|
shell's look.
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="assets/panel-desktop.png" alt="Strata's clipboard panel open on the GNOME desktop" width="100%">
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="assets/panel.png" alt="Close-up of the Strata panel: a URL with its hostname, an image thumbnail, color swatches, and text entries" width="400">
|
||||||
|
</p>
|
||||||
|
|
||||||
## Deeper reading
|
## Deeper reading
|
||||||
|
|
||||||
- [`ARCHITECTURE.md`](ARCHITECTURE.md): design goals, process model,
|
- [`ARCHITECTURE.md`](ARCHITECTURE.md): design goals, process model,
|
||||||
|
|
|
||||||
170
assets/ego.svg
Normal file
|
After Width: | Height: | Size: 18 KiB |
7
assets/icon.svg
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Strata">
|
||||||
|
<!-- App-icon variant: staggered strata layers on a rounded dark square. -->
|
||||||
|
<rect width="64" height="64" rx="14" fill="#1e1e1e"/>
|
||||||
|
<rect x="10" y="15" width="34" height="9" rx="3" fill="#62a0ea"/>
|
||||||
|
<rect x="15" y="27.5" width="34" height="9" rx="3" fill="#3584e4"/>
|
||||||
|
<rect x="20" y="40" width="34" height="9" rx="3" fill="#1a5fb4"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 444 B |
6
assets/logo.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Strata">
|
||||||
|
<!-- Staggered strata layers (also a clipboard-history stack). -->
|
||||||
|
<rect x="8" y="13" width="38" height="10" rx="3" fill="#62a0ea"/>
|
||||||
|
<rect x="14" y="27" width="38" height="10" rx="3" fill="#3584e4"/>
|
||||||
|
<rect x="20" y="41" width="38" height="10" rx="3" fill="#1a5fb4"/>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 375 B |
21
assets/og-card.svg
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 630" font-family="Liberation Sans, DejaVu Sans, sans-serif">
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">
|
||||||
|
<stop offset="0" stop-color="#232323"/>
|
||||||
|
<stop offset="1" stop-color="#181818"/>
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
<rect width="1200" height="630" fill="url(#bg)"/>
|
||||||
|
|
||||||
|
<!-- staggered strata mark, scaled from the 64-unit logo -->
|
||||||
|
<g transform="translate(130,150) scale(5.4)">
|
||||||
|
<rect x="8" y="13" width="38" height="10" rx="3" fill="#62a0ea"/>
|
||||||
|
<rect x="14" y="27" width="38" height="10" rx="3" fill="#3584e4"/>
|
||||||
|
<rect x="20" y="41" width="38" height="10" rx="3" fill="#1a5fb4"/>
|
||||||
|
</g>
|
||||||
|
|
||||||
|
<!-- wordmark + tagline -->
|
||||||
|
<text x="500" y="305" font-size="140" font-weight="700" fill="#ffffff">Strata</text>
|
||||||
|
<text x="505" y="368" font-size="34" fill="#bcbcbc">Stutter-free clipboard history for GNOME</text>
|
||||||
|
<text x="505" y="414" font-size="29" fill="#6f6f6f">JS draws, Rust thinks.</text>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1,004 B |
BIN
assets/og-image.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
assets/panel-desktop.png
Normal file
|
After Width: | Height: | Size: 421 KiB |
BIN
assets/panel.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
149
eslint.config.js
Normal file
|
|
@ -0,0 +1,149 @@
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
// SPDX-FileCopyrightText: No rights reserved
|
||||||
|
|
||||||
|
import js from '@eslint/js';
|
||||||
|
|
||||||
|
export default [
|
||||||
|
js.configs.recommended,
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
ARGV: 'readonly',
|
||||||
|
Debugger: 'readonly',
|
||||||
|
GIRepositoryGType: 'readonly',
|
||||||
|
globalThis: 'readonly',
|
||||||
|
imports: 'readonly',
|
||||||
|
Intl: 'readonly',
|
||||||
|
log: 'readonly',
|
||||||
|
logError: 'readonly',
|
||||||
|
pkg: 'readonly',
|
||||||
|
print: 'readonly',
|
||||||
|
printerr: 'readonly',
|
||||||
|
window: 'readonly',
|
||||||
|
TextEncoder: 'readonly',
|
||||||
|
TextDecoder: 'readonly',
|
||||||
|
console: 'readonly',
|
||||||
|
setTimeout: 'readonly',
|
||||||
|
setInterval: 'readonly',
|
||||||
|
clearTimeout: 'readonly',
|
||||||
|
clearInterval: 'readonly',
|
||||||
|
// GNOME Shell Only
|
||||||
|
global: 'readonly',
|
||||||
|
_: 'readonly',
|
||||||
|
C_: 'readonly',
|
||||||
|
N_: 'readonly',
|
||||||
|
ngettext: 'readonly',
|
||||||
|
},
|
||||||
|
parserOptions: {
|
||||||
|
ecmaVersion: 2022,
|
||||||
|
sourceType: 'module',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// See: https://eslint.org/docs/latest/rules/#possible-problems
|
||||||
|
'array-callback-return': 'error',
|
||||||
|
'no-await-in-loop': 'error',
|
||||||
|
'no-constant-binary-expression': 'error',
|
||||||
|
'no-constructor-return': 'error',
|
||||||
|
'no-new-native-nonconstructor': 'error',
|
||||||
|
'no-promise-executor-return': 'error',
|
||||||
|
'no-self-compare': 'error',
|
||||||
|
'no-template-curly-in-string': 'error',
|
||||||
|
'no-unmodified-loop-condition': 'error',
|
||||||
|
'no-unreachable-loop': 'error',
|
||||||
|
'no-unused-private-class-members': 'error',
|
||||||
|
'no-use-before-define': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
functions: false,
|
||||||
|
classes: true,
|
||||||
|
variables: true,
|
||||||
|
allowNamedExports: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// See: https://eslint.org/docs/latest/rules/#suggestions
|
||||||
|
'block-scoped-var': 'error',
|
||||||
|
'complexity': 'warn',
|
||||||
|
'consistent-return': 'error',
|
||||||
|
'default-param-last': 'error',
|
||||||
|
'eqeqeq': 'error',
|
||||||
|
'no-array-constructor': 'error',
|
||||||
|
'no-caller': 'error',
|
||||||
|
'no-extend-native': 'error',
|
||||||
|
'no-extra-bind': 'error',
|
||||||
|
'no-extra-label': 'error',
|
||||||
|
'no-iterator': 'error',
|
||||||
|
'no-label-var': 'error',
|
||||||
|
'no-loop-func': 'error',
|
||||||
|
'no-multi-assign': 'warn',
|
||||||
|
'no-new-object': 'error',
|
||||||
|
'no-new-wrappers': 'error',
|
||||||
|
'no-proto': 'error',
|
||||||
|
'no-shadow': 'warn',
|
||||||
|
'no-unused-vars': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
varsIgnorePattern: '^_',
|
||||||
|
argsIgnorePattern: '^_',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'no-var': 'warn',
|
||||||
|
'unicode-bom': 'error',
|
||||||
|
// GJS Restrictions
|
||||||
|
'no-restricted-globals': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
name: 'Debugger',
|
||||||
|
message: 'Internal use only',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'GIRepositoryGType',
|
||||||
|
message: 'Internal use only',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'log',
|
||||||
|
message: 'Use console.log()',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'logError',
|
||||||
|
message: 'Use console.warn() or console.error()',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'no-restricted-properties': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
object: 'imports',
|
||||||
|
property: 'format',
|
||||||
|
message: 'Use template strings',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: 'pkg',
|
||||||
|
property: 'initFormat',
|
||||||
|
message: 'Use template strings',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: 'Lang',
|
||||||
|
property: 'copyProperties',
|
||||||
|
message: 'Use Object.assign()',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: 'Lang',
|
||||||
|
property: 'bind',
|
||||||
|
message: 'Use arrow notation or Function.prototype.bind()',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
object: 'Lang',
|
||||||
|
property: 'Class',
|
||||||
|
message: 'Use ES6 classes',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
'no-restricted-syntax': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
selector: 'MethodDefinition[key.name="_init"] CallExpression[arguments.length<=1][callee.object.type="Super"][callee.property.name="_init"]',
|
||||||
|
message: 'Use constructor() and super()',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
14
package.json
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"name": "strata-extension",
|
||||||
|
"version": "0.9.0",
|
||||||
|
"description": "Lint tooling for the Strata GNOME Shell extension",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"lint": "eslint 'strata@edu4rdshl.dev'"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@eslint/js": "^10.0.0",
|
||||||
|
"eslint": "^10.0.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
2
strata-daemon/Cargo.lock
generated
|
|
@ -1205,7 +1205,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "strata-daemon"
|
name = "strata-daemon"
|
||||||
version = "0.8.0"
|
version = "0.11.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"blake3",
|
"blake3",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "strata-daemon"
|
name = "strata-daemon"
|
||||||
version = "0.8.0"
|
version = "0.11.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "Strata clipboard manager backend daemon"
|
description = "Strata clipboard manager backend daemon"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
|
||||||
|
|
||||||
import { StrataProxy, BUS_NAME, OBJECT_PATH } from './dbus.js';
|
import { StrataProxy, BUS_NAME, OBJECT_PATH } from './dbus.js';
|
||||||
import { StrataPanel } from './ui/panel.js';
|
import { StrataPanel } from './ui/panel.js';
|
||||||
|
import { logError } from './util.js';
|
||||||
|
|
||||||
export default class StrataExtension extends Extension {
|
export default class StrataExtension extends Extension {
|
||||||
/** @type {Gio.Subprocess | null} */
|
/** @type {Gio.Subprocess | null} */
|
||||||
|
|
@ -21,7 +22,6 @@ export default class StrataExtension extends Extension {
|
||||||
_daemonRestartAttempts = 0;
|
_daemonRestartAttempts = 0;
|
||||||
_shuttingDown = false;
|
_shuttingDown = false;
|
||||||
_daemonRestartTimerId = null;
|
_daemonRestartTimerId = null;
|
||||||
_daemonKillTimerId = null;
|
|
||||||
/** True while a GetNameOwner check before spawning is in flight, so an
|
/** True while a GetNameOwner check before spawning is in flight, so an
|
||||||
* overlapping respawn attempt can't spawn a second daemon. */
|
* overlapping respawn attempt can't spawn a second daemon. */
|
||||||
_spawnPending = false;
|
_spawnPending = false;
|
||||||
|
|
@ -35,18 +35,12 @@ export default class StrataExtension extends Extension {
|
||||||
_itemDeletedId = null;
|
_itemDeletedId = null;
|
||||||
_historyClearedId = null;
|
_historyClearedId = null;
|
||||||
|
|
||||||
/** @type {number | null} focused-window signal connection ID */
|
|
||||||
_focusSignalId = null;
|
|
||||||
|
|
||||||
/** @type {string} WM class of the currently focused app (lower-cased) */
|
/** @type {string} WM class of the currently focused app (lower-cased) */
|
||||||
_currentFocusedApp = '';
|
_currentFocusedApp = '';
|
||||||
|
|
||||||
/** @type {object | null} PanelMenu.Button indicator */
|
/** @type {object | null} PanelMenu.Button indicator */
|
||||||
_indicator = null;
|
_indicator = null;
|
||||||
|
|
||||||
/** @type {number | null} Meta.Selection owner-changed signal ID */
|
|
||||||
_selectionChangedId = null;
|
|
||||||
|
|
||||||
/** @type {number | null} Debounce timer for clipboard reads */
|
/** @type {number | null} Debounce timer for clipboard reads */
|
||||||
_clipboardDebounceId = null;
|
_clipboardDebounceId = null;
|
||||||
|
|
||||||
|
|
@ -57,55 +51,28 @@ export default class StrataExtension extends Extension {
|
||||||
_excludedApps = [];
|
_excludedApps = [];
|
||||||
_pendingSignalId = null;
|
_pendingSignalId = null;
|
||||||
|
|
||||||
/** @type {boolean} Re-entrancy guard for signal processing */
|
/** @type {Set<number>} Pending GLib.idle_add source IDs to flush on disable. */
|
||||||
#busy = false;
|
_idleSources = new Set();
|
||||||
|
|
||||||
/** @type {number | null} Keyboard shortcut binding ID */
|
|
||||||
_shortcutId = null;
|
|
||||||
|
|
||||||
enable() {
|
enable() {
|
||||||
this._shuttingDown = false;
|
this._shuttingDown = false;
|
||||||
this._daemonRestartAttempts = 0;
|
this._daemonRestartAttempts = 0;
|
||||||
// Cancel any pending force-kill timer left over from a previous disable
|
|
||||||
// (enable→disable→enable within 1.5s) so it can't outlive this cycle.
|
|
||||||
if (this._daemonKillTimerId) {
|
|
||||||
GLib.Source.remove(this._daemonKillTimerId);
|
|
||||||
this._daemonKillTimerId = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._settings = this.getSettings();
|
this._settings = this.getSettings();
|
||||||
this._excludedApps = this._settings.get_strv('excluded-apps');
|
this._excludedApps = this._readExcluded();
|
||||||
this._excludedAppsChangedId = this._settings.connect('changed::excluded-apps', () => {
|
|
||||||
this._excludedApps = this._settings.get_strv('excluded-apps');
|
|
||||||
});
|
|
||||||
|
|
||||||
this._readSizeLimits();
|
this._readSizeLimits();
|
||||||
this._configChangedIds = [
|
this._settings.connectObject(
|
||||||
this._settings.connect('changed::max-history', () => { this._readSizeLimits(); this._pushConfig(); }),
|
'changed::excluded-apps', () => { this._excludedApps = this._readExcluded(); },
|
||||||
this._settings.connect('changed::max-text-mb', () => { this._readSizeLimits(); this._pushConfig(); }),
|
'changed::max-history', () => { this._readSizeLimits(); this._pushConfig(); },
|
||||||
this._settings.connect('changed::max-image-mb', () => { this._readSizeLimits(); this._pushConfig(); }),
|
'changed::max-text-mb', () => { this._readSizeLimits(); this._pushConfig(); },
|
||||||
];
|
'changed::max-image-mb', () => { this._readSizeLimits(); this._pushConfig(); },
|
||||||
|
this);
|
||||||
|
|
||||||
// Load the light theme overrides into the Shell theme context. They stay
|
|
||||||
// inert until the panel toggles the `.strata-theme-light` class (panel.js).
|
|
||||||
this._loadThemeStylesheet();
|
|
||||||
|
|
||||||
// 1. Top-bar indicator icon.
|
|
||||||
this._addIndicator();
|
this._addIndicator();
|
||||||
|
|
||||||
// 2. Spawn the Rust daemon.
|
|
||||||
this._spawnDaemon();
|
this._spawnDaemon();
|
||||||
|
|
||||||
// 3. Connect D-Bus proxy (async - doesn't block if daemon isn't ready yet).
|
|
||||||
this._connectProxy();
|
this._connectProxy();
|
||||||
|
|
||||||
// 4. Track focused window (lightweight - no clipboard I/O).
|
|
||||||
this._connectFocusTracking();
|
this._connectFocusTracking();
|
||||||
|
|
||||||
// 5. Monitor clipboard via Meta.Selection (GNOME-native, no Wayland protocol needed).
|
|
||||||
this._connectClipboardMonitor();
|
this._connectClipboardMonitor();
|
||||||
|
|
||||||
// 6. Register keyboard shortcut.
|
|
||||||
this._registerShortcut();
|
this._registerShortcut();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,28 +83,18 @@ export default class StrataExtension extends Extension {
|
||||||
GLib.Source.remove(this._daemonRestartTimerId);
|
GLib.Source.remove(this._daemonRestartTimerId);
|
||||||
this._daemonRestartTimerId = null;
|
this._daemonRestartTimerId = null;
|
||||||
}
|
}
|
||||||
// Clean up in reverse order.
|
|
||||||
this._unregisterShortcut();
|
this._unregisterShortcut();
|
||||||
this._disconnectClipboardMonitor();
|
this._disconnectClipboardMonitor();
|
||||||
this._disconnectFocusTracking();
|
this._disconnectFocusTracking();
|
||||||
this._disconnectSignals();
|
this._disconnectSignals();
|
||||||
if (this._proxyOwnerId && this._proxy) {
|
this._clearIdleSources();
|
||||||
this._proxy.disconnect(this._proxyOwnerId);
|
this._proxy?.disconnectObject(this);
|
||||||
this._proxyOwnerId = 0;
|
this._settings?.disconnectObject(this);
|
||||||
}
|
|
||||||
if (this._configChangedIds && this._settings) {
|
|
||||||
for (const id of this._configChangedIds) this._settings.disconnect(id);
|
|
||||||
this._configChangedIds = null;
|
|
||||||
}
|
|
||||||
if (this._excludedAppsChangedId && this._settings) {
|
|
||||||
this._settings.disconnect(this._excludedAppsChangedId);
|
|
||||||
this._excludedAppsChangedId = null;
|
|
||||||
}
|
|
||||||
this._panel?.destroy();
|
this._panel?.destroy();
|
||||||
this._panel = null;
|
this._panel = null;
|
||||||
|
this._indicator?.disconnectObject(this);
|
||||||
this._indicator?.destroy();
|
this._indicator?.destroy();
|
||||||
this._indicator = null;
|
this._indicator = null;
|
||||||
this._unloadThemeStylesheet();
|
|
||||||
this._stopDaemon();
|
this._stopDaemon();
|
||||||
this._proxy = null;
|
this._proxy = null;
|
||||||
this._settings = null;
|
this._settings = null;
|
||||||
|
|
@ -152,20 +109,19 @@ export default class StrataExtension extends Extension {
|
||||||
style_class: 'system-status-icon',
|
style_class: 'system-status-icon',
|
||||||
});
|
});
|
||||||
this._indicator.add_child(icon);
|
this._indicator.add_child(icon);
|
||||||
this._indicator.connect('button-press-event', () => {
|
this._indicator.connectObject('button-press-event', () => {
|
||||||
this._panel?.toggle();
|
this._panel?.toggle();
|
||||||
return false; // EVENT_PROPAGATE
|
return false; // EVENT_PROPAGATE
|
||||||
});
|
}, this);
|
||||||
Main.panel.addToStatusArea('strata', this._indicator);
|
Main.panel.addToStatusArea('strata', this._indicator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_connectClipboardMonitor() {
|
_connectClipboardMonitor() {
|
||||||
const selection = global.display.get_selection();
|
global.display.get_selection().connectObject('owner-changed', (_sel, type) => {
|
||||||
this._selectionChangedId = selection.connect('owner-changed', (_sel, type) => {
|
|
||||||
if (type !== Meta.SelectionType.SELECTION_CLIPBOARD) return;
|
if (type !== Meta.SelectionType.SELECTION_CLIPBOARD) return;
|
||||||
this._scheduleClipboardRead();
|
this._scheduleClipboardRead();
|
||||||
});
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnectClipboardMonitor() {
|
_disconnectClipboardMonitor() {
|
||||||
|
|
@ -176,10 +132,7 @@ export default class StrataExtension extends Extension {
|
||||||
this._clipboardDebounceId = null;
|
this._clipboardDebounceId = null;
|
||||||
}
|
}
|
||||||
this._clipboardTransferPending = false;
|
this._clipboardTransferPending = false;
|
||||||
if (this._selectionChangedId !== null) {
|
global.display.get_selection().disconnectObject(this);
|
||||||
global.display.get_selection().disconnect(this._selectionChangedId);
|
|
||||||
this._selectionChangedId = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Debounce entry point - coalesces rapid clipboard changes (e.g. from
|
/** Debounce entry point - coalesces rapid clipboard changes (e.g. from
|
||||||
|
|
@ -196,8 +149,6 @@ export default class StrataExtension extends Extension {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Single in-flight transfer at a time - prevents queuing multiple concurrent
|
|
||||||
* transfer_async + base64_encode operations that would stall the main thread. */
|
|
||||||
_readClipboard() {
|
_readClipboard() {
|
||||||
if (this._clipboardTransferPending) return;
|
if (this._clipboardTransferPending) return;
|
||||||
const selection = global.display.get_selection();
|
const selection = global.display.get_selection();
|
||||||
|
|
@ -206,6 +157,7 @@ export default class StrataExtension extends Extension {
|
||||||
// copied secrets with this hint mime. Honoring it lets users keep
|
// copied secrets with this hint mime. Honoring it lets users keep
|
||||||
// their passwords out of clipboard history.
|
// their passwords out of clipboard history.
|
||||||
if (mimes.includes('x-kde-passwordManagerHint')) return;
|
if (mimes.includes('x-kde-passwordManagerHint')) return;
|
||||||
|
if (this._isExcluded(this._currentFocusedApp)) return;
|
||||||
const mime = this._pickMime(mimes);
|
const mime = this._pickMime(mimes);
|
||||||
if (!mime) return;
|
if (!mime) return;
|
||||||
|
|
||||||
|
|
@ -225,14 +177,10 @@ export default class StrataExtension extends Extension {
|
||||||
const bytes = outputStream.steal_as_bytes();
|
const bytes = outputStream.steal_as_bytes();
|
||||||
const size = bytes.get_size();
|
const size = bytes.get_size();
|
||||||
if (size === 0) return;
|
if (size === 0) return;
|
||||||
const MAX_TEXT = this._maxTextBytes;
|
if (size > (mime.startsWith('image/') ? this._maxImageBytes : this._maxTextBytes)) return;
|
||||||
const MAX_IMAGE = this._maxImageBytes;
|
|
||||||
if (size > (mime.startsWith('image/') ? MAX_IMAGE : MAX_TEXT)) return;
|
|
||||||
// Send raw bytes as a D-Bus `ay` so we avoid blocking
|
|
||||||
// synchronous base64 work on the GJS main thread.
|
|
||||||
this._proxy?.SubmitItemRemote(mime, bytes.get_data(), () => {});
|
this._proxy?.SubmitItemRemote(mime, bytes.get_data(), () => {});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Clipboard read error:', e.message);
|
logError('Clipboard read error', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -241,7 +189,6 @@ export default class StrataExtension extends Extension {
|
||||||
/** Pick the best MIME type to store from the offered list (mirrors Rust pick_mime). */
|
/** Pick the best MIME type to store from the offered list (mirrors Rust pick_mime). */
|
||||||
_pickMime(mimes) {
|
_pickMime(mimes) {
|
||||||
const PREFERRED = [
|
const PREFERRED = [
|
||||||
// Raster images (size-capped at MAX_IMAGE).
|
|
||||||
'image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/webp',
|
'image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/webp',
|
||||||
'image/bmp', 'image/tiff', 'image/x-icon',
|
'image/bmp', 'image/tiff', 'image/x-icon',
|
||||||
// Plain text (UTF-8 preferred, then locale, then X11 legacy aliases).
|
// Plain text (UTF-8 preferred, then locale, then X11 legacy aliases).
|
||||||
|
|
@ -261,9 +208,7 @@ export default class StrataExtension extends Extension {
|
||||||
];
|
];
|
||||||
for (const want of PREFERRED)
|
for (const want of PREFERRED)
|
||||||
if (mimes.includes(want)) return want;
|
if (mimes.includes(want)) return want;
|
||||||
// Allowlist only: see comment in pick_mime (daemon). Reading unknown
|
// Allowlist only: see pick_mime in the daemon. Unknown mime types are skipped.
|
||||||
// mime types could pull a 1 GB blob into Shell memory before we can
|
|
||||||
// size-check it.
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -288,10 +233,8 @@ export default class StrataExtension extends Extension {
|
||||||
if (this._shuttingDown) return;
|
if (this._shuttingDown) return;
|
||||||
try {
|
try {
|
||||||
_conn.call_finish(result);
|
_conn.call_finish(result);
|
||||||
// Name already owned - daemon managed externally (systemd etc).
|
// Name already owned (e.g. systemd user service) - don't spawn a second instance.
|
||||||
console.log('[Strata] daemon already running, skipping spawn');
|
} catch {
|
||||||
} catch (_) {
|
|
||||||
// Name not owned - spawn it ourselves.
|
|
||||||
this._doSpawnDaemon();
|
this._doSpawnDaemon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -302,10 +245,7 @@ export default class StrataExtension extends Extension {
|
||||||
if (this._shuttingDown) return;
|
if (this._shuttingDown) return;
|
||||||
const daemonPath = GLib.find_program_in_path('strata-daemon');
|
const daemonPath = GLib.find_program_in_path('strata-daemon');
|
||||||
if (!daemonPath) {
|
if (!daemonPath) {
|
||||||
console.error(
|
logError('strata-daemon not found in PATH. Install the strata-daemon package or place the binary in your PATH.');
|
||||||
'[Strata] strata-daemon not found in PATH. ' +
|
|
||||||
'Install the strata-daemon package or place the binary in your PATH.'
|
|
||||||
);
|
|
||||||
this._notifyDaemonMissing();
|
this._notifyDaemonMissing();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +258,7 @@ export default class StrataExtension extends Extension {
|
||||||
this._daemonSpawnTime = GLib.get_monotonic_time() / 1000; // ms
|
this._daemonSpawnTime = GLib.get_monotonic_time() / 1000; // ms
|
||||||
this._daemon.wait_async(null, (proc) => this._onDaemonExited(proc));
|
this._daemon.wait_async(null, (proc) => this._onDaemonExited(proc));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Failed to spawn daemon:', e);
|
logError('Failed to spawn daemon', e);
|
||||||
this._scheduleDaemonRestart();
|
this._scheduleDaemonRestart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -332,12 +272,12 @@ export default class StrataExtension extends Extension {
|
||||||
Main.messageTray.add(source);
|
Main.messageTray.add(source);
|
||||||
const notification = new MessageTray.Notification({
|
const notification = new MessageTray.Notification({
|
||||||
source,
|
source,
|
||||||
title: 'Strata: daemon not found',
|
title: 'Strata: daemon not installed',
|
||||||
body: 'Install the strata-daemon package to enable clipboard history.',
|
body: 'Install the strata-daemon package. See the project page for instructions.',
|
||||||
urgency: MessageTray.Urgency.HIGH,
|
urgency: MessageTray.Urgency.HIGH,
|
||||||
});
|
});
|
||||||
source.addNotification(notification);
|
source.addNotification(notification);
|
||||||
} catch (_) {
|
} catch {
|
||||||
// Message tray may not be available (e.g. during early startup) - already logged above.
|
// Message tray may not be available (e.g. during early startup) - already logged above.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -351,26 +291,17 @@ export default class StrataExtension extends Extension {
|
||||||
const lifetimeMs = (GLib.get_monotonic_time() / 1000) - this._daemonSpawnTime;
|
const lifetimeMs = (GLib.get_monotonic_time() / 1000) - this._daemonSpawnTime;
|
||||||
this._daemon = null;
|
this._daemon = null;
|
||||||
|
|
||||||
if (this._shuttingDown) {
|
if (this._shuttingDown) return;
|
||||||
console.log(`[Strata] daemon exited cleanly during shutdown (status=${exit})`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset attempt counter if the daemon ran long enough to be considered healthy.
|
// Reset attempt counter if the daemon ran long enough to be considered healthy.
|
||||||
if (lifetimeMs >= 5000) {
|
if (lifetimeMs >= 5000) {
|
||||||
this._daemonRestartAttempts = 0;
|
this._daemonRestartAttempts = 0;
|
||||||
}
|
}
|
||||||
this._daemonRestartAttempts++;
|
this._daemonRestartAttempts++;
|
||||||
console.error(
|
logError(`daemon exited with status ${exit} after ${Math.round(lifetimeMs)}ms (restart attempt ${this._daemonRestartAttempts})`);
|
||||||
`[Strata] daemon exited with status ${exit} after ${Math.round(lifetimeMs)}ms ` +
|
|
||||||
`(restart attempt ${this._daemonRestartAttempts})`
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this._daemonRestartAttempts > 5) {
|
if (this._daemonRestartAttempts > 5) {
|
||||||
console.error(
|
logError('Daemon crashed 5 times in rapid succession - giving up. Disable and re-enable the extension to retry.');
|
||||||
'[Strata] Daemon crashed 5 times in rapid succession - giving up. ' +
|
|
||||||
'Disable and re-enable the extension to retry.'
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._scheduleDaemonRestart();
|
this._scheduleDaemonRestart();
|
||||||
|
|
@ -378,9 +309,12 @@ export default class StrataExtension extends Extension {
|
||||||
|
|
||||||
_scheduleDaemonRestart() {
|
_scheduleDaemonRestart() {
|
||||||
if (this._shuttingDown) return;
|
if (this._shuttingDown) return;
|
||||||
|
if (this._daemonRestartTimerId !== null) {
|
||||||
|
GLib.Source.remove(this._daemonRestartTimerId);
|
||||||
|
this._daemonRestartTimerId = null;
|
||||||
|
}
|
||||||
// Exponential backoff: 1s, 2s, 4s, 8s, 16s
|
// Exponential backoff: 1s, 2s, 4s, 8s, 16s
|
||||||
const backoffMs = 1000 * Math.pow(2, Math.max(0, this._daemonRestartAttempts - 1));
|
const backoffMs = 1000 * Math.pow(2, Math.max(0, this._daemonRestartAttempts - 1));
|
||||||
console.log(`[Strata] respawning daemon in ${backoffMs}ms`);
|
|
||||||
this._daemonRestartTimerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, backoffMs, () => {
|
this._daemonRestartTimerId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, backoffMs, () => {
|
||||||
this._daemonRestartTimerId = null;
|
this._daemonRestartTimerId = null;
|
||||||
this._spawnDaemon();
|
this._spawnDaemon();
|
||||||
|
|
@ -390,20 +324,9 @@ export default class StrataExtension extends Extension {
|
||||||
|
|
||||||
_stopDaemon() {
|
_stopDaemon() {
|
||||||
if (!this._daemon) return;
|
if (!this._daemon) return;
|
||||||
// Capture reference immediately so the timer doesn't kill a newly-spawned daemon.
|
const daemon = this._daemon;
|
||||||
const daemonToStop = this._daemon;
|
|
||||||
this._daemon = null;
|
this._daemon = null;
|
||||||
try {
|
daemon.send_signal(15); // SIGTERM
|
||||||
// Graceful shutdown via D-Bus first.
|
|
||||||
this._proxy?.ShutdownRemote(() => {});
|
|
||||||
} catch (_) {}
|
|
||||||
// Give it 1.5s then force-terminate. Track the source so a re-enable
|
|
||||||
// within that window can cancel it (see enable()).
|
|
||||||
this._daemonKillTimerId = GLib.timeout_add(GLib.PRIORITY_LOW, 1500, () => {
|
|
||||||
this._daemonKillTimerId = null;
|
|
||||||
try { daemonToStop.send_signal(15); } catch (_) {} // SIGTERM
|
|
||||||
return GLib.SOURCE_REMOVE;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -414,22 +337,23 @@ export default class StrataExtension extends Extension {
|
||||||
BUS_NAME,
|
BUS_NAME,
|
||||||
OBJECT_PATH,
|
OBJECT_PATH,
|
||||||
(proxy, error) => {
|
(proxy, error) => {
|
||||||
|
if (this._shuttingDown || proxy !== this._proxy) return;
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('[Strata] D-Bus proxy error:', error);
|
logError('D-Bus proxy error', error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this._connectSignals();
|
this._connectSignals();
|
||||||
this._panel = new StrataPanel(proxy, this._settings, this._indicator);
|
this._panel = new StrataPanel(proxy, this._settings);
|
||||||
// Push config now if the daemon is already up, and
|
// Push config now if the daemon is already up, and
|
||||||
// again on every owner transition so a respawned
|
// again on every owner transition so a respawned
|
||||||
// daemon picks up the latest values.
|
// daemon picks up the latest values.
|
||||||
this._pushConfig();
|
this._pushConfig();
|
||||||
this._proxyOwnerId = proxy.connect('notify::g-name-owner',
|
proxy.connectObject('notify::g-name-owner',
|
||||||
() => { if (proxy.g_name_owner) this._pushConfig(); });
|
() => { if (proxy.g_name_owner) this._pushConfig(); }, this);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Failed to create D-Bus proxy:', e);
|
logError('Failed to create D-Bus proxy', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,80 +376,77 @@ export default class StrataExtension extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
_connectSignals() {
|
_connectSignals() {
|
||||||
this._itemAddedId = Gio.DBus.session.signal_subscribe(
|
this._itemAddedId = this._proxy.connectSignal('ItemAdded',
|
||||||
BUS_NAME,
|
(_p, _sender, [id, mimeType, preview]) =>
|
||||||
'dev.edu4rdshl.Strata.Manager',
|
this._onItemAdded(id, mimeType, preview));
|
||||||
'ItemAdded',
|
|
||||||
OBJECT_PATH,
|
|
||||||
null,
|
|
||||||
Gio.DBusSignalFlags.NONE,
|
|
||||||
this._onItemAdded.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this._itemDeletedId = Gio.DBus.session.signal_subscribe(
|
this._itemDeletedId = this._proxy.connectSignal('ItemDeleted',
|
||||||
BUS_NAME,
|
(_p, _sender, [id]) => {
|
||||||
'dev.edu4rdshl.Strata.Manager',
|
|
||||||
'ItemDeleted',
|
|
||||||
OBJECT_PATH,
|
|
||||||
null,
|
|
||||||
Gio.DBusSignalFlags.NONE,
|
|
||||||
(_conn, _sender, _path, _iface, _signal, params) => {
|
|
||||||
const [id] = params.deepUnpack();
|
|
||||||
// Best-effort: unlink the on-disk thumbnail file (if any).
|
|
||||||
// GLib.unlink returns -1 if file doesn't exist; we ignore that.
|
|
||||||
try {
|
try {
|
||||||
const cachePath =
|
const cachePath =
|
||||||
`${GLib.get_user_cache_dir()}/strata/thumbnails/${id}.png`;
|
`${GLib.get_user_cache_dir()}/strata/thumbnails/${id}.png`;
|
||||||
GLib.unlink(cachePath);
|
GLib.unlink(cachePath);
|
||||||
} catch (_) { /* not all items have thumbnails - fine */ }
|
} catch { /* no cached thumbnail for this id */ }
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
this._addIdleSource(() => this._panel?.removeItem(id));
|
||||||
this._panel?.removeItem(id);
|
});
|
||||||
return GLib.SOURCE_REMOVE;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
this._historyClearedId = Gio.DBus.session.signal_subscribe(
|
this._historyClearedId = this._proxy.connectSignal('HistoryCleared',
|
||||||
BUS_NAME,
|
|
||||||
'dev.edu4rdshl.Strata.Manager',
|
|
||||||
'HistoryCleared',
|
|
||||||
OBJECT_PATH,
|
|
||||||
null,
|
|
||||||
Gio.DBusSignalFlags.NONE,
|
|
||||||
() => {
|
() => {
|
||||||
// Wipe all on-disk thumbnails when daemon clears history.
|
this._clearThumbnailCache();
|
||||||
|
this._addIdleSource(() => this._panel?.clearItems());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Delete every cached thumbnail without blocking the compositor:
|
||||||
|
* enumerate and unlink asynchronously in batches. */
|
||||||
|
_clearThumbnailCache() {
|
||||||
|
const dir = Gio.File.new_for_path(
|
||||||
|
`${GLib.get_user_cache_dir()}/strata/thumbnails`);
|
||||||
|
dir.enumerate_children_async(
|
||||||
|
'standard::name', Gio.FileQueryInfoFlags.NONE,
|
||||||
|
GLib.PRIORITY_DEFAULT, null,
|
||||||
|
(d, res) => {
|
||||||
|
let en;
|
||||||
try {
|
try {
|
||||||
const dir = `${GLib.get_user_cache_dir()}/strata/thumbnails`;
|
en = d.enumerate_children_finish(res);
|
||||||
const d = Gio.File.new_for_path(dir);
|
} catch {
|
||||||
if (d.query_exists(null)) {
|
return; // dir missing or unreadable
|
||||||
const en = d.enumerate_children(
|
}
|
||||||
'standard::name', Gio.FileQueryInfoFlags.NONE, null);
|
const step = () => {
|
||||||
let info;
|
en.next_files_async(32, GLib.PRIORITY_DEFAULT, null, (e, r) => {
|
||||||
while ((info = en.next_file(null))) {
|
let infos;
|
||||||
try { d.get_child(info.get_name()).delete(null); } catch (_) {}
|
try {
|
||||||
|
infos = e.next_files_finish(r);
|
||||||
|
} catch {
|
||||||
|
infos = [];
|
||||||
}
|
}
|
||||||
en.close(null);
|
if (infos.length === 0) {
|
||||||
}
|
e.close_async(GLib.PRIORITY_DEFAULT, null, () => {});
|
||||||
} catch (e) { console.error('[Strata] cache clear failed:', e); }
|
return;
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
}
|
||||||
this._panel?.clearItems();
|
for (const info of infos) {
|
||||||
return GLib.SOURCE_REMOVE;
|
e.get_child(info).delete_async(
|
||||||
});
|
GLib.PRIORITY_DEFAULT, null,
|
||||||
}
|
(f, rr) => { try { f.delete_finish(rr); } catch { /* best-effort */ } });
|
||||||
);
|
}
|
||||||
|
step();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
step();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnectSignals() {
|
_disconnectSignals() {
|
||||||
if (this._itemAddedId !== null) {
|
if (this._itemAddedId && this._proxy) {
|
||||||
Gio.DBus.session.signal_unsubscribe(this._itemAddedId);
|
this._proxy.disconnectSignal(this._itemAddedId);
|
||||||
this._itemAddedId = null;
|
this._itemAddedId = null;
|
||||||
}
|
}
|
||||||
if (this._itemDeletedId !== null) {
|
if (this._itemDeletedId && this._proxy) {
|
||||||
Gio.DBus.session.signal_unsubscribe(this._itemDeletedId);
|
this._proxy.disconnectSignal(this._itemDeletedId);
|
||||||
this._itemDeletedId = null;
|
this._itemDeletedId = null;
|
||||||
}
|
}
|
||||||
if (this._historyClearedId !== null) {
|
if (this._historyClearedId && this._proxy) {
|
||||||
Gio.DBus.session.signal_unsubscribe(this._historyClearedId);
|
this._proxy.disconnectSignal(this._historyClearedId);
|
||||||
this._historyClearedId = null;
|
this._historyClearedId = null;
|
||||||
}
|
}
|
||||||
if (this._pendingSignalId !== null) {
|
if (this._pendingSignalId !== null) {
|
||||||
|
|
@ -535,7 +456,24 @@ export default class StrataExtension extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_onItemAdded(_conn, _sender, _path, _iface, _signal, params) {
|
/** Schedule a one-shot idle callback whose source ID is tracked so disable()
|
||||||
|
* can drop pending work instead of leaking a closure on `this`. */
|
||||||
|
_addIdleSource(callback) {
|
||||||
|
const id = GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||||
|
this._idleSources.delete(id);
|
||||||
|
callback();
|
||||||
|
return GLib.SOURCE_REMOVE;
|
||||||
|
});
|
||||||
|
this._idleSources.add(id);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
_clearIdleSources() {
|
||||||
|
for (const id of this._idleSources) GLib.Source.remove(id);
|
||||||
|
this._idleSources.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
_onItemAdded(id, mimeType, preview) {
|
||||||
// Debounce: if the daemon emits a burst, coalesce into one update.
|
// Debounce: if the daemon emits a burst, coalesce into one update.
|
||||||
if (this._pendingSignalId !== null) {
|
if (this._pendingSignalId !== null) {
|
||||||
GLib.Source.remove(this._pendingSignalId);
|
GLib.Source.remove(this._pendingSignalId);
|
||||||
|
|
@ -543,55 +481,30 @@ export default class StrataExtension extends Extension {
|
||||||
}
|
}
|
||||||
this._pendingSignalId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50, () => {
|
this._pendingSignalId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 50, () => {
|
||||||
this._pendingSignalId = null;
|
this._pendingSignalId = null;
|
||||||
this._processItemAdded(params).catch(e => console.error('[Strata] ItemAdded error:', e));
|
this._addIdleSource(() => this._panel?.prependItem(id, mimeType, preview));
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async _processItemAdded(params) {
|
_readExcluded() {
|
||||||
if (this.#busy) return;
|
return this._settings.get_strv('excluded-apps').map(s => s.toLowerCase());
|
||||||
this.#busy = true;
|
|
||||||
try {
|
|
||||||
const [id, mimeType, preview] = params.deepUnpack();
|
|
||||||
|
|
||||||
// Exclusion check - no clipboard I/O, just string comparison.
|
|
||||||
if (this._isExcluded(this._currentFocusedApp)) {
|
|
||||||
try {
|
|
||||||
await this._proxy?.DeleteItemAsync(id);
|
|
||||||
} catch (e) {
|
|
||||||
// ignore - item may already be gone
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer UI mutation to after the current frame renders.
|
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
|
||||||
this._panel?.prependItem(id, mimeType, preview);
|
|
||||||
return GLib.SOURCE_REMOVE;
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
this.#busy = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_isExcluded(appClass) {
|
_isExcluded(appClass) {
|
||||||
if (!appClass) return false;
|
if (!appClass) return false;
|
||||||
return this._excludedApps.some(ex => appClass.includes(ex.toLowerCase()));
|
return this._excludedApps.some(ex => appClass.includes(ex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_connectFocusTracking() {
|
_connectFocusTracking() {
|
||||||
this._focusSignalId = global.display.connect('notify::focus-window', () => {
|
global.display.connectObject('notify::focus-window', () => {
|
||||||
const win = global.display.focus_window;
|
const win = global.display.focus_window;
|
||||||
this._currentFocusedApp = (win?.get_wm_class() ?? '').toLowerCase();
|
this._currentFocusedApp = (win?.get_wm_class() ?? '').toLowerCase();
|
||||||
});
|
}, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
_disconnectFocusTracking() {
|
_disconnectFocusTracking() {
|
||||||
if (this._focusSignalId !== null) {
|
global.display.disconnectObject(this);
|
||||||
global.display.disconnect(this._focusSignalId);
|
|
||||||
this._focusSignalId = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -612,37 +525,4 @@ export default class StrataExtension extends Extension {
|
||||||
_unregisterShortcut() {
|
_unregisterShortcut() {
|
||||||
Main.wm.removeKeybinding('keyboard-shortcut');
|
Main.wm.removeKeybinding('keyboard-shortcut');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Load light.css into the global St theme context ONCE. It is scoped under
|
|
||||||
* `.strata-theme-light`, so it stays inert until the panel adds that class
|
|
||||||
* (dark/light switching is the panel's class toggle, independent of this).
|
|
||||||
*
|
|
||||||
* We deliberately do NOT subscribe to the theme context's 'changed'
|
|
||||||
* signal: load_stylesheet itself emits 'changed', so reloading on it feeds
|
|
||||||
* back into itself and hits "too much recursion" (it fired on screen
|
|
||||||
* unlock, which restyles widgets). The only thing a one-time load gives up
|
|
||||||
* is re-applying after a GNOME Shell *theme* switch (which replaces the
|
|
||||||
* St.Theme and drops this sheet) - a rare action, recoverable by toggling
|
|
||||||
* the extension. That trade is worth never touching the signal. */
|
|
||||||
_loadThemeStylesheet() {
|
|
||||||
try {
|
|
||||||
const themeContext = St.ThemeContext.get_for_stage(global.stage);
|
|
||||||
this._lightCssFile = this.dir.get_child('light.css');
|
|
||||||
this._stTheme = themeContext.get_theme();
|
|
||||||
this._stTheme.load_stylesheet(this._lightCssFile);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('[Strata] Failed to load light.css:', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_unloadThemeStylesheet() {
|
|
||||||
try {
|
|
||||||
this._stTheme?.unload_stylesheet(this._lightCssFile);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('[Strata] Failed to unload light.css:', e);
|
|
||||||
}
|
|
||||||
this._stTheme = null;
|
|
||||||
this._lightCssFile = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,143 +0,0 @@
|
||||||
/* Strata light theme.
|
|
||||||
*
|
|
||||||
* Loaded into the Shell theme context by extension.js and activated by toggling
|
|
||||||
* the `.strata-theme-light` class on the panel root box (see ui/panel.js).
|
|
||||||
* Every rule is scoped under `.strata-theme-light` so it is strictly more
|
|
||||||
* specific than its counterpart in stylesheet.css and wins deterministically,
|
|
||||||
* regardless of stylesheet load order. The dark theme (stylesheet.css) is left
|
|
||||||
* untouched: with no class present, none of these rules apply.
|
|
||||||
*
|
|
||||||
* Colors follow GNOME Adwaita (blue #3584e4, link #1a5fb4, amber #b5830a,
|
|
||||||
* red #e01b24) and are picked for contrast on a light panel.
|
|
||||||
*
|
|
||||||
* Performance rule (same as stylesheet.css): NO `transition: all`, NO
|
|
||||||
* Clutter/CSS animations. Only background-color transitions on hover.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ── Panel container ────────────────────────────────────────────────────── */
|
|
||||||
.strata-panel.strata-theme-light {
|
|
||||||
background-color: rgba(250, 250, 250, 0.98);
|
|
||||||
border-color: rgba(0, 0, 0, 0.14);
|
|
||||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Header ─────────────────────────────────────────────────────────────── */
|
|
||||||
.strata-theme-light .strata-title {
|
|
||||||
color: rgba(0, 0, 0, 0.87);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-clear-btn {
|
|
||||||
border-color: rgba(0, 0, 0, 0.18);
|
|
||||||
color: rgba(0, 0, 0, 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-clear-btn:hover {
|
|
||||||
background-color: rgba(0, 0, 0, 0.07);
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Search box ─────────────────────────────────────────────────────────── */
|
|
||||||
.strata-theme-light .strata-search {
|
|
||||||
background-color: rgba(0, 0, 0, 0.05);
|
|
||||||
border-color: rgba(0, 0, 0, 0.14);
|
|
||||||
color: rgba(0, 0, 0, 0.87);
|
|
||||||
caret-color: rgba(0, 0, 0, 0.8);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-search:focus {
|
|
||||||
border-color: rgba(53, 132, 228, 0.8);
|
|
||||||
background-color: rgba(0, 0, 0, 0.035);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Placeholder ("Search...") text - legible dim gray on the light panel. */
|
|
||||||
.strata-theme-light .strata-search-hint {
|
|
||||||
color: rgba(0, 0, 0, 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Clipboard item: hover / focus (Adwaita blue) ───────────────────────── */
|
|
||||||
.strata-theme-light .strata-item:hover,
|
|
||||||
.strata-theme-light .strata-item-hovered {
|
|
||||||
background-color: rgba(53, 132, 228, 0.14);
|
|
||||||
border-color: rgba(53, 132, 228, 0.45);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item:focus,
|
|
||||||
.strata-theme-light .strata-item-focused {
|
|
||||||
background-color: rgba(53, 132, 228, 0.16);
|
|
||||||
border-color: rgba(53, 132, 228, 0.65);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item:hover:focus,
|
|
||||||
.strata-theme-light .strata-item-focused.strata-item-hovered {
|
|
||||||
background-color: rgba(53, 132, 228, 0.24);
|
|
||||||
border-color: rgba(53, 132, 228, 0.78);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item:focus .strata-item-text,
|
|
||||||
.strata-theme-light .strata-item-focused .strata-item-text {
|
|
||||||
color: rgba(0, 0, 0, 0.95);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Active item (warm amber, darkened for light bg) ────────────────────── */
|
|
||||||
.strata-theme-light .strata-item-active {
|
|
||||||
background-color: rgba(181, 131, 10, 0.16);
|
|
||||||
border-color: rgba(181, 131, 10, 0.50);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-active .strata-item-text {
|
|
||||||
color: rgba(120, 82, 0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-active.strata-item-hovered {
|
|
||||||
background-color: rgba(181, 131, 10, 0.24);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-active.strata-item-focused,
|
|
||||||
.strata-theme-light .strata-item-active:focus {
|
|
||||||
background-color: rgba(53, 132, 228, 0.20);
|
|
||||||
border-color: rgba(53, 132, 228, 0.65);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-active.strata-item-focused .strata-item-text,
|
|
||||||
.strata-theme-light .strata-item-active:focus .strata-item-text {
|
|
||||||
color: rgba(0, 0, 0, 0.95);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item:active {
|
|
||||||
background-color: rgba(0, 0, 0, 0.10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Item icon / thumbnail ──────────────────────────────────────────────── */
|
|
||||||
.strata-theme-light .strata-item-icon {
|
|
||||||
color: rgba(0, 0, 0, 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-thumb {
|
|
||||||
border-color: rgba(0, 0, 0, 0.15);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Text content ───────────────────────────────────────────────────────── */
|
|
||||||
.strata-theme-light .strata-item-text {
|
|
||||||
color: rgba(0, 0, 0, 0.85);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-url {
|
|
||||||
color: rgba(26, 95, 180, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-subtext {
|
|
||||||
color: rgba(0, 0, 0, 0.55);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ── Delete button (Adwaita red) ────────────────────────────────────────── */
|
|
||||||
.strata-theme-light .strata-item:hover .strata-item-delete,
|
|
||||||
.strata-theme-light .strata-item:focus .strata-item-delete,
|
|
||||||
.strata-theme-light .strata-item-focused .strata-item-delete,
|
|
||||||
.strata-theme-light .strata-item-hovered .strata-item-delete {
|
|
||||||
color: rgba(224, 27, 36, 0.75);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strata-theme-light .strata-item-delete:hover {
|
|
||||||
background-color: rgba(224, 27, 36, 0.13);
|
|
||||||
color: rgba(224, 27, 36, 1.0);
|
|
||||||
}
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"name": "Strata",
|
"name": "Strata",
|
||||||
"description": "A fast, stutter-free clipboard manager. All I/O runs in a Rust daemon - GNOME Shell is never blocked.",
|
"description": "A fast clipboard manager. Storage, search and image decoding run in a separate Rust daemon.",
|
||||||
"uuid": "strata@edu4rdshl.dev",
|
"uuid": "strata@edu4rdshl.dev",
|
||||||
"version": 8,
|
"version": 11,
|
||||||
"shell-version": ["45", "46", "47", "48", "49", "50"],
|
"shell-version": ["50"],
|
||||||
"settings-schema": "org.gnome.shell.extensions.strata",
|
"settings-schema": "org.gnome.shell.extensions.strata",
|
||||||
"url": "https://github.com/Edu4rdSHL/Strata"
|
"url": "https://github.com/Edu4rdSHL/Strata"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,8 @@
|
||||||
/**
|
/* prefs.js - Strata preferences window. */
|
||||||
* prefs.js - Strata preferences window (GNOME 45+ / Adw).
|
|
||||||
*
|
|
||||||
* Pages:
|
|
||||||
* General: max-history SpinRow, keyboard-shortcut ShortcutRow
|
|
||||||
* Privacy: excluded-apps ExpanderRow + StringList (one entry per line)
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Adw from 'gi://Adw';
|
import Adw from 'gi://Adw';
|
||||||
import Gtk from 'gi://Gtk';
|
import Gtk from 'gi://Gtk';
|
||||||
import Gdk from 'gi://Gdk';
|
import Gdk from 'gi://Gdk';
|
||||||
import GLib from 'gi://GLib';
|
|
||||||
import Gio from 'gi://Gio';
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
|
||||||
|
|
@ -22,17 +15,12 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
window.add(this._buildPrivacyPage(settings));
|
window.add(this._buildPrivacyPage(settings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// General page
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
_buildGeneralPage(settings) {
|
_buildGeneralPage(settings) {
|
||||||
const page = new Adw.PreferencesPage({
|
const page = new Adw.PreferencesPage({
|
||||||
title: 'General',
|
title: 'General',
|
||||||
icon_name: 'preferences-system-symbolic',
|
icon_name: 'preferences-system-symbolic',
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── History ──────────────────────────────────────────────────────────
|
|
||||||
const historyGroup = new Adw.PreferencesGroup({ title: 'History' });
|
const historyGroup = new Adw.PreferencesGroup({ title: 'History' });
|
||||||
|
|
||||||
const maxHistoryRow = new Adw.SpinRow({
|
const maxHistoryRow = new Adw.SpinRow({
|
||||||
|
|
@ -89,32 +77,8 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
|
|
||||||
page.add(historyGroup);
|
page.add(historyGroup);
|
||||||
|
|
||||||
// ── Appearance ───────────────────────────────────────────────────────
|
|
||||||
const appearanceGroup = new Adw.PreferencesGroup({ title: 'Appearance' });
|
const appearanceGroup = new Adw.PreferencesGroup({ title: 'Appearance' });
|
||||||
|
|
||||||
const themes = [
|
|
||||||
{ id: 'auto', label: 'Automatic' },
|
|
||||||
{ id: 'light', label: 'Light' },
|
|
||||||
{ id: 'dark', label: 'Dark' },
|
|
||||||
];
|
|
||||||
const themeRow = new Adw.ComboRow({
|
|
||||||
title: 'Theme',
|
|
||||||
subtitle: 'Automatic follows the system light/dark preference',
|
|
||||||
model: Gtk.StringList.new(themes.map(t => t.label)),
|
|
||||||
});
|
|
||||||
const currentTheme = settings.get_string('theme');
|
|
||||||
const currentThemeIdx = themes.findIndex(t => t.id === currentTheme);
|
|
||||||
themeRow.selected = currentThemeIdx >= 0 ? currentThemeIdx : 0;
|
|
||||||
themeRow.connect('notify::selected', () => {
|
|
||||||
settings.set_string('theme', themes[themeRow.selected].id);
|
|
||||||
});
|
|
||||||
settings.connect('changed::theme', () => {
|
|
||||||
const idx = themes.findIndex(t => t.id === settings.get_string('theme'));
|
|
||||||
if (idx >= 0 && themeRow.selected !== idx)
|
|
||||||
themeRow.selected = idx;
|
|
||||||
});
|
|
||||||
appearanceGroup.add(themeRow);
|
|
||||||
|
|
||||||
const panelWidthRow = new Adw.SpinRow({
|
const panelWidthRow = new Adw.SpinRow({
|
||||||
title: 'Panel width',
|
title: 'Panel width',
|
||||||
subtitle: 'Width of the clipboard panel in pixels',
|
subtitle: 'Width of the clipboard panel in pixels',
|
||||||
|
|
@ -180,7 +144,6 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
|
|
||||||
page.add(appearanceGroup);
|
page.add(appearanceGroup);
|
||||||
|
|
||||||
// ── Keyboard ─────────────────────────────────────────────────────────
|
|
||||||
const kbGroup = new Adw.PreferencesGroup({ title: 'Keyboard' });
|
const kbGroup = new Adw.PreferencesGroup({ title: 'Keyboard' });
|
||||||
|
|
||||||
const shortcutRow = new Adw.ActionRow({
|
const shortcutRow = new Adw.ActionRow({
|
||||||
|
|
@ -208,10 +171,6 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Privacy page
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
_buildPrivacyPage(settings) {
|
_buildPrivacyPage(settings) {
|
||||||
const page = new Adw.PreferencesPage({
|
const page = new Adw.PreferencesPage({
|
||||||
title: 'Privacy',
|
title: 'Privacy',
|
||||||
|
|
@ -223,13 +182,11 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
description: 'Items copied while these apps have focus will not be stored in history. Enter a partial app name (case-insensitive).',
|
description: 'Items copied while these apps have focus will not be stored in history. Enter a partial app name (case-insensitive).',
|
||||||
});
|
});
|
||||||
|
|
||||||
// We use a StringList model bound to excluded-apps.
|
|
||||||
const model = new Gtk.StringList();
|
const model = new Gtk.StringList();
|
||||||
const currentApps = settings.get_strv('excluded-apps');
|
const currentApps = settings.get_strv('excluded-apps');
|
||||||
for (const app of currentApps)
|
for (const app of currentApps)
|
||||||
model.append(app);
|
model.append(app);
|
||||||
|
|
||||||
/** Sync the StringList back to GSettings. */
|
|
||||||
const saveModel = () => {
|
const saveModel = () => {
|
||||||
const apps = [];
|
const apps = [];
|
||||||
for (let i = 0; i < model.get_n_items(); i++) {
|
for (let i = 0; i < model.get_n_items(); i++) {
|
||||||
|
|
@ -239,7 +196,6 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
settings.set_strv('excluded-apps', apps);
|
settings.set_strv('excluded-apps', apps);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Each item in the list: an EditableLabel + Remove button.
|
|
||||||
const listBox = new Gtk.ListBox({
|
const listBox = new Gtk.ListBox({
|
||||||
selection_mode: Gtk.SelectionMode.NONE,
|
selection_mode: Gtk.SelectionMode.NONE,
|
||||||
css_classes: ['boxed-list'],
|
css_classes: ['boxed-list'],
|
||||||
|
|
@ -280,7 +236,6 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
listBox.append(row);
|
listBox.append(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add-new row.
|
|
||||||
const addRow = new Adw.ActionRow({ activatable: false });
|
const addRow = new Adw.ActionRow({ activatable: false });
|
||||||
const addEntry = new Gtk.Entry({
|
const addEntry = new Gtk.Entry({
|
||||||
placeholder_text: 'App name…',
|
placeholder_text: 'App name…',
|
||||||
|
|
@ -314,10 +269,6 @@ export default class StrataPreferences extends ExtensionPreferences {
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
// Keyboard shortcut dialog
|
|
||||||
// -------------------------------------------------------------------------
|
|
||||||
|
|
||||||
_showShortcutDialog(parent, settings) {
|
_showShortcutDialog(parent, settings) {
|
||||||
const dialog = new Adw.MessageDialog({
|
const dialog = new Adw.MessageDialog({
|
||||||
heading: 'Set Keyboard Shortcut',
|
heading: 'Set Keyboard Shortcut',
|
||||||
|
|
|
||||||
|
|
@ -52,17 +52,6 @@
|
||||||
<description>When enabled, clicking or pressing Enter on a history item moves it to position 1 in the list.</description>
|
<description>When enabled, clicking or pressing Enter on a history item moves it to position 1 in the list.</description>
|
||||||
</key>
|
</key>
|
||||||
|
|
||||||
<key name="theme" type="s">
|
|
||||||
<choices>
|
|
||||||
<choice value="auto"/>
|
|
||||||
<choice value="light"/>
|
|
||||||
<choice value="dark"/>
|
|
||||||
</choices>
|
|
||||||
<default>'auto'</default>
|
|
||||||
<summary>Panel color theme</summary>
|
|
||||||
<description>Auto follows the system light/dark color scheme (org.gnome.desktop.interface color-scheme). Light and Dark force a fixed theme.</description>
|
|
||||||
</key>
|
|
||||||
|
|
||||||
<key name="panel-position" type="s">
|
<key name="panel-position" type="s">
|
||||||
<choices>
|
<choices>
|
||||||
<choice value="top-center"/>
|
<choice value="top-center"/>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* Strata clipboard manager stylesheet.
|
/* Strata dark theme (the default; loaded when the system color scheme is dark).
|
||||||
*
|
*
|
||||||
* Performance rule: NO `transition: all`, NO Clutter/CSS animations.
|
* Performance rule: NO `transition: all`, NO Clutter/CSS animations.
|
||||||
* Only background-color transitions on hover (GPU-composited, zero JS).
|
* Only background-color transitions on hover (GPU-composited, zero JS).
|
||||||
129
strata@edu4rdshl.dev/stylesheet-light.css
Normal file
|
|
@ -0,0 +1,129 @@
|
||||||
|
/* Strata light theme.
|
||||||
|
*
|
||||||
|
* GNOME Shell loads this instead of stylesheet-dark.css when the system color
|
||||||
|
* scheme is light. It imports the dark base and overrides the colors below, so
|
||||||
|
* the overrides win by load order. Colors follow GNOME Adwaita (blue #3584e4,
|
||||||
|
* link #1a5fb4, amber, red #e01b24), picked for contrast on a light panel.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@import url("stylesheet-dark.css");
|
||||||
|
|
||||||
|
.strata-panel {
|
||||||
|
background-color: rgba(250, 250, 250, 0.98);
|
||||||
|
border-color: rgba(0, 0, 0, 0.14);
|
||||||
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-title {
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-clear-btn {
|
||||||
|
border-color: rgba(0, 0, 0, 0.18);
|
||||||
|
color: rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-clear-btn:hover {
|
||||||
|
background-color: rgba(0, 0, 0, 0.07);
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-search {
|
||||||
|
background-color: rgba(0, 0, 0, 0.05);
|
||||||
|
border-color: rgba(0, 0, 0, 0.14);
|
||||||
|
color: rgba(0, 0, 0, 0.87);
|
||||||
|
caret-color: rgba(0, 0, 0, 0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-search:focus {
|
||||||
|
border-color: rgba(53, 132, 228, 0.8);
|
||||||
|
background-color: rgba(0, 0, 0, 0.035);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Placeholder ("Search...") text - legible dim gray on the light panel. */
|
||||||
|
.strata-search-hint {
|
||||||
|
color: rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:hover,
|
||||||
|
.strata-item-hovered {
|
||||||
|
background-color: rgba(53, 132, 228, 0.14);
|
||||||
|
border-color: rgba(53, 132, 228, 0.45);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:focus,
|
||||||
|
.strata-item-focused {
|
||||||
|
background-color: rgba(53, 132, 228, 0.16);
|
||||||
|
border-color: rgba(53, 132, 228, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:hover:focus,
|
||||||
|
.strata-item-focused.strata-item-hovered {
|
||||||
|
background-color: rgba(53, 132, 228, 0.24);
|
||||||
|
border-color: rgba(53, 132, 228, 0.78);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:focus .strata-item-text,
|
||||||
|
.strata-item-focused .strata-item-text {
|
||||||
|
color: rgba(0, 0, 0, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-active {
|
||||||
|
background-color: rgba(181, 131, 10, 0.16);
|
||||||
|
border-color: rgba(181, 131, 10, 0.50);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-active .strata-item-text {
|
||||||
|
color: rgba(120, 82, 0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-active.strata-item-hovered {
|
||||||
|
background-color: rgba(181, 131, 10, 0.24);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-active.strata-item-focused,
|
||||||
|
.strata-item-active:focus {
|
||||||
|
background-color: rgba(53, 132, 228, 0.20);
|
||||||
|
border-color: rgba(53, 132, 228, 0.65);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-active.strata-item-focused .strata-item-text,
|
||||||
|
.strata-item-active:focus .strata-item-text {
|
||||||
|
color: rgba(0, 0, 0, 0.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:active {
|
||||||
|
background-color: rgba(0, 0, 0, 0.10);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-icon {
|
||||||
|
color: rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-thumb {
|
||||||
|
border-color: rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-text {
|
||||||
|
color: rgba(0, 0, 0, 0.85);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-url {
|
||||||
|
color: rgba(26, 95, 180, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-subtext {
|
||||||
|
color: rgba(0, 0, 0, 0.55);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item:hover .strata-item-delete,
|
||||||
|
.strata-item:focus .strata-item-delete,
|
||||||
|
.strata-item-focused .strata-item-delete,
|
||||||
|
.strata-item-hovered .strata-item-delete {
|
||||||
|
color: rgba(224, 27, 36, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
.strata-item-delete:hover {
|
||||||
|
background-color: rgba(224, 27, 36, 0.13);
|
||||||
|
color: rgba(224, 27, 36, 1.0);
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ import St from 'gi://St';
|
||||||
import Clutter from 'gi://Clutter';
|
import Clutter from 'gi://Clutter';
|
||||||
import Gio from 'gi://Gio';
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
|
import { logError } from '../util.js';
|
||||||
|
|
||||||
const TEXT_PREVIEW_LEN = 140;
|
const TEXT_PREVIEW_LEN = 140;
|
||||||
const THUMB_SIZE = 48;
|
const THUMB_SIZE = 48;
|
||||||
|
|
||||||
|
|
@ -22,24 +24,23 @@ function iconForMime(mimeType) {
|
||||||
return 'edit-copy-symbolic';
|
return 'edit-copy-symbolic';
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Detect if a string looks like a URL. */
|
|
||||||
function isUrl(text) {
|
function isUrl(text) {
|
||||||
return /^https?:\/\/.+/i.test(text.trim());
|
return /^https?:\/\/.+/i.test(text.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Detect if a string looks like a CSS/hex color. */
|
|
||||||
function isColor(text) {
|
function isColor(text) {
|
||||||
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(text.trim());
|
return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(text.trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ClipboardItem = GObject.registerClass({
|
export const ClipboardItem = GObject.registerClass({
|
||||||
|
GTypeName: 'StrataClipboardItem',
|
||||||
Signals: {
|
Signals: {
|
||||||
'activate': {},
|
'activate': {},
|
||||||
'delete': {},
|
'delete': {},
|
||||||
},
|
},
|
||||||
}, class ClipboardItem extends St.Button {
|
}, class extends St.Button {
|
||||||
_init(id, mimeType, preview, opts = {}) {
|
constructor(id, mimeType, preview, opts = {}) {
|
||||||
super._init({
|
super({
|
||||||
style_class: 'strata-item',
|
style_class: 'strata-item',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
can_focus: true,
|
can_focus: true,
|
||||||
|
|
@ -48,26 +49,20 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
|
|
||||||
this._id = id;
|
this._id = id;
|
||||||
this._mimeType = mimeType;
|
this._mimeType = mimeType;
|
||||||
/** D-Bus proxy used for lazy thumbnail fetch. */
|
|
||||||
this._proxy = opts.proxy ?? null;
|
this._proxy = opts.proxy ?? null;
|
||||||
/** Optional shared LRU cache (Map<id, string filePath>) - populated on first fetch. */
|
|
||||||
this._thumbCache = opts.thumbCache ?? null;
|
this._thumbCache = opts.thumbCache ?? null;
|
||||||
/** Stored on the actor so panel.js can filter by it. */
|
|
||||||
this.actor = this;
|
|
||||||
this._strataPreview = mimeType.startsWith('image/') ? '' : preview;
|
|
||||||
|
|
||||||
const row = new St.BoxLayout({
|
const row = new St.BoxLayout({
|
||||||
style_class: 'strata-item-row',
|
style_class: 'strata-item-row',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Left: icon or image thumbnail
|
const isImage = mimeType.startsWith('image/');
|
||||||
row.add_child(this._buildLeading(mimeType, preview));
|
const urlLike = !isImage && isUrl(preview ?? '');
|
||||||
|
const colorLike = !isImage && !urlLike && isColor(preview ?? '');
|
||||||
|
row.add_child(this._buildLeading(mimeType, preview, isImage, colorLike));
|
||||||
|
row.add_child(this._buildContent(preview, isImage, urlLike, colorLike));
|
||||||
|
|
||||||
// Center: text preview
|
|
||||||
row.add_child(this._buildContent(mimeType, preview));
|
|
||||||
|
|
||||||
// Right: delete button
|
|
||||||
const deleteBtn = new St.Button({
|
const deleteBtn = new St.Button({
|
||||||
style_class: 'strata-item-delete',
|
style_class: 'strata-item-delete',
|
||||||
icon_name: 'edit-delete-symbolic',
|
icon_name: 'edit-delete-symbolic',
|
||||||
|
|
@ -96,11 +91,11 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildLeading(mimeType, preview) {
|
_buildLeading(mimeType, preview, isImage, colorLike) {
|
||||||
if (mimeType.startsWith('image/')) {
|
if (isImage) {
|
||||||
return this._buildThumbnail(this._id);
|
return this._buildThumbnail(this._id);
|
||||||
}
|
}
|
||||||
if (isColor(preview)) {
|
if (colorLike) {
|
||||||
return this._buildColorSwatch(preview);
|
return this._buildColorSwatch(preview);
|
||||||
}
|
}
|
||||||
const icon = new St.Icon({
|
const icon = new St.Icon({
|
||||||
|
|
@ -112,10 +107,6 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Build an image thumbnail container.
|
|
||||||
* - If already in shared cache, apply immediately.
|
|
||||||
* - Else fetch via GetThumbnailRemote, write to ~/.cache/strata/thumbnails/{id}.png,
|
|
||||||
* then apply. The decode happens off-thread (CSS background-image loader). */
|
|
||||||
_buildThumbnail(id) {
|
_buildThumbnail(id) {
|
||||||
const container = new St.Widget({
|
const container = new St.Widget({
|
||||||
width: THUMB_SIZE,
|
width: THUMB_SIZE,
|
||||||
|
|
@ -131,22 +122,19 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
const applyStyle = () => {
|
const applyStyle = () => {
|
||||||
try {
|
try {
|
||||||
container.style = `background-image: url("${fileUri}"); background-size: cover; background-repeat: no-repeat;`;
|
container.style = `background-image: url("${fileUri}"); background-size: cover; background-repeat: no-repeat;`;
|
||||||
} catch (_) { /* container was destroyed mid-flight */ }
|
} catch { /* container was destroyed mid-flight */ }
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Fast path: already cached this session.
|
|
||||||
if (this._thumbCache?.has(id)) {
|
if (this._thumbCache?.has(id)) {
|
||||||
applyStyle();
|
applyStyle();
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
// Second fast path: file exists on disk from a previous session.
|
|
||||||
if (GLib.file_test(cachePath, GLib.FileTest.EXISTS)) {
|
if (GLib.file_test(cachePath, GLib.FileTest.EXISTS)) {
|
||||||
this._thumbCache?.set(id, cachePath);
|
this._thumbCache?.set(id, cachePath);
|
||||||
applyStyle();
|
applyStyle();
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
// Slow path: ask the daemon for the bytes, then write file async.
|
|
||||||
GLib.mkdir_with_parents(cacheDir, 0o755);
|
GLib.mkdir_with_parents(cacheDir, 0o755);
|
||||||
if (!this._proxy) {
|
if (!this._proxy) {
|
||||||
this._fallbackIcon(container);
|
this._fallbackIcon(container);
|
||||||
|
|
@ -172,18 +160,18 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
this._thumbCache?.set(id, cachePath);
|
this._thumbCache?.set(id, cachePath);
|
||||||
applyStyle();
|
applyStyle();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Thumbnail write error:', e);
|
logError('Thumbnail write error', e);
|
||||||
this._fallbackIcon(container);
|
this._fallbackIcon(container);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Thumbnail fetch handler error:', e);
|
logError('Thumbnail fetch handler error', e);
|
||||||
this._fallbackIcon(container);
|
this._fallbackIcon(container);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Thumbnail render error:', e);
|
logError('Thumbnail render error', e);
|
||||||
this._fallbackIcon(container);
|
this._fallbackIcon(container);
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
|
|
@ -199,7 +187,7 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
x_align: Clutter.ActorAlign.CENTER,
|
x_align: Clutter.ActorAlign.CENTER,
|
||||||
});
|
});
|
||||||
container.add_child(icon);
|
container.add_child(icon);
|
||||||
} catch (_) {}
|
} catch { /* container destroyed before the icon was added */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildColorSwatch(hex) {
|
_buildColorSwatch(hex) {
|
||||||
|
|
@ -212,7 +200,7 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_buildContent(mimeType, preview) {
|
_buildContent(preview, isImage, urlLike, colorLike) {
|
||||||
preview = preview ?? '';
|
preview = preview ?? '';
|
||||||
const box = new St.BoxLayout({
|
const box = new St.BoxLayout({
|
||||||
vertical: true,
|
vertical: true,
|
||||||
|
|
@ -220,20 +208,20 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
style_class: 'strata-item-content',
|
style_class: 'strata-item-content',
|
||||||
});
|
});
|
||||||
|
|
||||||
let mainText = '';
|
let mainText;
|
||||||
let subText = '';
|
let subText = '';
|
||||||
|
|
||||||
if (mimeType.startsWith('image/')) {
|
if (isImage) {
|
||||||
// Generic label - the thumbnail identifies the image, and the
|
// Generic label - the thumbnail identifies the image, and the
|
||||||
// on-clipboard format (often PNG even for a copied GIF/WebP) is an
|
// on-clipboard format (often PNG even for a copied GIF/WebP) is an
|
||||||
// implementation detail that misleads more than it informs.
|
// implementation detail that misleads more than it informs.
|
||||||
mainText = 'Image';
|
mainText = 'Image';
|
||||||
} else if (isUrl(preview)) {
|
} else if (urlLike) {
|
||||||
mainText = preview.trim();
|
mainText = preview.trim();
|
||||||
try {
|
try {
|
||||||
subText = new URL(preview.trim()).hostname;
|
subText = GLib.Uri.parse(preview.trim(), GLib.UriFlags.NONE).get_host() ?? '';
|
||||||
} catch (_) {}
|
} catch { /* not a parseable URI */ }
|
||||||
} else if (isColor(preview)) {
|
} else if (colorLike) {
|
||||||
mainText = preview.trim().toUpperCase();
|
mainText = preview.trim().toUpperCase();
|
||||||
subText = 'Color';
|
subText = 'Color';
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -245,7 +233,7 @@ export const ClipboardItem = GObject.registerClass({
|
||||||
|
|
||||||
const labelMain = new St.Label({
|
const labelMain = new St.Label({
|
||||||
text: mainText || '(empty)',
|
text: mainText || '(empty)',
|
||||||
style_class: `strata-item-text${isUrl(preview) ? ' strata-item-url' : ''}`,
|
style_class: `strata-item-text${urlLike ? ' strata-item-url' : ''}`,
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
y_align: Clutter.ActorAlign.CENTER,
|
y_align: Clutter.ActorAlign.CENTER,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
/* panel.js - Strata clipboard popup panel. */
|
/* panel.js - Strata clipboard popup panel. */
|
||||||
|
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
import Gio from 'gi://Gio';
|
|
||||||
import St from 'gi://St';
|
import St from 'gi://St';
|
||||||
import Clutter from 'gi://Clutter';
|
import Clutter from 'gi://Clutter';
|
||||||
import Meta from 'gi://Meta';
|
import Meta from 'gi://Meta';
|
||||||
|
|
@ -9,18 +8,18 @@ import Shell from 'gi://Shell';
|
||||||
|
|
||||||
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
|
||||||
import { ClipboardItem } from './clipboardItem.js';
|
import { ClipboardItem } from './clipboardItem.js';
|
||||||
|
import { logError } from '../util.js';
|
||||||
|
|
||||||
const SEARCH_DEBOUNCE_MS = 150;
|
const SEARCH_DEBOUNCE_MS = 150;
|
||||||
const LOAD_MORE_THRESHOLD = 200;
|
const LOAD_MORE_THRESHOLD = 200;
|
||||||
|
|
||||||
export class StrataPanel {
|
export class StrataPanel {
|
||||||
constructor(proxy, settings, indicator = null) {
|
constructor(proxy, settings) {
|
||||||
this._proxy = proxy;
|
this._proxy = proxy;
|
||||||
this._settings = settings;
|
this._settings = settings;
|
||||||
this._indicator = indicator; // PanelMenu.Button - used to avoid toggle-reopen race
|
|
||||||
this._pageSize = settings.get_int('page-size');
|
this._pageSize = settings.get_int('page-size');
|
||||||
this._pageSizeChangedId = settings.connect('changed::page-size',
|
settings.connectObject('changed::page-size',
|
||||||
() => { this._pageSize = settings.get_int('page-size'); });
|
() => { this._pageSize = settings.get_int('page-size'); }, this);
|
||||||
/** @type {{ id: string, mimeType: string, preview: string }[]} */
|
/** @type {{ id: string, mimeType: string, preview: string }[]} */
|
||||||
this._items = [];
|
this._items = [];
|
||||||
/** @type {Map<string, ClipboardItem>} id → widget */
|
/** @type {Map<string, ClipboardItem>} id → widget */
|
||||||
|
|
@ -29,7 +28,7 @@ export class StrataPanel {
|
||||||
this._thumbCache = new Map();
|
this._thumbCache = new Map();
|
||||||
/** Pagination state for the non-search view. */
|
/** Pagination state for the non-search view. */
|
||||||
this._loadedOffset = 0; // how many items we've already pulled
|
this._loadedOffset = 0; // how many items we've already pulled
|
||||||
this._hasMore = true; // false once daemon returns < PAGE_SIZE
|
this._hasMore = true; // false once daemon returns less than a full page
|
||||||
this._loadingMore = false; // re-entrancy guard for scroll-driven loads
|
this._loadingMore = false; // re-entrancy guard for scroll-driven loads
|
||||||
/** Search state. */
|
/** Search state. */
|
||||||
this._searchQuery = ''; // current search string ('' = no search)
|
this._searchQuery = ''; // current search string ('' = no search)
|
||||||
|
|
@ -46,16 +45,6 @@ export class StrataPanel {
|
||||||
|
|
||||||
this._buildUI();
|
this._buildUI();
|
||||||
|
|
||||||
// Theme: apply light/dark to the panel box and react to changes.
|
|
||||||
// The light.css overrides (loaded by extension.js) only take effect
|
|
||||||
// while the `.strata-theme-light` class is present on `_box`.
|
|
||||||
this._interfaceSettings = new Gio.Settings({ schema_id: 'org.gnome.desktop.interface' });
|
|
||||||
this._applyTheme();
|
|
||||||
this._themeChangedId = this._settings.connect('changed::theme',
|
|
||||||
() => this._applyTheme());
|
|
||||||
this._colorSchemeChangedId = this._interfaceSettings.connect('changed::color-scheme',
|
|
||||||
() => this._applyTheme());
|
|
||||||
|
|
||||||
// Trigger the initial load as soon as the daemon owns its bus name.
|
// Trigger the initial load as soon as the daemon owns its bus name.
|
||||||
// At extension boot the daemon may still be starting (its D-Bus name
|
// At extension boot the daemon may still be starting (its D-Bus name
|
||||||
// not yet owned); the proxy fires notify::g-name-owner when that
|
// not yet owned); the proxy fires notify::g-name-owner when that
|
||||||
|
|
@ -63,39 +52,21 @@ export class StrataPanel {
|
||||||
// and only then issue GetHistory. If the daemon is already up, the
|
// and only then issue GetHistory. If the daemon is already up, the
|
||||||
// owner is already set and we load immediately.
|
// owner is already set and we load immediately.
|
||||||
this._tryInitialLoad();
|
this._tryInitialLoad();
|
||||||
this._nameOwnerId = this._proxy.connect('notify::g-name-owner',
|
this._proxy.connectObject('notify::g-name-owner',
|
||||||
() => this._tryInitialLoad());
|
() => this._tryInitialLoad(), this);
|
||||||
}
|
|
||||||
|
|
||||||
/** True when the effective theme is light. `auto` follows the system
|
|
||||||
* color-scheme (anything other than prefer-dark counts as light). */
|
|
||||||
_effectiveIsLight() {
|
|
||||||
const mode = this._settings.get_string('theme');
|
|
||||||
if (mode === 'light') return true;
|
|
||||||
if (mode === 'dark') return false;
|
|
||||||
return this._interfaceSettings.get_string('color-scheme') !== 'prefer-dark';
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Toggle the light-theme class on the panel root box. */
|
|
||||||
_applyTheme() {
|
|
||||||
if (!this._box) return;
|
|
||||||
if (this._effectiveIsLight())
|
|
||||||
this._box.add_style_class_name('strata-theme-light');
|
|
||||||
else
|
|
||||||
this._box.remove_style_class_name('strata-theme-light');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_tryInitialLoad() {
|
_tryInitialLoad() {
|
||||||
if (this._initialLoaded) return;
|
if (this._initialLoaded) return;
|
||||||
if (!this._proxy.g_name_owner) return;
|
if (!this._proxy.g_name_owner) return;
|
||||||
this._initialLoaded = true;
|
this._initialLoaded = true;
|
||||||
this._loadHistory(0, this._pageSize).catch(e =>
|
this._loadHistory(0, this._pageSize).then(ok => {
|
||||||
console.error('[Strata] initial _loadHistory failed:', e));
|
if (!ok) this._initialLoaded = false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_buildUI() {
|
_buildUI() {
|
||||||
// Overlay container - sits above all windows.
|
|
||||||
this._overlay = new St.Widget({
|
this._overlay = new St.Widget({
|
||||||
layout_manager: new Clutter.FixedLayout(),
|
layout_manager: new Clutter.FixedLayout(),
|
||||||
visible: false,
|
visible: false,
|
||||||
|
|
@ -144,14 +115,12 @@ export class StrataPanel {
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Panel box
|
|
||||||
this._box = new St.BoxLayout({
|
this._box = new St.BoxLayout({
|
||||||
style_class: 'strata-panel',
|
style_class: 'strata-panel',
|
||||||
vertical: true,
|
vertical: true,
|
||||||
reactive: true,
|
reactive: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Header row: title + clear button
|
|
||||||
const header = new St.BoxLayout({
|
const header = new St.BoxLayout({
|
||||||
style_class: 'strata-header',
|
style_class: 'strata-header',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
|
|
@ -171,7 +140,6 @@ export class StrataPanel {
|
||||||
header.add_child(title);
|
header.add_child(title);
|
||||||
header.add_child(clearBtn);
|
header.add_child(clearBtn);
|
||||||
|
|
||||||
// Search box
|
|
||||||
this._searchEntry = new St.Entry({
|
this._searchEntry = new St.Entry({
|
||||||
hint_text: 'Search…',
|
hint_text: 'Search…',
|
||||||
style_class: 'strata-search',
|
style_class: 'strata-search',
|
||||||
|
|
@ -185,7 +153,6 @@ export class StrataPanel {
|
||||||
this._searchEntry.get_clutter_text().connect('text-changed', () => {
|
this._searchEntry.get_clutter_text().connect('text-changed', () => {
|
||||||
this._scheduleSearch(this._searchEntry.get_text());
|
this._scheduleSearch(this._searchEntry.get_text());
|
||||||
});
|
});
|
||||||
// Down arrow from search box moves focus to the first item.
|
|
||||||
this._searchEntry.get_clutter_text().connect('key-press-event', (_actor, event) => {
|
this._searchEntry.get_clutter_text().connect('key-press-event', (_actor, event) => {
|
||||||
if (event.get_key_symbol() === Clutter.KEY_Down) {
|
if (event.get_key_symbol() === Clutter.KEY_Down) {
|
||||||
this._focusItem(0);
|
this._focusItem(0);
|
||||||
|
|
@ -194,7 +161,6 @@ export class StrataPanel {
|
||||||
return Clutter.EVENT_PROPAGATE;
|
return Clutter.EVENT_PROPAGATE;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Item list
|
|
||||||
this._scrollView = new St.ScrollView({
|
this._scrollView = new St.ScrollView({
|
||||||
style_class: 'strata-scroll',
|
style_class: 'strata-scroll',
|
||||||
x_expand: true,
|
x_expand: true,
|
||||||
|
|
@ -208,21 +174,17 @@ export class StrataPanel {
|
||||||
});
|
});
|
||||||
this._scrollView.set_child(this._itemList);
|
this._scrollView.set_child(this._itemList);
|
||||||
|
|
||||||
// Load more items when scrolled near the bottom.
|
|
||||||
const vadj = this._scrollView.get_vadjustment();
|
const vadj = this._scrollView.get_vadjustment();
|
||||||
if (vadj) {
|
if (vadj) {
|
||||||
vadj.connect('notify::value', () => this._maybeLoadMore());
|
vadj.connect('notify::value', () => this._maybeLoadMore());
|
||||||
// Also re-check when the list grows (a new page just appended).
|
|
||||||
vadj.connect('notify::upper', () => this._maybeLoadMore());
|
vadj.connect('notify::upper', () => this._maybeLoadMore());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assemble
|
|
||||||
this._box.add_child(header);
|
this._box.add_child(header);
|
||||||
this._box.add_child(this._searchEntry);
|
this._box.add_child(this._searchEntry);
|
||||||
this._box.add_child(this._scrollView);
|
this._box.add_child(this._scrollView);
|
||||||
this._overlay.add_child(this._box);
|
this._overlay.add_child(this._box);
|
||||||
|
|
||||||
// ESC to close
|
|
||||||
this._overlay.connect('key-press-event', (_actor, event) => {
|
this._overlay.connect('key-press-event', (_actor, event) => {
|
||||||
if (event.get_key_symbol() === Clutter.KEY_Escape) {
|
if (event.get_key_symbol() === Clutter.KEY_Escape) {
|
||||||
this.close();
|
this.close();
|
||||||
|
|
@ -261,7 +223,7 @@ export class StrataPanel {
|
||||||
// retry now that the user is asking to see the list.
|
// retry now that the user is asking to see the list.
|
||||||
if (this._items.length === 0 && this._loadedOffset === 0 && this._hasMore) {
|
if (this._items.length === 0 && this._loadedOffset === 0 && this._hasMore) {
|
||||||
this._loadHistory(0, this._pageSize).catch(e =>
|
this._loadHistory(0, this._pageSize).catch(e =>
|
||||||
console.error('[Strata] open: history reload failed:', e));
|
logError('open: history reload failed', e));
|
||||||
}
|
}
|
||||||
global.stage.set_key_focus(this._searchEntry.get_clutter_text());
|
global.stage.set_key_focus(this._searchEntry.get_clutter_text());
|
||||||
}
|
}
|
||||||
|
|
@ -269,7 +231,6 @@ export class StrataPanel {
|
||||||
close() {
|
close() {
|
||||||
if (!this._visible) return;
|
if (!this._visible) return;
|
||||||
this._visible = false;
|
this._visible = false;
|
||||||
// Clear hover state since the panel is closing.
|
|
||||||
this._hoveredWidget?.remove_style_class_name('strata-item-hovered');
|
this._hoveredWidget?.remove_style_class_name('strata-item-hovered');
|
||||||
this._hoveredWidget = null;
|
this._hoveredWidget = null;
|
||||||
if (this._grab) {
|
if (this._grab) {
|
||||||
|
|
@ -291,17 +252,16 @@ export class StrataPanel {
|
||||||
this._widgets.delete(id);
|
this._widgets.delete(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// While searching, only render if the new item matches the active query.
|
|
||||||
if (this._searchQuery && !this._matchesSearch(preview, mimeType)) {
|
if (this._searchQuery && !this._matchesSearch(preview, mimeType)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const widget = this._makeItemWidget(id, mimeType, preview);
|
const widget = this._makeItemWidget(id, mimeType, preview);
|
||||||
this._widgets.set(id, widget);
|
this._widgets.set(id, widget);
|
||||||
this._itemList.insert_child_at_index(widget.actor, 0);
|
this._itemList.insert_child_at_index(widget, 0);
|
||||||
this._setActiveWidget(widget);
|
this._setActiveWidget(widget);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Strata] prependItem failed for id=${id} mime=${mimeType}:`, e);
|
logError(`prependItem failed for id=${id} mime=${mimeType}`, e);
|
||||||
this._items = this._items.filter(i => i.id !== id);
|
this._items = this._items.filter(i => i.id !== id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -318,6 +278,7 @@ export class StrataPanel {
|
||||||
|
|
||||||
removeItem(id) {
|
removeItem(id) {
|
||||||
this._items = this._items.filter(i => i.id !== id);
|
this._items = this._items.filter(i => i.id !== id);
|
||||||
|
this._thumbCache.delete(id);
|
||||||
// Keep the search snapshot in sync so a deleted/pruned item sitting in
|
// Keep the search snapshot in sync so a deleted/pruned item sitting in
|
||||||
// the not-yet-rendered tail can't be re-created as a phantom row when
|
// the not-yet-rendered tail can't be re-created as a phantom row when
|
||||||
// scrolling appends the next page. Adjust _searchRendered if the removed
|
// scrolling appends the next page. Adjust _searchRendered if the removed
|
||||||
|
|
@ -335,7 +296,6 @@ export class StrataPanel {
|
||||||
if (wasHovered) this._hoveredWidget = null;
|
if (wasHovered) this._hoveredWidget = null;
|
||||||
widget.destroy();
|
widget.destroy();
|
||||||
this._widgets.delete(id);
|
this._widgets.delete(id);
|
||||||
// Re-assign active to the new first visible item.
|
|
||||||
if (wasActive) {
|
if (wasActive) {
|
||||||
const first = this._getVisibleItems()[0];
|
const first = this._getVisibleItems()[0];
|
||||||
if (first) this._setActiveWidget(first);
|
if (first) this._setActiveWidget(first);
|
||||||
|
|
@ -351,27 +311,13 @@ export class StrataPanel {
|
||||||
this._hoveredWidget = null;
|
this._hoveredWidget = null;
|
||||||
this._activeWidget = null;
|
this._activeWidget = null;
|
||||||
this._widgets.clear();
|
this._widgets.clear();
|
||||||
|
this._thumbCache.clear();
|
||||||
this._itemList.destroy_all_children();
|
this._itemList.destroy_all_children();
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
if (this._pageSizeChangedId) {
|
this._settings.disconnectObject(this);
|
||||||
this._settings.disconnect(this._pageSizeChangedId);
|
this._proxy.disconnectObject(this);
|
||||||
this._pageSizeChangedId = 0;
|
|
||||||
}
|
|
||||||
if (this._themeChangedId) {
|
|
||||||
this._settings.disconnect(this._themeChangedId);
|
|
||||||
this._themeChangedId = 0;
|
|
||||||
}
|
|
||||||
if (this._colorSchemeChangedId && this._interfaceSettings) {
|
|
||||||
this._interfaceSettings.disconnect(this._colorSchemeChangedId);
|
|
||||||
this._colorSchemeChangedId = 0;
|
|
||||||
}
|
|
||||||
this._interfaceSettings = null;
|
|
||||||
if (this._nameOwnerId) {
|
|
||||||
this._proxy.disconnect(this._nameOwnerId);
|
|
||||||
this._nameOwnerId = 0;
|
|
||||||
}
|
|
||||||
if (this._searchDebounceId) {
|
if (this._searchDebounceId) {
|
||||||
GLib.Source.remove(this._searchDebounceId);
|
GLib.Source.remove(this._searchDebounceId);
|
||||||
this._searchDebounceId = null;
|
this._searchDebounceId = null;
|
||||||
|
|
@ -385,22 +331,23 @@ export class StrataPanel {
|
||||||
|
|
||||||
|
|
||||||
async _loadHistory(offset, limit) {
|
async _loadHistory(offset, limit) {
|
||||||
if (!this._overlay) return 0;
|
if (!this._overlay) return false;
|
||||||
try {
|
try {
|
||||||
const [json] = await this._proxy.GetHistoryAsync(offset, limit);
|
const [json] = await this._proxy.GetHistoryAsync(offset, limit);
|
||||||
if (!this._overlay) return 0;
|
if (!this._overlay) return false;
|
||||||
const items = JSON.parse(json);
|
const items = JSON.parse(json);
|
||||||
const BATCH = 20;
|
const BATCH = 20;
|
||||||
for (let i = 0; i < items.length; i += BATCH) {
|
for (let i = 0; i < items.length; i += BATCH) {
|
||||||
if (!this._overlay) return items.length;
|
if (!this._overlay) return false;
|
||||||
await new Promise(resolve =>
|
// eslint-disable-next-line no-await-in-loop -- batches deliberately yield to the main loop
|
||||||
|
await new Promise(resolve => {
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||||
const end = Math.min(i + BATCH, items.length);
|
const end = Math.min(i + BATCH, items.length);
|
||||||
for (let j = i; j < end; j++) this._appendItemFromMeta(items[j]);
|
for (let j = i; j < end; j++) this._appendItemFromMeta(items[j]);
|
||||||
resolve();
|
resolve();
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
})
|
});
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
this._loadedOffset = offset + items.length;
|
this._loadedOffset = offset + items.length;
|
||||||
this._hasMore = items.length >= limit;
|
this._hasMore = items.length >= limit;
|
||||||
|
|
@ -408,10 +355,10 @@ export class StrataPanel {
|
||||||
const firstWidget = this._widgets.get(items[0].id);
|
const firstWidget = this._widgets.get(items[0].id);
|
||||||
if (firstWidget) this._setActiveWidget(firstWidget);
|
if (firstWidget) this._setActiveWidget(firstWidget);
|
||||||
}
|
}
|
||||||
return items.length;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] _loadHistory failed:', e);
|
logError('GetHistory failed', e);
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -425,9 +372,9 @@ export class StrataPanel {
|
||||||
this._items.push({ id, mimeType, preview });
|
this._items.push({ id, mimeType, preview });
|
||||||
const widget = this._makeItemWidget(id, mimeType, preview);
|
const widget = this._makeItemWidget(id, mimeType, preview);
|
||||||
this._widgets.set(id, widget);
|
this._widgets.set(id, widget);
|
||||||
this._itemList.add_child(widget.actor);
|
this._itemList.add_child(widget);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(`[Strata] _appendItemFromMeta failed for id=${meta?.id}:`, e);
|
logError(`_appendItemFromMeta failed for id=${meta?.id}`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -443,7 +390,6 @@ export class StrataPanel {
|
||||||
// snapshot (no re-query, so a scroll cannot race the search).
|
// snapshot (no re-query, so a scroll cannot race the search).
|
||||||
this._renderSearchPage(this._searchEpoch);
|
this._renderSearchPage(this._searchEpoch);
|
||||||
} else {
|
} else {
|
||||||
// Browse mode: pull the next page from the daemon.
|
|
||||||
if (!this._hasMore) return;
|
if (!this._hasMore) return;
|
||||||
this._loadingMore = true;
|
this._loadingMore = true;
|
||||||
this._loadHistory(this._loadedOffset, this._pageSize)
|
this._loadHistory(this._loadedOffset, this._pageSize)
|
||||||
|
|
@ -475,21 +421,19 @@ export class StrataPanel {
|
||||||
for (let j = i; j < e; j++)
|
for (let j = i; j < e; j++)
|
||||||
this._appendItemFromMeta(this._searchResults[j]);
|
this._appendItemFromMeta(this._searchResults[j]);
|
||||||
};
|
};
|
||||||
// The very first chunk of a fresh render (start === 0, right after
|
// First chunk runs synchronously so the list never paints empty
|
||||||
// _clearListDom) is rendered synchronously, in the same frame as
|
// between clear and first append. Later chunks yield to idle.
|
||||||
// the clear, so the list never paints empty in between - that
|
|
||||||
// empty frame is the "blink" seen while typing a search. Later
|
|
||||||
// chunks (and scroll-driven pages) yield to idle to keep frames
|
|
||||||
// light.
|
|
||||||
if (i === 0) {
|
if (i === 0) {
|
||||||
renderChunk();
|
renderChunk();
|
||||||
} else {
|
} else {
|
||||||
await new Promise(resolve =>
|
// eslint-disable-next-line no-await-in-loop -- batches deliberately yield to the main loop
|
||||||
|
await new Promise(resolve => {
|
||||||
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
GLib.idle_add(GLib.PRIORITY_DEFAULT_IDLE, () => {
|
||||||
renderChunk();
|
renderChunk();
|
||||||
resolve();
|
resolve();
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._searchRendered = end;
|
this._searchRendered = end;
|
||||||
|
|
@ -545,14 +489,12 @@ export class StrataPanel {
|
||||||
return widget;
|
return widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Focus the item at visible-list index `idx` (clamped). */
|
|
||||||
_focusItem(idx) {
|
_focusItem(idx) {
|
||||||
const items = this._getVisibleItems();
|
const items = this._getVisibleItems();
|
||||||
if (items.length === 0) return;
|
if (items.length === 0) return;
|
||||||
global.stage.set_key_focus(items[Math.max(0, Math.min(idx, items.length - 1))]);
|
global.stage.set_key_focus(items[Math.max(0, Math.min(idx, items.length - 1))]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** All currently-visible item actors in order. */
|
|
||||||
_getVisibleItems() {
|
_getVisibleItems() {
|
||||||
return this._itemList.get_children().filter(c => c.visible);
|
return this._itemList.get_children().filter(c => c.visible);
|
||||||
}
|
}
|
||||||
|
|
@ -574,7 +516,7 @@ export class StrataPanel {
|
||||||
else if (box.y2 > cur + pageSize)
|
else if (box.y2 > cur + pageSize)
|
||||||
adj.value = box.y2 - pageSize;
|
adj.value = box.y2 - pageSize;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] ensureVisible error:', e);
|
logError('ensureVisible error', e);
|
||||||
}
|
}
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
});
|
});
|
||||||
|
|
@ -585,7 +527,7 @@ export class StrataPanel {
|
||||||
const [mimeType, content] = await this._proxy.GetItemContentAsync(id);
|
const [mimeType, content] = await this._proxy.GetItemContentAsync(id);
|
||||||
this._writeToClipboard(mimeType, content);
|
this._writeToClipboard(mimeType, content);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Paste error:', e);
|
logError('GetItemContent failed', e);
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
@ -606,7 +548,7 @@ export class StrataPanel {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] Clipboard write error:', e);
|
logError('Clipboard write error', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -614,7 +556,7 @@ export class StrataPanel {
|
||||||
try {
|
try {
|
||||||
await this._proxy.ClearHistoryAsync();
|
await this._proxy.ClearHistoryAsync();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] ClearHistory error:', e);
|
logError('ClearHistory failed', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -629,7 +571,7 @@ export class StrataPanel {
|
||||||
GLib.PRIORITY_DEFAULT, SEARCH_DEBOUNCE_MS, () => {
|
GLib.PRIORITY_DEFAULT, SEARCH_DEBOUNCE_MS, () => {
|
||||||
this._searchDebounceId = null;
|
this._searchDebounceId = null;
|
||||||
this._runSearch(trimmed).catch(e =>
|
this._runSearch(trimmed).catch(e =>
|
||||||
console.error('[Strata] search failed:', e));
|
logError('search failed', e));
|
||||||
return GLib.SOURCE_REMOVE;
|
return GLib.SOURCE_REMOVE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -663,7 +605,7 @@ export class StrataPanel {
|
||||||
this._clearListDom();
|
this._clearListDom();
|
||||||
this._items = [];
|
this._items = [];
|
||||||
}
|
}
|
||||||
}).catch(e => console.error('[Strata] reset-history failed:', e));
|
}).catch(e => logError('reset-history failed', e));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -675,7 +617,7 @@ export class StrataPanel {
|
||||||
try {
|
try {
|
||||||
[json] = await this._proxy.SearchHistoryAsync(query, limit);
|
[json] = await this._proxy.SearchHistoryAsync(query, limit);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] SearchHistory D-Bus error:', e);
|
logError('SearchHistory failed', e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (epoch !== this._searchEpoch || !this._overlay) return; // stale or destroyed
|
if (epoch !== this._searchEpoch || !this._overlay) return; // stale or destroyed
|
||||||
|
|
@ -684,7 +626,7 @@ export class StrataPanel {
|
||||||
try {
|
try {
|
||||||
results = JSON.parse(json);
|
results = JSON.parse(json);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('[Strata] SearchHistory: bad JSON:', e);
|
logError('SearchHistory: bad JSON', e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -719,13 +661,11 @@ export class StrataPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
_moveItemToTop(id, widget) {
|
_moveItemToTop(id, widget) {
|
||||||
// Move data model entry to front.
|
|
||||||
const idx = this._items.findIndex(i => i.id === id);
|
const idx = this._items.findIndex(i => i.id === id);
|
||||||
if (idx > 0) {
|
if (idx > 0) {
|
||||||
const [entry] = this._items.splice(idx, 1);
|
const [entry] = this._items.splice(idx, 1);
|
||||||
this._items.unshift(entry);
|
this._items.unshift(entry);
|
||||||
}
|
}
|
||||||
// Move actor to position 0 in the list.
|
|
||||||
this._itemList.set_child_at_index(widget, 0);
|
this._itemList.set_child_at_index(widget, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -752,7 +692,6 @@ export class StrataPanel {
|
||||||
const MARGIN = 16; // px gap from screen edge
|
const MARGIN = 16; // px gap from screen edge
|
||||||
|
|
||||||
let x, y;
|
let x, y;
|
||||||
// Horizontal
|
|
||||||
if (position.endsWith('left'))
|
if (position.endsWith('left'))
|
||||||
x = monitor.x + MARGIN;
|
x = monitor.x + MARGIN;
|
||||||
else if (position.endsWith('right'))
|
else if (position.endsWith('right'))
|
||||||
|
|
|
||||||
11
strata@edu4rdshl.dev/util.js
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
/* util.js - shared helpers for the Strata extension. */
|
||||||
|
|
||||||
|
import GLib from 'gi://GLib';
|
||||||
|
import Gio from 'gi://Gio';
|
||||||
|
|
||||||
|
export function logError(label, err) {
|
||||||
|
if (err instanceof GLib.Error)
|
||||||
|
Gio.DBusError.strip_remote_error(err);
|
||||||
|
const tail = err !== undefined ? `: ${err?.message ?? err}` : '';
|
||||||
|
console.error(`[Strata] ${label}${tail}`);
|
||||||
|
}
|
||||||