Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf16d427b8 | ||
|
|
4f055935d4 | ||
|
|
63179b9c47 | ||
|
|
d1df30d6d0 | ||
|
|
9953865128 | ||
|
|
03a3c681b0 | ||
|
|
1c6a536026 | ||
|
|
42ffe9c492 | ||
|
|
856f8d8bf4 | ||
|
|
eea3a78140 | ||
|
|
8c319cffc6 | ||
|
|
450a20bf63 | ||
|
|
6af81b587c | ||
|
|
c033335912 | ||
|
|
01af00b5ea | ||
|
|
2bed8b7fac | ||
|
|
1367bd8591 | ||
|
|
1156b3503a | ||
|
|
d80a64444f | ||
|
|
456d61de01 | ||
|
|
ab2655556f | ||
|
|
f0331e65b1 | ||
|
|
25c7322c4b | ||
|
|
7af5c34856 | ||
|
|
e8def40fae | ||
|
|
34591f2677 | ||
|
|
91c26b9d54 | ||
|
|
70e53c1246 | ||
|
|
b2ae30bab4 | ||
|
|
2538e41f00 | ||
|
|
3eb7cddb6c | ||
|
|
2813ae0eff | ||
|
|
1b1ffc4435 | ||
|
|
cf9fabb052 | ||
|
|
43fe73bf09 | ||
|
|
d291e36b3f | ||
|
|
fe37c15f95 | ||
|
|
d4f62da6f5 | ||
|
|
1edefd9cad | ||
|
|
90ffa7df27 | ||
|
|
d69e941ec1 | ||
|
|
5e5e8876f6 | ||
|
|
886d595f91 | ||
|
|
e04237b928 | ||
|
|
ef84c519a2 | ||
|
|
1e647c7036 | ||
|
|
56f6b1668d | ||
|
|
4c49407849 | ||
|
|
07d8066d90 | ||
|
|
ee2646f091 | ||
|
|
89eafe5bc7 | ||
|
|
bd9106c5ee | ||
|
|
2e49b98b82 | ||
|
|
12ea4e7f60 | ||
|
|
91fdfcd2b6 | ||
|
|
2c8b27bb5a | ||
|
|
f6cebdeba4 | ||
|
|
3b9aed089c | ||
|
|
20e08f74ee | ||
|
|
89c5aeb01d | ||
|
|
f1811475cd | ||
|
|
f25909b7f8 | ||
|
|
6690cda29f | ||
|
|
76e9d267df | ||
|
|
50ac4a89f5 | ||
|
|
376a6f215b | ||
|
|
24ec63a178 | ||
|
|
2f61da8690 | ||
|
|
48985c470a | ||
|
|
1a62696662 | ||
|
|
becd676352 | ||
|
|
f546cfa194 | ||
|
|
319bcdd355 | ||
|
|
300711affe | ||
|
|
c380d20794 | ||
|
|
833f289cd0 | ||
|
|
0577c023b8 | ||
|
|
460b63555a | ||
|
|
aec80d1afd | ||
|
|
0a5c4a386a | ||
|
|
8877674f43 | ||
|
|
d6b53be516 | ||
|
|
cf37611243 | ||
|
|
5191952155 | ||
|
|
193f1d59fa | ||
|
|
809af580a9 | ||
|
|
2ba19f9e64 | ||
|
|
9233128b7c | ||
|
|
b51fc8a1b0 | ||
|
|
0de3da162b | ||
|
|
510ad34183 | ||
|
|
c676c0223b | ||
|
|
29252cbbc6 | ||
|
|
c695288d1e | ||
|
|
c02937d8b6 | ||
|
|
b9ff6725cd | ||
|
|
3572d22ba8 | ||
|
|
50e2ab25a5 | ||
|
|
a1e36d9ac5 | ||
|
|
1ae11bab29 | ||
|
|
4e9f0e566f | ||
|
|
4ca4fa307a | ||
|
|
f2999fb53f | ||
|
|
b94e80c346 | ||
|
|
c5cc36b7cf | ||
|
|
14388085cb | ||
|
|
9908392af1 | ||
|
|
d10883169f | ||
|
|
d419946959 | ||
|
|
6679418696 | ||
|
|
61ad3e4d94 | ||
|
|
89d96e28ac | ||
|
|
b53a909e1c | ||
|
|
4053bb8973 | ||
|
|
5555c3c787 | ||
|
|
3b4c9267bb | ||
|
|
2bad68a8cf | ||
|
|
d41e338dfb | ||
|
|
46a1c9e701 | ||
|
|
bbfdb56d70 | ||
|
|
3dd09ca589 | ||
|
|
2d1d9d45d3 | ||
|
|
640165d8cc | ||
|
|
70bc9238c5 | ||
|
|
fa759c304a | ||
|
|
6deffa91bb | ||
|
|
1cadf43d49 | ||
|
|
560f92a64e | ||
|
|
2f9534f75f | ||
|
|
4bc58623b7 | ||
|
|
eec74ca750 | ||
|
|
2bb0a2f29f | ||
|
|
e9decaa594 | ||
|
|
c10e312b51 | ||
|
|
6e3bd0c4a8 | ||
|
|
9c3bfb627e | ||
|
|
a7011558b0 | ||
|
|
92acc7c356 | ||
|
|
e81a51416e | ||
|
|
19df29d7e0 | ||
|
|
461b34e5cb | ||
|
|
bb6c540441 | ||
|
|
ec2cfff9c4 | ||
|
|
18c93ec538 | ||
|
|
ea2fd4b701 | ||
|
|
37fcb7390b | ||
|
|
c5d7faceba | ||
|
|
ee4fe479d0 | ||
|
|
0896290411 | ||
|
|
0d8facbb01 | ||
|
|
a8c5c59b22 | ||
|
|
b72c8e9cd9 | ||
|
|
e63a28abb7 | ||
|
|
11fd9a79c3 | ||
|
|
4e48df376b | ||
|
|
fbc1f058ad | ||
|
|
840c8496ab | ||
|
|
0b5a6f6538 | ||
|
|
7845d64313 | ||
|
|
9329a1ebd8 | ||
|
|
b6bff9e9df | ||
|
|
095c2c9aef | ||
|
|
22893fd681 | ||
|
|
beb6cb2f08 | ||
|
|
5cc4a6e740 | ||
|
|
a4f661ffa7 | ||
|
|
339b069354 | ||
|
|
ca0e646564 | ||
|
|
9116399ddd | ||
|
|
c135f37b45 | ||
|
|
f6bc4c6bbb | ||
|
|
14ca00a866 | ||
|
|
f33bc883e3 | ||
|
|
cee182df50 | ||
|
|
354558e592 | ||
|
|
9ea990d3c6 | ||
|
|
fa9716bc64 | ||
|
|
6f474a9a77 | ||
|
|
e84ebf36dc | ||
|
|
f351d183d3 | ||
|
|
52f4ae3cbf | ||
|
|
a2bc6190ce | ||
|
|
a52bc3f126 | ||
|
|
1b8c041151 | ||
|
|
331cc930ca | ||
|
|
a5a7a6937c | ||
|
|
a1b1bb01ff | ||
|
|
7e74b2e3ac | ||
|
|
5c50e294ff | ||
|
|
7bfd708399 | ||
|
|
bdcf83d1c2 | ||
|
|
bc16514f05 | ||
|
|
734a7bf04a | ||
|
|
a3d4709472 | ||
|
|
0cee090fa2 | ||
|
|
9ac29b2a94 | ||
|
|
14a1611e9e | ||
|
|
e426e1f884 | ||
|
|
b87bcd8cc9 | ||
|
|
a293b5914a | ||
|
|
247a56edf5 | ||
|
|
bf0a3617a6 | ||
|
|
dea9378d8d | ||
|
|
0a4e0829b9 | ||
|
|
9d2dd4ec37 | ||
|
|
247286fc5e |
+16
@@ -0,0 +1,16 @@
|
||||
image: archlinux
|
||||
packages:
|
||||
- rust
|
||||
- libpulse
|
||||
- alsa-lib
|
||||
- fontconfig
|
||||
- libxkbcommon
|
||||
sources:
|
||||
- https://git.sr.ht/~kennylevinsen/wldash
|
||||
tasks:
|
||||
- rustfmt-check: |
|
||||
cd wldash
|
||||
cargo fmt -- --check
|
||||
- build: |
|
||||
cd wldash
|
||||
cargo build
|
||||
@@ -0,0 +1,114 @@
|
||||
name: Release
|
||||
|
||||
# A `v*` tag builds the package on each architecture's own runner
|
||||
# (x86_64 on ergo's bare runner, aarch64 on klokka's) and uploads it
|
||||
# to the [uhhm] Arch registry, like uhhm/gdo and bl/djdeck. Hosts then
|
||||
# `pacman -S wldash`. The tag has to agree with PKGBUILD's pkgver and
|
||||
# Cargo.toml's version, and CHANGELOG.md has to have the section; a
|
||||
# release with the tag's notes is created from the x86_64 job.
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
jobs:
|
||||
package:
|
||||
strategy:
|
||||
matrix:
|
||||
include:
|
||||
- arch: x86_64
|
||||
runs-on: bare
|
||||
# The bare runner's shared toolchain and caches, with the
|
||||
# writable cargo home uhhm/iris and uhhm/gdo use.
|
||||
cargo_home: /var/local/cargo-target/iris-cargo-home
|
||||
rustc_wrapper: /usr/bin/sccache
|
||||
rustup_home: /var/local/rustup
|
||||
target_dir: /var/local/cargo-target
|
||||
- arch: aarch64
|
||||
runs-on: aarch64
|
||||
# klokka's host runner: rustup's stable (step below), defaults everywhere.
|
||||
cargo_home: ""
|
||||
rustc_wrapper: ""
|
||||
rustup_home: ""
|
||||
target_dir: ""
|
||||
runs-on: ${{ matrix.runs-on }}
|
||||
env:
|
||||
CARGO_HOME: ${{ matrix.cargo_home }}
|
||||
RUSTC_WRAPPER: ${{ matrix.rustc_wrapper }}
|
||||
RUSTUP_HOME: ${{ matrix.rustup_home }}
|
||||
CARGO_TARGET_DIR: ${{ matrix.target_dir }}
|
||||
PATH: /var/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/bin
|
||||
SCCACHE_DIR: /var/local/sccache
|
||||
SCCACHE_SERVER_PORT: "4228"
|
||||
steps:
|
||||
# v4 built-in checkout: native Go, needs no Node (the aarch64 host runner
|
||||
# has none) and keeps the token out of a fetch URL.
|
||||
- name: Checkout
|
||||
uses: builtin:checkout
|
||||
|
||||
# klokka's runner has rustup but no default toolchain, so its cargo
|
||||
# proxy refuses to run without this.
|
||||
- name: Install Rust stable (aarch64)
|
||||
if: matrix.arch == 'aarch64'
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Check tag matches pkgver and Cargo.toml
|
||||
run: |
|
||||
want="${GITHUB_REF_NAME#v}"
|
||||
have=$(sed -n 's/^pkgver=//p' PKGBUILD)
|
||||
[ "$want" = "$have" ] || { echo "tag $GITHUB_REF_NAME != pkgver $have" >&2; exit 1; }
|
||||
cargo_ver=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
|
||||
[ "$want" = "$cargo_ver" ] || { echo "tag $GITHUB_REF_NAME != Cargo.toml version $cargo_ver" >&2; exit 1; }
|
||||
notes=$(awk -v v="$want" '/^## /{p = ($2 == v)} p' CHANGELOG.md | tail -n +2)
|
||||
[ -n "$(printf "%s" "$notes" | tr -d "[:space:]")" ] || { echo "CHANGELOG.md has no section for $GITHUB_REF_NAME" >&2; exit 1; }
|
||||
|
||||
# Bare runners are never mutated by CI: wldash's system libraries
|
||||
# (dbus, libpulse, libxkbcommon, fontconfig, wayland) must already be
|
||||
# installed on the host. Fail loud if one is missing.
|
||||
- name: Check system build deps
|
||||
run: |
|
||||
missing=""
|
||||
for lib in dbus-1 libpulse xkbcommon fontconfig wayland-client; do
|
||||
pkg-config --exists "$lib" || missing="$missing $lib"
|
||||
done
|
||||
[ -z "$missing" ] || { echo "::error::bare runner missing:$missing — install once on the host" >&2; exit 1; }
|
||||
|
||||
# -d: cargo is the shared toolchain, not a pacman package the
|
||||
# runner could verify. Builds and tests from the checkout. Empty
|
||||
# env values above are unset here so cargo's defaults apply.
|
||||
- name: Build package
|
||||
run: |
|
||||
for v in CARGO_HOME RUSTC_WRAPPER RUSTUP_HOME CARGO_TARGET_DIR; do
|
||||
eval "[ -n \"\$$v\" ]" || unset "$v"
|
||||
done
|
||||
makepkg -f -d --noconfirm
|
||||
|
||||
# REGISTRY_TOKEN is a write:package token for bl, a secret on this
|
||||
# repo. The registry namespace is always bl: pacman.conf's [uhhm]
|
||||
# points at /api/packages/bl/arch/uhhm. Without the secret the build
|
||||
# still runs so the tag is verified; re-run the job once it is set.
|
||||
- name: Publish to the Arch package registry
|
||||
run: |
|
||||
set -euo pipefail
|
||||
if [ -z "${{ secrets.REGISTRY_TOKEN }}" ]; then
|
||||
echo "::warning::REGISTRY_TOKEN not set — skipping Arch registry publish"
|
||||
exit 0
|
||||
fi
|
||||
for pkg in $(makepkg --packagelist); do
|
||||
echo "==> $pkg"
|
||||
curl --fail-with-body --user "bl:${{ secrets.REGISTRY_TOKEN }}" \
|
||||
--upload-file "$pkg" \
|
||||
"${{ gitea.server_url }}/api/packages/bl/arch/uhhm"
|
||||
done
|
||||
|
||||
- name: Release notes
|
||||
if: matrix.arch == 'x86_64'
|
||||
run: |
|
||||
set -euo pipefail
|
||||
tag="${{ github.ref_name }}"
|
||||
api="${{ github.server_url }}/api/v1/repos/${{ github.repository }}"
|
||||
auth="Authorization: token ${{ secrets.GITHUB_TOKEN }}"
|
||||
notes=$(awk -v v="${tag#v}" '/^## /{p = ($2 == v)} p' CHANGELOG.md | tail -n +2)
|
||||
body=$(jq -n --arg tag "$tag" --arg notes "$notes" '{tag_name: $tag, name: $tag, body: $notes}')
|
||||
curl -sf -X POST -H "$auth" -H 'Content-Type: application/json' -d "$body" "$api/releases" > /dev/null \
|
||||
|| echo "release $tag exists"
|
||||
@@ -0,0 +1,3 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
liberapay: kennylevinsen
|
||||
@@ -0,0 +1,33 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 0.4.3 (2026-10-05)
|
||||
|
||||
- Backlight: a config with a `!backlight` widget on a machine without `/sys/class/backlight` entries (or with a `device` name that does not exist) panicked at start ("did not find backlight device"), fatal with `panic = "abort"`. The widget now warns once on stderr, renders empty and ignores clicks, so one config can be shared between a laptop and a desktop.
|
||||
|
||||
## 0.4.2 (2026-10-03)
|
||||
|
||||
- Fonts: a `font_paths` entry pointing at a file that does not exist on this machine made the font-loader thread panic and abort wldash ("Font file not found"). Pinned paths that are missing now fall back to fontconfig by name, with one line on stderr; a font that cannot be resolved at all exits with a clear message instead of a backtrace.
|
||||
- `--write-default-config` no longer writes absolute font paths. Configs shared between machines with different font package layouts (`fonts/noto` vs `fonts/google-noto`) were breaking on the second host; names are resolved per machine instead. Existing configs keep working, and `font_paths` can still pin a file on purpose.
|
||||
|
||||
## 0.4.1 (2026-10-03)
|
||||
|
||||
- No more desktop-file cache: wldash scanned `~/.cache/wldash/desktop.json` (on NFS for shared homes, and stale after every package install) and needed a manual `--desktop-refresh`. Desktop files are now scanned on a background thread at every start, a few milliseconds over local `/usr/share`. `--desktop-refresh` is a no-op kept for key bindings; `simd-json` is gone.
|
||||
- Calculator history and the Escape-saved prompt moved from `$XDG_CACHE_HOME/wldash` to `$XDG_STATE_HOME/wldash` (`~/.local/state`), where small roaming state belongs; old files are still read.
|
||||
- Launcher: `Type=Link` entries open their URL with `xdg-open`; `Terminal=true` entries run inside `$TERMINAL -e` when that variable is set.
|
||||
|
||||
## 0.4.0 (2026-10-03)
|
||||
|
||||
First release of the project.uhhm.no fork, packaged for the `[uhhm]` Arch registry. Numbering: upstream's old code base was tagged up to v0.3.0 and the rewrite called itself 0.2.0; this fork continues above both so pacman sees a monotonic version.
|
||||
|
||||
- Launcher: the prompt cursor was a byte offset in some places and a grapheme index in others, so typing æøå and then End or another key crashed wldash. The cursor is grapheme-based everywhere, Up stops at the last row, mouse selection can't underflow, and all desktop Exec field codes (`%i`, `%c`, `%k`, `%%`, ...) are stripped.
|
||||
- No more aborting on machines without a backlight, battery or PulseAudio: `/sys/class/backlight` itself was taken for a device, UPower's always-present DisplayDevice for a battery, and a failed audio connection panicked a thread (fatal with `panic = "abort"`).
|
||||
- Redraws: `Geometry::expand` computed the damage height from the wrong field; buffer refcounts no longer underflow; `wl_shm_pool`s are destroyed on resize.
|
||||
- Input: a key-repeat rate of 0 divided by zero; Escape is now seen by the launcher first so the prompt is saved for Ctrl+R; the first layer-surface configure always lays out.
|
||||
- Config: `/etc/wldash/config.yml` takes precedence over `~/.config/wldash/config.yml` when present (machine-local layout on NFS-shared homes); `--config` overrides both. Errors print one line and exit 1 instead of panicking.
|
||||
- Housekeeping: `memmap` → `memmap2`, unused `shlex` dropped, zero rustc/clippy warnings, rustfmt applied, unit tests for the prompt, Exec parsing and geometry.
|
||||
|
||||
## 0.2.0
|
||||
|
||||
Upstream (kennylevinsen/wldash) rewrite, the state this fork started from.
|
||||
Generated
+4
-236
@@ -8,18 +8,6 @@ version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
|
||||
|
||||
[[package]]
|
||||
name = "ahash"
|
||||
version = "0.8.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"version_check",
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "android-tzdata"
|
||||
version = "0.1.1"
|
||||
@@ -188,15 +176,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "float-cmp"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fontconfig"
|
||||
version = "0.8.0"
|
||||
@@ -225,38 +204,6 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "halfbrown"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5681137554ddff44396e5f149892c769d45301dd9aa19c51602a89ee214cb0ec"
|
||||
dependencies = [
|
||||
"hashbrown 0.13.2",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.14.3"
|
||||
@@ -299,7 +246,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "433de089bd45971eecf4668ee0ee8f4cec17db4f8bd8f7bc3197a6ce37aa7d9b"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.3",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -334,70 +281,6 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "lexical-core"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46"
|
||||
dependencies = [
|
||||
"lexical-parse-float",
|
||||
"lexical-parse-integer",
|
||||
"lexical-util",
|
||||
"lexical-write-float",
|
||||
"lexical-write-integer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-parse-float"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f"
|
||||
dependencies = [
|
||||
"lexical-parse-integer",
|
||||
"lexical-util",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-parse-integer"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9"
|
||||
dependencies = [
|
||||
"lexical-util",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-util"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5255b9ff16ff898710eb9eb63cb39248ea8a5bb036bea8085b1a767ff6c4e3fc"
|
||||
dependencies = [
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-write-float"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862"
|
||||
dependencies = [
|
||||
"lexical-util",
|
||||
"lexical-write-integer",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lexical-write-integer"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446"
|
||||
dependencies = [
|
||||
"lexical-util",
|
||||
"static_assertions",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.152"
|
||||
@@ -462,16 +345,6 @@ version = "2.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
||||
|
||||
[[package]]
|
||||
name = "memmap"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memmap2"
|
||||
version = "0.9.5"
|
||||
@@ -703,26 +576,6 @@ dependencies = [
|
||||
"pest_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref-cast"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4846d4c50d1721b1a3bef8af76924eef20d5e723647333798c1b519b3a9473f"
|
||||
dependencies = [
|
||||
"ref-cast-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ref-cast-impl"
|
||||
version = "1.0.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fddb4f8d99b0a2ebafc65a87a69a7b9875e4b1ae1f00db265d300ef7f28bccc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rusttype"
|
||||
version = "0.9.3"
|
||||
@@ -774,17 +627,6 @@ dependencies = [
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.113"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_yaml"
|
||||
version = "0.9.31"
|
||||
@@ -809,34 +651,6 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "simd-json"
|
||||
version = "0.13.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2faf8f101b9bc484337a6a6b0409cf76c139f2fb70a9e3aee6b6774be7bfbf76"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"halfbrown",
|
||||
"lexical-core",
|
||||
"ref-cast",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"simdutf8",
|
||||
"value-trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simdutf8"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f27f6278552951f1f2b8cf9da965d10969b2efdea95a6ec47987ab46edfe263a"
|
||||
|
||||
[[package]]
|
||||
name = "slotmap"
|
||||
version = "1.0.7"
|
||||
@@ -852,12 +666,6 @@ version = "1.13.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
|
||||
|
||||
[[package]]
|
||||
name = "static_assertions"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.109"
|
||||
@@ -946,18 +754,6 @@ version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab4c90930b95a82d00dc9e9ac071b4991924390d46cbd0dfe566148667605e4b"
|
||||
|
||||
[[package]]
|
||||
name = "value-trait"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dad8db98c1e677797df21ba03fca7d3bf9bec3ca38db930954e4fe6e1ea27eb4"
|
||||
dependencies = [
|
||||
"float-cmp",
|
||||
"halfbrown",
|
||||
"itoa",
|
||||
"ryu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
@@ -980,12 +776,6 @@ dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.90"
|
||||
@@ -1280,8 +1070,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04"
|
||||
|
||||
[[package]]
|
||||
name = "wldash2"
|
||||
version = "0.1.0"
|
||||
name = "wldash"
|
||||
version = "0.4.3"
|
||||
dependencies = [
|
||||
"calloop",
|
||||
"chrono",
|
||||
@@ -1289,14 +1079,12 @@ dependencies = [
|
||||
"fontconfig",
|
||||
"fuzzy-matcher",
|
||||
"libpulse-binding",
|
||||
"memmap",
|
||||
"memmap2",
|
||||
"nix 0.26.4",
|
||||
"rcalc_lib",
|
||||
"rusttype",
|
||||
"serde",
|
||||
"serde_yaml",
|
||||
"shlex",
|
||||
"simd-json",
|
||||
"unicode-segmentation",
|
||||
"walkdir",
|
||||
"wayland-client",
|
||||
@@ -1333,23 +1121,3 @@ dependencies = [
|
||||
"once_cell",
|
||||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.7.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
|
||||
dependencies = [
|
||||
"zerocopy-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy-derive"
|
||||
version = "0.7.32"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.48",
|
||||
]
|
||||
|
||||
+7
-6
@@ -1,19 +1,22 @@
|
||||
[package]
|
||||
name = "wldash2"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
name = "wldash"
|
||||
version = "0.4.3"
|
||||
edition = "2024"
|
||||
|
||||
[profile.release]
|
||||
#debug = true
|
||||
lto = "fat"
|
||||
panic = "abort"
|
||||
|
||||
[features]
|
||||
default = ["fontconfig"]
|
||||
|
||||
[dependencies]
|
||||
wayland-client = { version = "0.30", features = ["calloop", "log"] }
|
||||
wayland-protocols = { version = "0.30", features = ["client", "unstable", "staging"] }
|
||||
wayland-protocols-wlr = { version = "0.1", features = ["client"] }
|
||||
nix = "0.26" # 0.27 is breaking
|
||||
memmap = "0.7"
|
||||
memmap2 = "0.9"
|
||||
fontconfig = { version = "0.8.0", optional = true }
|
||||
rusttype = "0.9"
|
||||
# fontdue = "0.7"
|
||||
@@ -24,7 +27,6 @@ walkdir = "2.4"
|
||||
|
||||
unicode-segmentation = "1.10"
|
||||
fuzzy-matcher = "0.3"
|
||||
shlex = "1.3"
|
||||
|
||||
xkbcommon = { version = "0.8", features = ["wayland"] }
|
||||
|
||||
@@ -36,5 +38,4 @@ libpulse-binding = "2.28"
|
||||
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_yaml = "0.9"
|
||||
simd-json = "0.13"
|
||||
|
||||
|
||||
@@ -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>.
|
||||
@@ -0,0 +1,40 @@
|
||||
# Maintainer: Bendik Aagaard Lynghaug <bendik.lynghaug@gmail.com>
|
||||
# Built from the tagged checkout by .gitea/workflows/release.yml, once
|
||||
# per architecture, and uploaded to the [uhhm] registry on
|
||||
# project.uhhm.no (namespace bl). pkgver is the version; the tag has
|
||||
# to agree with it and with Cargo.toml.
|
||||
pkgname=wldash
|
||||
pkgver=0.4.3
|
||||
pkgrel=1
|
||||
pkgdesc="Dashboard/launcher/control-panel for wlroots-style Wayland compositors (layer-shell)"
|
||||
arch=('x86_64' 'aarch64')
|
||||
url="https://project.uhhm.no/bl/wldash"
|
||||
license=('GPL-3.0-only')
|
||||
depends=('glibc' 'gcc-libs' 'dbus' 'libpulse' 'libxkbcommon' 'fontconfig' 'wayland')
|
||||
makedepends=('cargo')
|
||||
optdepends=('upower: battery widget'
|
||||
'pipewire-pulse: volume widget (or pulseaudio)')
|
||||
# !lto: Cargo.toml already does lto = "fat"; makepkg's -flto in RUSTFLAGS
|
||||
# would only fight it. !debug: panic = "abort" release, nothing to strip.
|
||||
options=('!debug' '!lto')
|
||||
|
||||
# Sources are the checkout itself: makepkg resolves local sources by
|
||||
# basename next to the PKGBUILD, so the tagged tree CI builds from is
|
||||
# the source of truth, as in uhhm/gdo.
|
||||
|
||||
build() {
|
||||
cd "$startdir"
|
||||
cargo build --release --locked
|
||||
}
|
||||
|
||||
check() {
|
||||
cd "$startdir"
|
||||
cargo test --release --locked
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$startdir"
|
||||
install -Dm755 "${CARGO_TARGET_DIR:-target}/release/wldash" "$pkgdir/usr/bin/wldash"
|
||||
install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
|
||||
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
# wldash
|
||||
|
||||

|
||||
|
||||
A dashboard/launcher/control-panel thing for Wayland. Requires wlr-layer-shell-unstable-v1.
|
||||
|
||||
Consider this alpha-quality: While it works, *everything* is subject to change with a moments notice. You may end up pulling in the latest changes, and *poof*, wldash suddenly turns into an artisan espresso machine.
|
||||
|
||||
## Rewrite note
|
||||
|
||||
wldash has received a significant rewrite. The old version is available in the wldash1 branch for now.
|
||||
|
||||
## This fork
|
||||
|
||||
This is a maintained fork of [kennylevinsen/wldash](https://github.com/kennylevinsen/wldash)
|
||||
living at <https://project.uhhm.no/bl/wldash>. On top of upstream it fixes a number of
|
||||
crashes (non-ASCII input in the launcher, machines without a backlight, battery or
|
||||
PulseAudio, key-repeat rate 0, ...), corrects redraw damage tracking, and prefers a
|
||||
machine-local `/etc/wldash/config.yml` over the per-user config when present, which keeps
|
||||
per-host layouts apart on NFS-shared homes.
|
||||
|
||||
## How to use
|
||||
|
||||
1. Checkout: `git clone https://project.uhhm.no/bl/wldash`
|
||||
2. Build: `cargo build --release`
|
||||
3. Put somewhere: `cp target/release/wldash /usr/local/bin/wldash`
|
||||
4. Run: `wldash`
|
||||
|
||||
To generate a new default configuration, run `wldash --write-default-config`. To configure, edit `$XDG_CONFIG_HOME/wldash/config.yml` (or if `XDG_CONFIG_HOME` is not set, `~/.config/wldash/config.yml`). If `/etc/wldash/config.yml` exists it takes precedence over the per-user file; `--config FILE` overrides both.
|
||||
|
||||
Fonts are named (`sans`, `monospace`, or any fontconfig name) and resolved through fontconfig on the machine wldash runs on. `font_paths` in the config can pin a name to a file; if that file does not exist on the current machine, wldash says so on stderr and falls back to fontconfig rather than failing, so one config can roam between hosts with different font package layouts.
|
||||
|
||||
Desktop files are scanned every time wldash starts (on a background thread), so there is no cache to refresh; `--desktop-refresh` is kept as a no-op for old key bindings. Calculator history and the prompt saved on Escape live in `$XDG_STATE_HOME/wldash` (`~/.local/state/wldash`); older installs' files under `~/.cache/wldash` are still read.
|
||||
|
||||
For more info, look in `src/config.rs`.
|
||||
|
||||
## System dependencies
|
||||
|
||||
`dbus`. See https://github.com/diwic/dbus-rs#requirements.
|
||||
|
||||
## How to use launcher
|
||||
|
||||
The launcher for wldash is built-in, based on https://github.com/kennylevinsen/dot-desktop. Pluggable systems may come back in the future.
|
||||
|
||||
The environment variables `XDG_DATA_DIRS` and `XDG_DATA_HOME` are read to find the many `applications` folders that contain `desktop` files.
|
||||
|
||||
## Features
|
||||
|
||||
### Date and time
|
||||
|
||||
In nice, big letters!
|
||||
|
||||
### 3 month calendar
|
||||
|
||||
Scroll or click on the months to navigate.
|
||||
|
||||
### Battery level
|
||||
|
||||
Over upower, only visible if upower battery is detected
|
||||
|
||||
### Audio volume
|
||||
|
||||
Over pulseaudio, only visible if pulseaudio connection is successful. Scroll to adjust volume, right-click to toggle mute.
|
||||
|
||||
### Backlight control
|
||||
|
||||
Using backlight sys file, only visible of backlight is detected. Scroll to adjust, right-click to toggle between the extreme values.
|
||||
|
||||
### Launcher
|
||||
|
||||
Loads desktop files from the usual locations.
|
||||
|
||||
The launcher also accepts prefix operators to change its mode:
|
||||
|
||||
- `!`: Arbitrary command
|
||||
- `=`: Calculator based on rcalc_lib. See https://docs.rs/rcalc_lib/0.9.3/rcalc_lib/
|
||||
|
||||
## Notable missing features:
|
||||
|
||||
- Scaling of any kind - all sizes are currently hardcoded in pixels
|
||||
|
||||
## Releasing
|
||||
|
||||
Releases are cut with [cargo-release](https://github.com/crate-ci/cargo-release) (`cargo install cargo-release`), configured in `release.toml`. Put a line for each change under `## Unreleased` in `CHANGELOG.md` as you go, then on a clean `master`:
|
||||
|
||||
```
|
||||
cargo release patch # dry run: shows the bump, replacements and tag
|
||||
cargo release patch --execute # do it (minor/major or an explicit version also work)
|
||||
```
|
||||
|
||||
This bumps `Cargo.toml`, `Cargo.lock` and `PKGBUILD` to the same version, stamps the changelog section with the version and date, commits as `release X.Y.Z`, tags `vX.Y.Z` and pushes commit and tag to the `gitea` remote. The tag triggers `.gitea/workflows/release.yml`, which builds the package per architecture and uploads it to the `[uhhm]` registry. The workflow refuses a tag whose version disagrees with `PKGBUILD` or `Cargo.toml`, which cannot happen when the tag comes from cargo-release.
|
||||
|
||||
## How to discuss
|
||||
|
||||
Go to #kennylevinsen @ irc.libera.chat to discuss, or use [~kennylevinsen/public-inbox@lists.sr.ht](https://lists.sr.ht/~kennylevinsen/public-inbox).
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
@@ -0,0 +1,26 @@
|
||||
# cargo-release settings. Cut a release with
|
||||
#
|
||||
# cargo release patch # dry run, shows what would change
|
||||
# cargo release patch --execute
|
||||
#
|
||||
# (or `minor`, `major`, or an explicit version). It bumps Cargo.toml and
|
||||
# Cargo.lock, rewrites PKGBUILD's pkgver, turns the "## Unreleased"
|
||||
# section of CHANGELOG.md into "## X.Y.Z (date)", commits, tags
|
||||
# vX.Y.Z and pushes commit + tag to the gitea remote. That tag is what
|
||||
# .gitea/workflows/release.yml builds and uploads to the [uhhm] registry.
|
||||
|
||||
# Not on crates.io; the package goes to the Arch registry via the tag.
|
||||
publish = false
|
||||
# `origin` is the upstream kennylevinsen fork on GitHub; releases go to
|
||||
# project.uhhm.no, and the workflow only runs there.
|
||||
push-remote = "gitea"
|
||||
allow-branch = ["master"]
|
||||
tag-name = "v{{version}}"
|
||||
tag-message = "wldash {{version}}"
|
||||
pre-release-commit-message = "release {{version}}"
|
||||
|
||||
pre-release-replacements = [
|
||||
{ file = "PKGBUILD", search = "^pkgver=.*", replace = "pkgver={{version}}", exactly = 1 },
|
||||
{ file = "PKGBUILD", search = "^pkgrel=.*", replace = "pkgrel=1", exactly = 1 },
|
||||
{ file = "CHANGELOG.md", search = "^## Unreleased$", replace = "## {{version}} ({{date}})", exactly = 1 },
|
||||
]
|
||||
+21
-31
@@ -1,5 +1,4 @@
|
||||
use std::{
|
||||
ffi::CStr,
|
||||
fs::File,
|
||||
io,
|
||||
os::unix::io::{FromRawFd, RawFd},
|
||||
@@ -16,11 +15,11 @@ use nix::{
|
||||
unistd,
|
||||
};
|
||||
|
||||
use memmap::MmapMut;
|
||||
use memmap2::MmapMut;
|
||||
|
||||
use wayland_client::{
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
Dispatch, QueueHandle,
|
||||
protocol::{wl_buffer, wl_shm, wl_shm_pool},
|
||||
};
|
||||
|
||||
use crate::color::Color;
|
||||
@@ -30,10 +29,7 @@ fn create_shm_fd() -> io::Result<RawFd> {
|
||||
// Only try memfd on linux
|
||||
#[cfg(target_os = "linux")]
|
||||
loop {
|
||||
match memfd::memfd_create(
|
||||
CStr::from_bytes_with_nul(b"wldash\0").unwrap(),
|
||||
memfd::MemFdCreateFlag::MFD_CLOEXEC,
|
||||
) {
|
||||
match memfd::memfd_create(c"wldash", memfd::MemFdCreateFlag::MFD_CLOEXEC) {
|
||||
Ok(fd) => return Ok(fd),
|
||||
Err(Errno::EINTR) => continue,
|
||||
Err(Errno::ENOSYS) => break,
|
||||
@@ -78,11 +74,13 @@ fn create_shm_fd() -> io::Result<RawFd> {
|
||||
}
|
||||
|
||||
pub struct ShmBuffer {
|
||||
// Keeps the memfd alive for as long as the mapping and pool exist.
|
||||
#[allow(dead_code)]
|
||||
pub file: File,
|
||||
pub mmap: MmapMut,
|
||||
pub pool: wl_shm_pool::WlShmPool,
|
||||
pub buffer: wl_buffer::WlBuffer,
|
||||
pub refcnt: u32,
|
||||
pub id: u32,
|
||||
pub last_damage: Vec<Geometry>,
|
||||
}
|
||||
|
||||
@@ -94,7 +92,6 @@ impl ShmBuffer {
|
||||
height: i32,
|
||||
stride: i32,
|
||||
format: wl_shm::Format,
|
||||
id: u32,
|
||||
) -> io::Result<ShmBuffer>
|
||||
where
|
||||
D: Dispatch<wl_shm_pool::WlShmPool, ()> + Dispatch<wl_buffer::WlBuffer, ()> + 'static,
|
||||
@@ -102,16 +99,16 @@ impl ShmBuffer {
|
||||
let mem_fd = create_shm_fd()?;
|
||||
let file = unsafe { File::from_raw_fd(mem_fd) };
|
||||
file.set_len((height * stride) as u64)?;
|
||||
let pool = shm.create_pool(mem_fd, height * stride, &qh, ());
|
||||
let mmap = unsafe { MmapMut::map_mut(&file).unwrap() };
|
||||
let buffer = pool.create_buffer(0, width, height, stride, format, &qh, ());
|
||||
let pool = shm.create_pool(mem_fd, height * stride, qh, ());
|
||||
let mmap = unsafe { MmapMut::map_mut(&file)? };
|
||||
let buffer = pool.create_buffer(0, width, height, stride, format, qh, ());
|
||||
|
||||
Ok(ShmBuffer {
|
||||
refcnt: 0,
|
||||
file,
|
||||
mmap,
|
||||
pool,
|
||||
buffer,
|
||||
id,
|
||||
last_damage: Vec::new(),
|
||||
})
|
||||
}
|
||||
@@ -121,37 +118,33 @@ impl ShmBuffer {
|
||||
}
|
||||
|
||||
pub fn release(&mut self) {
|
||||
self.refcnt -= 1;
|
||||
// A compositor may release a buffer we never considered acquired
|
||||
// (e.g. after a resize); never underflow and wedge the buffer.
|
||||
self.refcnt = self.refcnt.saturating_sub(1);
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BufferManager {
|
||||
pub buffers: Vec<ShmBuffer>,
|
||||
pub next_id: u32,
|
||||
}
|
||||
|
||||
impl BufferManager {
|
||||
pub fn new() -> BufferManager {
|
||||
BufferManager {
|
||||
buffers: Vec::new(),
|
||||
next_id: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn clear_buffers(&mut self) {
|
||||
for buf in self.buffers.iter_mut() {
|
||||
buf.buffer.destroy()
|
||||
buf.buffer.destroy();
|
||||
buf.pool.destroy();
|
||||
}
|
||||
self.buffers.clear()
|
||||
}
|
||||
|
||||
pub fn next_buffer(&mut self) -> Option<&mut ShmBuffer> {
|
||||
for buf in self.buffers.iter_mut() {
|
||||
if buf.refcnt == 0 {
|
||||
return Some(buf);
|
||||
}
|
||||
}
|
||||
None
|
||||
self.buffers.iter_mut().find(|buf| buf.refcnt == 0)
|
||||
}
|
||||
|
||||
pub fn add_buffer<D>(
|
||||
@@ -162,18 +155,15 @@ impl BufferManager {
|
||||
) where
|
||||
D: Dispatch<wl_shm_pool::WlShmPool, ()> + Dispatch<wl_buffer::WlBuffer, ()> + 'static,
|
||||
{
|
||||
let mut buf = ShmBuffer::new(
|
||||
let buf = ShmBuffer::new(
|
||||
wl_shm,
|
||||
qh,
|
||||
dimensions.0,
|
||||
dimensions.1,
|
||||
dimensions.0 * 4,
|
||||
wl_shm::Format::Argb8888,
|
||||
self.next_id,
|
||||
)
|
||||
.expect("unable to add buffer");
|
||||
self.next_id += 1;
|
||||
BufferView::new(&mut buf.mmap, (dimensions.0 as u32, dimensions.1 as u32));
|
||||
self.buffers.push(buf);
|
||||
}
|
||||
}
|
||||
@@ -185,7 +175,7 @@ pub struct BufferView<'a> {
|
||||
}
|
||||
|
||||
impl<'a> BufferView<'a> {
|
||||
pub fn new(buf: &'a mut MmapMut, dimensions: (u32, u32)) -> BufferView {
|
||||
pub fn new(buf: &'a mut MmapMut, dimensions: (u32, u32)) -> BufferView<'a> {
|
||||
let view = unsafe {
|
||||
std::slice::from_raw_parts_mut(
|
||||
buf.as_mut_ptr() as *mut u32,
|
||||
@@ -208,7 +198,7 @@ impl<'a> BufferView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn subdimensions(&mut self, subdimensions: (u32, u32, u32, u32)) -> BufferView {
|
||||
pub fn subdimensions(&mut self, subdimensions: (u32, u32, u32, u32)) -> BufferView<'_> {
|
||||
let bounds = self.get_bounds();
|
||||
if cfg!(debug_assertions)
|
||||
&& (subdimensions.0 + subdimensions.2 > bounds.2
|
||||
@@ -232,11 +222,11 @@ impl<'a> BufferView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn subgeometry(&mut self, geo: Geometry) -> BufferView {
|
||||
pub fn subgeometry(&mut self, geo: Geometry) -> BufferView<'_> {
|
||||
self.subdimensions((geo.x, geo.y, geo.width, geo.height))
|
||||
}
|
||||
|
||||
pub fn offset(&mut self, offset: (u32, u32)) -> BufferView {
|
||||
pub fn offset(&mut self, offset: (u32, u32)) -> BufferView<'_> {
|
||||
let bounds = self.get_bounds();
|
||||
if cfg!(debug_assertions) && (offset.0 > bounds.2 || offset.1 > bounds.3) {
|
||||
panic!(
|
||||
|
||||
+21
-27
@@ -6,7 +6,7 @@ use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{
|
||||
event::Events,
|
||||
fonts::{find_font, FontMap},
|
||||
fonts::FontMap,
|
||||
widgets::{
|
||||
Backlight, Battery, Calendar, Clock, Date, HorizontalLayout, IndexedLayout, Interface,
|
||||
InvertedHorizontalLayout, InvertedVerticalLayout, Layout, Line, Margin, PulseAudio,
|
||||
@@ -89,8 +89,6 @@ impl Config {
|
||||
pub fn generate_v1() -> Config {
|
||||
let has_battery = Battery::detect();
|
||||
let has_backlight = Backlight::detect();
|
||||
let sans = find_font("sans");
|
||||
let monospace = find_font("monospace");
|
||||
|
||||
let mut bars = Vec::new();
|
||||
if has_battery {
|
||||
@@ -154,14 +152,13 @@ impl Config {
|
||||
])),
|
||||
};
|
||||
|
||||
let map = HashMap::from([
|
||||
("sans".to_string(), sans),
|
||||
("monospace".to_string(), monospace),
|
||||
]);
|
||||
|
||||
Config {
|
||||
font_paths: Some(map),
|
||||
widget: widget,
|
||||
// Left unset on purpose: "sans"/"monospace" are resolved through
|
||||
// fontconfig on each machine at start. Pinning absolute paths
|
||||
// here broke configs shared between hosts with different font
|
||||
// package layouts. Set font_paths yourself to override.
|
||||
font_paths: None,
|
||||
widget,
|
||||
mode: OperationMode::LayerSurface((1024, 768)),
|
||||
background: Some(0xFAFAFAFA),
|
||||
server: None,
|
||||
@@ -171,8 +168,6 @@ impl Config {
|
||||
pub fn generate_v2(clay: bool) -> Config {
|
||||
let has_battery = Battery::detect();
|
||||
let has_backlight = Backlight::detect();
|
||||
let sans = find_font("sans");
|
||||
let monospace = find_font("monospace");
|
||||
|
||||
let mut bars = Vec::new();
|
||||
if has_battery {
|
||||
@@ -244,14 +239,13 @@ impl Config {
|
||||
]),
|
||||
]);
|
||||
|
||||
let map = HashMap::from([
|
||||
("sans".to_string(), sans),
|
||||
("monospace".to_string(), monospace),
|
||||
]);
|
||||
|
||||
Config {
|
||||
font_paths: Some(map),
|
||||
widget: widget,
|
||||
// Left unset on purpose: "sans"/"monospace" are resolved through
|
||||
// fontconfig on each machine at start. Pinning absolute paths
|
||||
// here broke configs shared between hosts with different font
|
||||
// package layouts. Set font_paths yourself to override.
|
||||
font_paths: None,
|
||||
widget,
|
||||
mode: if clay {
|
||||
OperationMode::XdgToplevel
|
||||
} else {
|
||||
@@ -281,7 +275,7 @@ impl Widget {
|
||||
pub fn construct_widgets(
|
||||
self,
|
||||
v: &mut Vec<Box<dyn RealWidget>>,
|
||||
mut fm: &mut FontMap,
|
||||
fm: &mut FontMap,
|
||||
events: &Arc<Mutex<Events>>,
|
||||
) {
|
||||
match self {
|
||||
@@ -301,12 +295,12 @@ impl Widget {
|
||||
Widget::HorizontalLine(width) => v.push(Box::new(Line::new(width, false))),
|
||||
Widget::VerticalLine(width) => v.push(Box::new(Line::new(width, true))),
|
||||
Widget::Clock { font, font_size } => v.push(Box::new(Clock::new(
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font, "sans"),
|
||||
font_size,
|
||||
))),
|
||||
Widget::Date { font, font_size } => v.push(Box::new(Date::new(
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font, "sans"),
|
||||
font_size,
|
||||
))),
|
||||
@@ -317,7 +311,7 @@ impl Widget {
|
||||
sections_x,
|
||||
sections_y,
|
||||
} => v.push(Box::new(Calendar::new(
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font_primary, "monospace"),
|
||||
leak_or_default(font_secondary, "sans"),
|
||||
font_size,
|
||||
@@ -330,14 +324,14 @@ impl Widget {
|
||||
launch_cmd,
|
||||
} => v.push(Box::new(Interface::new(
|
||||
events.clone(),
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font, "sans"),
|
||||
font_size,
|
||||
launch_cmd,
|
||||
))),
|
||||
Widget::Battery { font, font_size } => v.push(Box::new(Battery::new(
|
||||
events.clone(),
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font, "sans"),
|
||||
font_size,
|
||||
))),
|
||||
@@ -347,13 +341,13 @@ impl Widget {
|
||||
font_size,
|
||||
} => v.push(Box::new(Backlight::new(
|
||||
leak_or_none(device),
|
||||
&mut fm,
|
||||
fm,
|
||||
leak_or_default(font, "sans"),
|
||||
font_size,
|
||||
))),
|
||||
Widget::PulseAudio { font, font_size } => v.push(Box::new(PulseAudio::new(
|
||||
events.clone(),
|
||||
&mut fm,
|
||||
fm,
|
||||
Box::leak(font.unwrap_or_else(|| "sans".to_string()).into_boxed_str()),
|
||||
font_size,
|
||||
))),
|
||||
|
||||
+23
-23
@@ -1,7 +1,7 @@
|
||||
use crate::buffer::BufferView;
|
||||
use crate::{color::Color, fonts::FontRef};
|
||||
|
||||
use rusttype::{point, Scale};
|
||||
use rusttype::{Scale, point};
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct CachedGlyph {
|
||||
@@ -82,7 +82,7 @@ pub struct Font<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Font<'a> {
|
||||
pub fn new(font: FontRef<'a>, size: f32) -> Font {
|
||||
pub fn new(font: FontRef<'a>, size: f32) -> Font<'a> {
|
||||
Font {
|
||||
glyphs: HashMap::new(),
|
||||
font,
|
||||
@@ -98,7 +98,7 @@ impl<'a> Font<'a> {
|
||||
|
||||
pub fn add_str_to_cache(&mut self, s: &str) {
|
||||
for ch in s.chars() {
|
||||
if self.glyphs.get(&ch).is_none() {
|
||||
if !self.glyphs.contains_key(&ch) {
|
||||
let glyph = CachedGlyph::new(self.font, self.size, ch);
|
||||
self.glyphs.insert(ch, glyph);
|
||||
}
|
||||
@@ -118,10 +118,10 @@ impl<'a> Font<'a> {
|
||||
let glyph = match self.glyphs.get(&ch) {
|
||||
Some(glyph) => glyph,
|
||||
None => {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
return Err(::std::io::Error::other(format!(
|
||||
"glyph for {:} not in cache",
|
||||
ch
|
||||
)));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -151,10 +151,10 @@ impl<'a> Font<'a> {
|
||||
let glyph = match self.glyphs.get(&ch) {
|
||||
Some(glyph) => glyph,
|
||||
None => {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
return Err(::std::io::Error::other(format!(
|
||||
"glyph for {:} not in cache",
|
||||
ch
|
||||
)));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -203,10 +203,10 @@ impl<'a> Font<'a> {
|
||||
let glyph = match self.glyphs.get(&ch) {
|
||||
Some(glyph) => glyph,
|
||||
None => {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
return Err(::std::io::Error::other(format!(
|
||||
"glyph for {:} not in cache",
|
||||
ch
|
||||
)));
|
||||
}
|
||||
};
|
||||
let width = glyph.advance;
|
||||
@@ -252,10 +252,10 @@ impl<'a> Font<'a> {
|
||||
let glyph = match self.glyphs.get(&ch) {
|
||||
Some(glyph) => glyph,
|
||||
None => {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
return Err(::std::io::Error::other(format!(
|
||||
"glyph for {:} not in cache",
|
||||
ch
|
||||
)));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
@@ -284,10 +284,10 @@ impl<'a> Font<'a> {
|
||||
let glyph = match self.glyphs.get(&ch) {
|
||||
Some(glyph) => glyph,
|
||||
None => {
|
||||
return Err(::std::io::Error::new(
|
||||
::std::io::ErrorKind::Other,
|
||||
format!("glyph for {:} not in cache", ch),
|
||||
))
|
||||
return Err(::std::io::Error::other(format!(
|
||||
"glyph for {:} not in cache",
|
||||
ch
|
||||
)));
|
||||
}
|
||||
};
|
||||
glyphs.push(glyph);
|
||||
|
||||
+1
-1
@@ -56,6 +56,6 @@ impl Events {
|
||||
|
||||
pub fn flush(&mut self) -> Vec<Event> {
|
||||
self.dirty = false;
|
||||
self.events.drain(..).collect()
|
||||
std::mem::take(&mut self.events)
|
||||
}
|
||||
}
|
||||
|
||||
+88
-22
@@ -9,21 +9,48 @@ use std::{
|
||||
/// FontRef is used to store Fonts on widgets.
|
||||
pub type FontRef<'a> = &'a rusttype::Font<'a>;
|
||||
|
||||
/// Ask fontconfig for the file backing a font name ("sans", "monospace",
|
||||
/// "Noto Sans", ...), the way fc-match does.
|
||||
#[cfg(feature = "fontconfig")]
|
||||
pub(crate) fn find_font(name: &str) -> String {
|
||||
pub(crate) fn find_font(name: &str) -> Result<String, String> {
|
||||
use fontconfig::Fontconfig as FontConfig;
|
||||
let fc = FontConfig::new().unwrap();
|
||||
fc.find(name, None)
|
||||
.unwrap()
|
||||
let fc = FontConfig::new().ok_or("could not initialise fontconfig")?;
|
||||
let found = fc
|
||||
.find(name, None)
|
||||
.ok_or_else(|| format!("fontconfig has no match for {:?}", name))?;
|
||||
found
|
||||
.path
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.to_string()
|
||||
.map(|s| s.to_string())
|
||||
.ok_or_else(|| format!("font path for {:?} is not UTF-8", name))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "fontconfig"))]
|
||||
pub(crate) fn find_font(_name: &str) -> String {
|
||||
panic!("fontconfig not enabled so font search not available");
|
||||
pub(crate) fn find_font(name: &str) -> Result<String, String> {
|
||||
Err(format!(
|
||||
"no path configured for font {:?} and wldash was built without fontconfig",
|
||||
name
|
||||
))
|
||||
}
|
||||
|
||||
/// Resolve the file to load for `name`: a path pinned in the config if it
|
||||
/// exists on this machine, otherwise whatever fontconfig picks for the name.
|
||||
///
|
||||
/// Configs roam between machines on a shared home, and font packages do
|
||||
/// not keep the same file layout everywhere (Noto under fonts/noto on one
|
||||
/// distribution, fonts/google-noto on another), so a pinned path that is
|
||||
/// missing is a reason to fall back, not to abort.
|
||||
pub(crate) fn resolve_font_path(name: &str, pinned: Option<&str>) -> Result<String, String> {
|
||||
if let Some(p) = pinned {
|
||||
if Path::new(p).is_file() {
|
||||
return Ok(p.to_string());
|
||||
}
|
||||
eprintln!(
|
||||
"wldash: configured font file for {:?} not found: {}; asking fontconfig instead",
|
||||
name, p
|
||||
);
|
||||
}
|
||||
find_font(name)
|
||||
}
|
||||
|
||||
/// FontLoader is a marker struct that is used to load files
|
||||
@@ -31,17 +58,20 @@ pub(crate) struct FontLoader;
|
||||
|
||||
impl FontLoader {
|
||||
/// Given a path, loads it as a Font, which can be rendered to the screen.
|
||||
pub(crate) fn from_path<'a, P>(path: P) -> Option<Font<'a>>
|
||||
pub(crate) fn from_path<'a, P>(path: P) -> Result<Font<'a>, String>
|
||||
where
|
||||
P: AsRef<Path>,
|
||||
{
|
||||
let mut file = File::open(path).expect("Font file not found");
|
||||
let path = path.as_ref();
|
||||
let mut file =
|
||||
File::open(path).map_err(|e| format!("cannot open {}: {}", path.display(), e))?;
|
||||
let mut data = match file.metadata() {
|
||||
Ok(metadata) => Vec::with_capacity(metadata.len() as usize),
|
||||
Err(_) => vec![],
|
||||
};
|
||||
file.read_to_end(&mut data).unwrap();
|
||||
Font::try_from_vec(data)
|
||||
file.read_to_end(&mut data)
|
||||
.map_err(|e| format!("cannot read {}: {}", path.display(), e))?;
|
||||
Font::try_from_vec(data).ok_or_else(|| format!("{} is not a usable font", path.display()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,10 +100,13 @@ impl PartialEq for ComparableF32 {
|
||||
|
||||
impl Eq for ComparableF32 {}
|
||||
|
||||
/// font name -> (font name, [(size, glyphs to preload)])
|
||||
type RequiredFonts = HashMap<&'static str, (&'static str, Vec<(f32, &'static str)>)>;
|
||||
|
||||
pub struct FontMap {
|
||||
fonts: HashMap<(&'static str, ComparableF32), draw::Font<'static>>,
|
||||
font_paths: HashMap<&'static str, String>,
|
||||
required_fonts: HashMap<&'static str, (&'static str, Vec<(f32, &'static str)>)>,
|
||||
required_fonts: RequiredFonts,
|
||||
}
|
||||
|
||||
impl FontMap {
|
||||
@@ -99,19 +132,28 @@ impl FontMap {
|
||||
self.font_paths.insert(font_name, font_path);
|
||||
}
|
||||
|
||||
/// Load every queued font. Runs on its own thread; a font that cannot
|
||||
/// be found or read is a configuration problem the user has to see, so
|
||||
/// it is reported in one line and the process exits instead of
|
||||
/// aborting with a panic backtrace.
|
||||
pub fn load_fonts(&mut self) {
|
||||
for (font_name, v) in self.required_fonts.iter() {
|
||||
let path = match self.font_paths.get(font_name) {
|
||||
Some(res) => res,
|
||||
_ => {
|
||||
let s = find_font(font_name);
|
||||
self.font_paths.insert(font_name, s);
|
||||
self.font_paths.get(font_name).unwrap()
|
||||
let pinned = self.font_paths.get(font_name).map(|s| s.as_str());
|
||||
let path = match resolve_font_path(font_name, pinned) {
|
||||
Ok(p) => p,
|
||||
Err(e) => {
|
||||
eprintln!("wldash: cannot resolve font {:?}: {}", font_name, e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let fontref = Box::leak(Box::new(
|
||||
FontLoader::from_path(path).expect("unable to load font"),
|
||||
));
|
||||
let font = match FontLoader::from_path(&path) {
|
||||
Ok(f) => f,
|
||||
Err(e) => {
|
||||
eprintln!("wldash: cannot load font {:?}: {}", font_name, e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
};
|
||||
let fontref = Box::leak(Box::new(font));
|
||||
for (size, preload) in &v.1 {
|
||||
if let Some(font) = self.fonts.get_mut(&(font_name, ComparableF32(*size))) {
|
||||
font.add_str_to_cache(preload);
|
||||
@@ -157,3 +199,27 @@ impl MaybeFontMap {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::resolve_font_path;
|
||||
|
||||
#[test]
|
||||
fn pinned_path_wins_when_present() {
|
||||
let dir = std::env::temp_dir().join(format!("wldash-font-test-{}", std::process::id()));
|
||||
std::fs::create_dir_all(&dir).unwrap();
|
||||
let f = dir.join("x.ttf");
|
||||
std::fs::write(&f, b"not really a font").unwrap();
|
||||
let p = f.to_str().unwrap();
|
||||
assert_eq!(resolve_font_path("sans", Some(p)).unwrap(), p);
|
||||
std::fs::remove_dir_all(&dir).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_pinned_path_falls_back_to_lookup() {
|
||||
// Whatever fontconfig answers (or an error without fontconfig),
|
||||
// the missing pinned path itself must never be returned.
|
||||
let r = resolve_font_path("sans", Some("/nonexistent/wldash/font.ttf"));
|
||||
assert_ne!(r.as_deref().ok(), Some("/nonexistent/wldash/font.ttf"));
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -12,12 +12,9 @@
|
||||
//! calloop event loop. Not doing so will prevent key repetition to work
|
||||
//! (but the rest of the functionnality will not be affected).
|
||||
|
||||
use std::{
|
||||
default::Default,
|
||||
os::unix::io::{AsRawFd, OwnedFd},
|
||||
};
|
||||
use std::{default::Default, os::unix::io::OwnedFd};
|
||||
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
use xkbcommon::xkb;
|
||||
|
||||
pub use xkbcommon::xkb::keysyms;
|
||||
@@ -31,6 +28,7 @@ pub use self::state::ModifiersState;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct KeyEvent {
|
||||
#[allow(dead_code)]
|
||||
pub rawkey: u32,
|
||||
pub keysym: u32,
|
||||
pub state: WEnum<wl_keyboard::KeyState>,
|
||||
@@ -46,7 +44,7 @@ pub struct KeymapDescription {
|
||||
|
||||
impl KeymapDescription {
|
||||
fn new(fd: OwnedFd, size: u32) -> KeymapDescription {
|
||||
KeymapDescription { fd: fd, size: size }
|
||||
KeymapDescription { fd, size }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +75,9 @@ impl Keyboard {
|
||||
WEnum::Value(wl_keyboard::KeymapFormat::NoKeymap) => {
|
||||
// TODO: how to handle this (hopefully never occuring) case?
|
||||
}
|
||||
_ => unreachable!(),
|
||||
// Unknown format from a newer protocol version: ignore rather than
|
||||
// abort the whole process.
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-3
@@ -1,11 +1,11 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use calloop::{
|
||||
EventSource, Poll, PostAction, Readiness, Token, TokenFactory,
|
||||
channel::{self, Channel},
|
||||
timer::{TimeoutAction, Timer},
|
||||
EventSource, Poll, PostAction, Readiness, Token, TokenFactory,
|
||||
};
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
|
||||
use super::KeyEvent;
|
||||
|
||||
@@ -89,6 +89,12 @@ impl EventSource for KeyRepeatSource {
|
||||
_ => (),
|
||||
},
|
||||
RepeatMessage::RepeatInfo((new_rate, new_delay)) => {
|
||||
// Per wl_keyboard.repeat_info, a rate of 0 disables
|
||||
// key repeat entirely. Dividing by it would panic.
|
||||
if new_rate == 0 {
|
||||
*disabled = true;
|
||||
key.take();
|
||||
} else {
|
||||
*rate = Duration::from_micros(1_000_000 / new_rate as u64);
|
||||
*delay = Duration::from_millis(new_delay as u64);
|
||||
*disabled = false;
|
||||
@@ -96,6 +102,7 @@ impl EventSource for KeyRepeatSource {
|
||||
timer.set_deadline(now + *delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
channel::Event::Closed => {
|
||||
@@ -129,7 +136,9 @@ impl EventSource for KeyRepeatSource {
|
||||
let mut next_deadline = deadline;
|
||||
if now - deadline > *rate * 2 {
|
||||
// We're way behind, let's just set a new time
|
||||
println!("KeyRepeatSource::process_events: More than two repeat cycles behind, resetting");
|
||||
println!(
|
||||
"KeyRepeatSource::process_events: More than two repeat cycles behind, resetting"
|
||||
);
|
||||
next_deadline = now + *rate;
|
||||
} else {
|
||||
while next_deadline < now {
|
||||
|
||||
+9
-11
@@ -81,17 +81,15 @@ impl KbState {
|
||||
}
|
||||
|
||||
pub(crate) fn compose_feed(&mut self, keysym: u32) -> Option<xkb::compose::FeedResult> {
|
||||
match &mut self.xkb_compose_state {
|
||||
Some(compose_state) => Some(compose_state.feed(xkb::Keysym::new(keysym))),
|
||||
None => None,
|
||||
}
|
||||
self.xkb_compose_state
|
||||
.as_mut()
|
||||
.map(|compose_state| compose_state.feed(xkb::Keysym::new(keysym)))
|
||||
}
|
||||
|
||||
pub(crate) fn compose_status(&mut self) -> Option<xkb::compose::Status> {
|
||||
match &mut self.xkb_compose_state {
|
||||
Some(compose_state) => Some(compose_state.status()),
|
||||
None => None,
|
||||
}
|
||||
self.xkb_compose_state
|
||||
.as_mut()
|
||||
.map(|compose_state| compose_state.status())
|
||||
}
|
||||
|
||||
pub(crate) fn compose_get_utf8(&mut self) -> Option<String> {
|
||||
@@ -130,11 +128,11 @@ impl KbState {
|
||||
|
||||
pub(crate) fn init_compose(&mut self) {
|
||||
let locale = env::var_os("LC_ALL")
|
||||
.and_then(|v| if v.is_empty() { None } else { Some(v) })
|
||||
.filter(|v| !v.is_empty())
|
||||
.or_else(|| env::var_os("LC_CTYPE"))
|
||||
.and_then(|v| if v.is_empty() { None } else { Some(v) })
|
||||
.filter(|v| !v.is_empty())
|
||||
.or_else(|| env::var_os("LANG"))
|
||||
.and_then(|v| if v.is_empty() { None } else { Some(v) })
|
||||
.filter(|v| !v.is_empty())
|
||||
.unwrap_or_else(|| "C".into());
|
||||
|
||||
let compose_table = match xkb::compose::Table::new_from_locale(
|
||||
|
||||
+66
-27
@@ -12,8 +12,8 @@ mod widgets;
|
||||
use wayland_client::{Connection, QueueHandle, WaylandSource};
|
||||
|
||||
use calloop::{
|
||||
timer::{TimeoutAction, Timer},
|
||||
EventLoop,
|
||||
timer::{TimeoutAction, Timer},
|
||||
};
|
||||
use chrono::{Duration, Local, Timelike};
|
||||
|
||||
@@ -23,17 +23,15 @@ use event::{Event, Events};
|
||||
use fonts::{FontMap, MaybeFontMap};
|
||||
use keyboard::{KeyRepeatSource, RepeatMessage};
|
||||
use state::State;
|
||||
use utils::{
|
||||
desktop::{load_desktop_files, write_desktop_cache},
|
||||
xdg,
|
||||
};
|
||||
use utils::xdg;
|
||||
use widgets::{Geometry, Widget};
|
||||
|
||||
use std::{
|
||||
env,
|
||||
env, fs,
|
||||
fs::File,
|
||||
io::{BufRead, BufReader, Write},
|
||||
os::unix::net::{UnixListener, UnixStream},
|
||||
path::Path,
|
||||
rc::Rc,
|
||||
thread,
|
||||
};
|
||||
@@ -45,26 +43,58 @@ usage: wldash [OPTIONS]
|
||||
|
||||
OPTIONS:
|
||||
--config CONFIG_FILE use the specified config file
|
||||
(~/.config/wldash/config.yml by default)
|
||||
(/etc/wldash/config.yml if present,
|
||||
else ~/.config/wldash/config.yml)
|
||||
--write-default-config [v1|v2|toplevel] generate and write a new config file
|
||||
(v2 by default)
|
||||
--desktop-refresh refresh desktop file cache
|
||||
--desktop-refresh no-op kept for old key bindings
|
||||
(desktop files are scanned at start)
|
||||
"
|
||||
);
|
||||
}
|
||||
|
||||
fn die(msg: String) -> ! {
|
||||
eprintln!("wldash: {}", msg);
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
fn ensure_dir_exists(path: &str) {
|
||||
if let Err(err) = fs::create_dir_all(path) {
|
||||
die(format!("error creating directory {}: {}", path, err));
|
||||
}
|
||||
}
|
||||
|
||||
fn create_required_directories() {
|
||||
let dir_config_wldash = format!("{}/wldash", xdg::config_folder());
|
||||
ensure_dir_exists(&dir_config_wldash);
|
||||
}
|
||||
|
||||
/// Default config path. On a shared (e.g. NFS-roamed) home, a host-specific
|
||||
/// config at /etc/wldash/config.yml takes precedence over the roamed
|
||||
/// ~/.config/wldash/config.yml, so each machine can keep its own layout
|
||||
/// without conflicting. An explicit --config still overrides both.
|
||||
fn default_config_file() -> String {
|
||||
let etc = "/etc/wldash/config.yml";
|
||||
if Path::new(etc).exists() {
|
||||
return etc.to_string();
|
||||
}
|
||||
format!("{}/wldash/config.yml", xdg::config_folder())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut args = env::args();
|
||||
// Skip program name
|
||||
_ = args.next();
|
||||
|
||||
let mut config_file = format!("{}/wldash/config.yml", xdg::config_folder());
|
||||
create_required_directories();
|
||||
|
||||
let mut config_file = default_config_file();
|
||||
|
||||
loop {
|
||||
match args.next() {
|
||||
Some(ref s) if s == "--config" => match args.next() {
|
||||
Some(ref s) => config_file = s.clone(),
|
||||
None => panic!("missing argument to --config"),
|
||||
None => die("missing argument to --config".to_string()),
|
||||
},
|
||||
Some(ref s) if s == "--write-default-config" => {
|
||||
let config = match args.next() {
|
||||
@@ -72,17 +102,20 @@ fn main() {
|
||||
Some(ref s) if s == "v2" => Config::generate_v2(false),
|
||||
Some(ref s) if s == "toplevel" => Config::generate_v2(true),
|
||||
None => Config::generate_v2(false),
|
||||
Some(s) => panic!("unknown argument: {}", s),
|
||||
Some(s) => die(format!("unknown argument to --write-default-config: {}", s)),
|
||||
};
|
||||
match File::create(config_file) {
|
||||
Ok(f) => serde_yaml::to_writer(f, &config).unwrap(),
|
||||
Err(_) => panic!("uh"),
|
||||
match File::create(&config_file) {
|
||||
Ok(f) => {
|
||||
if let Err(e) = serde_yaml::to_writer(f, &config) {
|
||||
die(format!("could not serialize config: {}", e));
|
||||
}
|
||||
}
|
||||
Err(e) => die(format!("could not write {}: {}", config_file, e)),
|
||||
}
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(ref s) if s == "--desktop-refresh" => {
|
||||
let v = load_desktop_files();
|
||||
write_desktop_cache(&v).unwrap();
|
||||
eprintln!("wldash: desktop files are scanned at every start; nothing to refresh");
|
||||
std::process::exit(0);
|
||||
}
|
||||
Some(ref s) if s == "--help" => {
|
||||
@@ -97,7 +130,10 @@ fn main() {
|
||||
}
|
||||
}
|
||||
|
||||
let conn = Connection::connect_to_env().unwrap();
|
||||
let conn = match Connection::connect_to_env() {
|
||||
Ok(c) => c,
|
||||
Err(e) => die(format!("could not connect to the Wayland display: {}", e)),
|
||||
};
|
||||
|
||||
let event_queue = conn.new_event_queue();
|
||||
let qhandle: QueueHandle<State> = event_queue.handle();
|
||||
@@ -116,7 +152,7 @@ fn main() {
|
||||
handle
|
||||
.insert_source(
|
||||
WaylandSource::new(event_queue).expect("Could not create WaylandSource!"),
|
||||
|_event, queue, mut state| queue.dispatch_pending(&mut state),
|
||||
|_event, queue, state| queue.dispatch_pending(state),
|
||||
)
|
||||
.expect("Failed to insert event source!");
|
||||
|
||||
@@ -173,9 +209,15 @@ fn main() {
|
||||
|
||||
let mut fm = FontMap::new();
|
||||
|
||||
let config: Config = match File::open(config_file) {
|
||||
Ok(f) => serde_yaml::from_reader(f).unwrap(),
|
||||
Err(_) => panic!("configuration file missing"),
|
||||
let config: Config = match File::open(&config_file) {
|
||||
Ok(f) => match serde_yaml::from_reader(f) {
|
||||
Ok(c) => c,
|
||||
Err(e) => die(format!("invalid configuration {}: {}", config_file, e)),
|
||||
},
|
||||
Err(e) => die(format!(
|
||||
"could not open configuration {}: {} (try 'wldash --write-default-config')",
|
||||
config_file, e
|
||||
)),
|
||||
};
|
||||
|
||||
if let Some(true) = config.server {
|
||||
@@ -190,8 +232,7 @@ fn main() {
|
||||
.spawn(move || {
|
||||
let listener = UnixListener::bind(socket_path.clone()).unwrap();
|
||||
loop {
|
||||
match listener.accept() {
|
||||
Ok((stream, _)) => {
|
||||
if let Ok((stream, _)) = listener.accept() {
|
||||
let _ = thread::Builder::new().name("ipc_client".to_string()).spawn(
|
||||
move || {
|
||||
let r = BufReader::new(stream);
|
||||
@@ -206,8 +247,6 @@ fn main() {
|
||||
},
|
||||
);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -261,7 +300,7 @@ fn main() {
|
||||
}
|
||||
|
||||
let mut force = false;
|
||||
if state.bufmgr.buffers.len() == 0 {
|
||||
if state.bufmgr.buffers.is_empty() {
|
||||
state.add_buffer(&qhandle);
|
||||
force = true;
|
||||
}
|
||||
@@ -285,7 +324,7 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
if buf.last_damage.len() == 0 {
|
||||
if buf.last_damage.is_empty() {
|
||||
for _ in 0..state.widgets.len() {
|
||||
buf.last_damage.push(Geometry::new());
|
||||
}
|
||||
|
||||
+31
-37
@@ -7,11 +7,11 @@ use std::{
|
||||
};
|
||||
|
||||
use wayland_client::{
|
||||
Connection, Dispatch, QueueHandle, WEnum,
|
||||
protocol::{
|
||||
wl_buffer, wl_callback, wl_compositor, wl_keyboard, wl_pointer, wl_registry, wl_seat,
|
||||
wl_shm, wl_shm_pool, wl_subcompositor, wl_subsurface, wl_surface,
|
||||
},
|
||||
Connection, Dispatch, QueueHandle, WEnum,
|
||||
};
|
||||
|
||||
use wayland_protocols::{
|
||||
@@ -133,17 +133,16 @@ impl State {
|
||||
Ok(token) => token,
|
||||
Err(_) => return,
|
||||
};
|
||||
match (
|
||||
if let (Some(surface), Some(activation)) = (
|
||||
&self.main_surface.wl_surface,
|
||||
&self.protocols.xdg_activation,
|
||||
) {
|
||||
(Some(surface), Some(activation)) => {
|
||||
activation.activate(key, surface);
|
||||
let activation_token = activation.get_activation_token(qh, ());
|
||||
activation_token.commit();
|
||||
unsafe {
|
||||
env::remove_var("XDG_ACTIVATION_TOKEN");
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,9 +330,8 @@ impl Dispatch<wl_callback::WlCallback, ()> for State {
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
) {
|
||||
match event {
|
||||
wl_callback::Event::Done { callback_data: _ } => state.ready = true,
|
||||
_ => {}
|
||||
if let wl_callback::Event::Done { callback_data: _ } = event {
|
||||
state.ready = true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,12 +459,15 @@ impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, ()> for State {
|
||||
(width, height) = (640, 480);
|
||||
}
|
||||
layer_surface.ack_configure(serial);
|
||||
let first_configure = !state.configured;
|
||||
state.configured = true;
|
||||
state.dirty = true;
|
||||
|
||||
let dim = (width as i32, height as i32);
|
||||
|
||||
if state.configured && state.dimensions == dim {
|
||||
// Always lay out on the first configure, even if the
|
||||
// compositor happens to hand us our placeholder dimensions.
|
||||
if !first_configure && state.dimensions == dim {
|
||||
return;
|
||||
}
|
||||
state.bufmgr.clear_buffers();
|
||||
@@ -478,8 +479,8 @@ impl Dispatch<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1, ()> for State {
|
||||
&Geometry {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width as u32,
|
||||
height: height as u32,
|
||||
width,
|
||||
height,
|
||||
},
|
||||
state,
|
||||
);
|
||||
@@ -656,25 +657,27 @@ impl Dispatch<wl_keyboard::WlKeyboard, ()> for State {
|
||||
state: kbstate,
|
||||
..
|
||||
} => {
|
||||
if key == 1 {
|
||||
state.running = false;
|
||||
return;
|
||||
}
|
||||
state.keyboard.resolve();
|
||||
let k = state.keyboard.key(key, kbstate);
|
||||
let repeats = k.repeats;
|
||||
let ev = Event::KeyEvent(k);
|
||||
// Widgets see the key first so the launcher gets to save its
|
||||
// prompt on Escape (the early-return used to swallow it).
|
||||
for widget in state.widgets.iter_mut() {
|
||||
widget.event(&ev);
|
||||
}
|
||||
if repeats {
|
||||
if let Event::KeyEvent(k) = ev {
|
||||
// Raw keycode 1 is KEY_ESC: fall back to quitting even when no
|
||||
// keymap could be loaded and no widget handled it.
|
||||
if key == 1 && kbstate == WEnum::Value(wl_keyboard::KeyState::Pressed) {
|
||||
state.running = false;
|
||||
return;
|
||||
}
|
||||
if repeats && let Event::KeyEvent(k) = ev {
|
||||
state
|
||||
.keyrepeat_sender
|
||||
.send(RepeatMessage::KeyEvent(k))
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
state.dirty = true;
|
||||
}
|
||||
wl_keyboard::Event::Modifiers {
|
||||
@@ -733,8 +736,8 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
state.pointer = Some((surface_x, surface_y));
|
||||
}
|
||||
wl_pointer::Event::Leave { .. } => state.pointer = None,
|
||||
wl_pointer::Event::Axis { axis, value, .. } => match state.pointer {
|
||||
Some((x, y)) => {
|
||||
wl_pointer::Event::Axis { axis, value, .. } => {
|
||||
if let Some((x, y)) = state.pointer {
|
||||
let axis = match axis {
|
||||
WEnum::Value(wl_pointer::Axis::VerticalScroll) => {
|
||||
PointerButton::ScrollVertical(value)
|
||||
@@ -749,24 +752,22 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
let geo = widget.geometry();
|
||||
if geo.contains(pos) {
|
||||
let pos = (pos.0 - geo.x, pos.1 - geo.y);
|
||||
let ev = Event::PointerEvent(PointerEvent {
|
||||
button: axis,
|
||||
pos: pos,
|
||||
});
|
||||
let ev = Event::PointerEvent(PointerEvent { button: axis, pos });
|
||||
widget.event(&ev);
|
||||
state.dirty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
}
|
||||
wl_pointer::Event::Button {
|
||||
button,
|
||||
state: button_state,
|
||||
..
|
||||
} => match (button, button_state, state.pointer) {
|
||||
(button, WEnum::Value(wl_pointer::ButtonState::Pressed), Some((x, y))) => {
|
||||
} => {
|
||||
if let (button, WEnum::Value(wl_pointer::ButtonState::Pressed), Some((x, y))) =
|
||||
(button, button_state, state.pointer)
|
||||
{
|
||||
let button = match button {
|
||||
BTN_LEFT => PointerButton::Left,
|
||||
BTN_RIGHT => PointerButton::Right,
|
||||
@@ -778,18 +779,14 @@ impl Dispatch<wl_pointer::WlPointer, ()> for State {
|
||||
let geo = widget.geometry();
|
||||
if geo.contains(pos) {
|
||||
let pos = (pos.0 - geo.x, pos.1 - geo.y);
|
||||
let ev = Event::PointerEvent(PointerEvent {
|
||||
button: button,
|
||||
pos: pos,
|
||||
});
|
||||
let ev = Event::PointerEvent(PointerEvent { button, pos });
|
||||
widget.event(&ev);
|
||||
state.dirty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -852,14 +849,11 @@ impl Dispatch<xdg_activation_token_v1::XdgActivationTokenV1, ()> for State {
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
) {
|
||||
match event {
|
||||
xdg_activation_token_v1::Event::Done { token } => {
|
||||
if let xdg_activation_token_v1::Event::Done { token } = event {
|
||||
let ev = Event::TokenUpdate(token);
|
||||
for widget in state.widgets.iter_mut() {
|
||||
widget.event(&ev);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+30
-22
@@ -2,18 +2,17 @@ use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashSet,
|
||||
error::Error,
|
||||
fs::{read_to_string, File},
|
||||
fs::read_to_string,
|
||||
hash::{Hash, Hasher},
|
||||
io::{Error as io_error, ErrorKind},
|
||||
path::Path,
|
||||
};
|
||||
|
||||
use serde::{self, Deserialize, Serialize};
|
||||
use simd_json;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::utils::{inish, xdg};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, Eq, Hash)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[derive(Clone, Debug, Eq)]
|
||||
pub struct Desktop {
|
||||
pub entry_type: String,
|
||||
pub name: String,
|
||||
@@ -26,7 +25,7 @@ pub struct Desktop {
|
||||
}
|
||||
|
||||
impl Desktop {
|
||||
fn parse(f: &str) -> Result<Desktop, Box<dyn Error>> {
|
||||
fn parse(f: &Path) -> Result<Desktop, Box<dyn Error>> {
|
||||
let s = read_to_string(f)?;
|
||||
let config = inish::parse(&s)?;
|
||||
match config.get("Desktop Entry") {
|
||||
@@ -43,10 +42,10 @@ impl Desktop {
|
||||
.map(|x| {
|
||||
x.split(';')
|
||||
.map(|y| y.trim().to_string())
|
||||
.filter(|z| z != "")
|
||||
.filter(|z| !z.is_empty())
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_else(|| vec![]),
|
||||
.unwrap_or_else(std::vec::Vec::new),
|
||||
}),
|
||||
None => Err(Box::new(io_error::new(
|
||||
ErrorKind::NotFound,
|
||||
@@ -74,20 +73,20 @@ impl PartialEq for Desktop {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_desktop_cache() -> Result<Vec<Desktop>, Box<dyn Error>> {
|
||||
match File::open(format!("{}/wldash/desktop.json", xdg::cache_folder())) {
|
||||
Ok(f) => simd_json::from_reader(f).map_err(|e| e.into()),
|
||||
Err(e) => Err(e.into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_desktop_cache(v: &Vec<Desktop>) -> Result<(), Box<dyn Error>> {
|
||||
match File::create(format!("{}/wldash/desktop.json", xdg::cache_folder())) {
|
||||
Ok(f) => simd_json::to_writer(f, v).map_err(|e| e.into()),
|
||||
Err(e) => Err(e.into()),
|
||||
// Must agree with PartialEq: equal entries (same name) must hash equally.
|
||||
impl Hash for Desktop {
|
||||
fn hash<H: Hasher>(&self, state: &mut H) {
|
||||
self.name.hash(state)
|
||||
}
|
||||
}
|
||||
|
||||
/// Scan every XDG applications directory for launchable entries.
|
||||
///
|
||||
/// This used to be cached as JSON under XDG_CACHE_HOME and refreshed by
|
||||
/// hand with `--desktop-refresh`. The scan is a few milliseconds over
|
||||
/// local /usr/share and runs on a background thread, while the cache sat
|
||||
/// on the (possibly NFS-mounted) home directory and went stale whenever a
|
||||
/// package was installed. So: no cache.
|
||||
pub fn load_desktop_files() -> Vec<Desktop> {
|
||||
let dirs = xdg::data_folders();
|
||||
|
||||
@@ -95,9 +94,18 @@ pub fn load_desktop_files() -> Vec<Desktop> {
|
||||
let mut seen: HashSet<String> = HashSet::new();
|
||||
|
||||
for dir in dirs {
|
||||
for entry in WalkDir::new(format!("{}/applications", dir)) {
|
||||
if let Ok(entry) = entry {
|
||||
if let Ok(d) = Desktop::parse(entry.path().to_str().unwrap()) {
|
||||
for entry in WalkDir::new(format!("{}/applications", dir))
|
||||
.into_iter()
|
||||
.flatten()
|
||||
{
|
||||
// Entries are often symlinks, so only rule out directories.
|
||||
if entry.file_type().is_dir()
|
||||
|| entry.path().extension().and_then(|e| e.to_str()) != Some("desktop")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
{
|
||||
if let Ok(d) = Desktop::parse(entry.path()) {
|
||||
if d.hidden
|
||||
|| d.no_display
|
||||
|| (d.entry_type != "Application" && d.entry_type != "Link")
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
use std::{collections::HashMap, error::Error};
|
||||
|
||||
fn parse_field<'a>(line: &'a str) -> Result<(&'a str, &'a str), Box<dyn Error>> {
|
||||
fn parse_field(line: &str) -> Result<(&str, &str), Box<dyn Error>> {
|
||||
let split = match line.find('=') {
|
||||
Some(v) => v,
|
||||
None => return Err("expected equals sign on line, but found none".into()),
|
||||
@@ -30,8 +30,8 @@ pub fn parse<'a>(s: &'a str) -> Result<Inish<'a>, Box<dyn Error>> {
|
||||
(Some('['), Some(']')) => {
|
||||
sections.insert(current_section_name, current_section);
|
||||
current_section = HashMap::new();
|
||||
let len = line.bytes().count();
|
||||
current_section_name = &line[1..len - 1].trim();
|
||||
let len = line.len();
|
||||
current_section_name = line[1..len - 1].trim();
|
||||
}
|
||||
(Some('['), v) => {
|
||||
return Err(format!(
|
||||
|
||||
@@ -10,6 +10,18 @@ pub fn cache_folder() -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// XDG_STATE_HOME: small persistent state (calculator history, saved
|
||||
/// prompt). Unlike a cache this is worth roaming with the home directory.
|
||||
pub fn state_folder() -> String {
|
||||
match env::var_os("XDG_STATE_HOME") {
|
||||
Some(s) => s.into_string().unwrap(),
|
||||
None => {
|
||||
let home = env::var_os("HOME").unwrap().into_string().unwrap();
|
||||
format!("{}/.local/state", home)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn config_folder() -> String {
|
||||
match env::var_os("XDG_CONFIG_HOME") {
|
||||
Some(s) => s.into_string().unwrap(),
|
||||
|
||||
+68
-28
@@ -1,6 +1,6 @@
|
||||
use std::{
|
||||
fs::{self, OpenOptions},
|
||||
io::{Error, ErrorKind, Write},
|
||||
io::{Error, Write},
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ fn read_file_as_u64(path: &Path) -> Result<u64, Error> {
|
||||
let mut s = fs::read_to_string(path)?;
|
||||
s.pop();
|
||||
s.parse::<u64>()
|
||||
.map_err(|_e| Error::new(ErrorKind::Other, "unable to parse value"))
|
||||
.map_err(|_e| Error::other("unable to parse value"))
|
||||
}
|
||||
|
||||
fn write_file_as_u64(path: &Path, value: u64) -> Result<(), Error> {
|
||||
@@ -26,31 +26,69 @@ fn write_file_as_u64(path: &Path, value: u64) -> Result<(), Error> {
|
||||
}
|
||||
|
||||
pub struct Backlight {
|
||||
device_path: PathBuf,
|
||||
/// `None` when no backlight exists on this machine: the widget then
|
||||
/// renders empty and ignores clicks instead of taking wldash down.
|
||||
/// Configs are shared between hosts, so a laptop config running on a
|
||||
/// desktop must not panic here.
|
||||
device_path: Option<PathBuf>,
|
||||
cur: u64,
|
||||
max: u64,
|
||||
dirty: bool,
|
||||
}
|
||||
|
||||
/// First device under /sys/class/backlight, if any. `min_depth(1)` skips the
|
||||
/// class directory itself, which otherwise got picked up as a "device".
|
||||
fn find_device() -> Option<PathBuf> {
|
||||
WalkDir::new("/sys/class/backlight")
|
||||
.min_depth(1)
|
||||
.max_depth(1)
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.map(|e| e.path().to_path_buf())
|
||||
.next()
|
||||
}
|
||||
|
||||
impl Backlight {
|
||||
fn update(&mut self) {
|
||||
self.cur = read_file_as_u64(self.device_path.join("brightness").as_path()).unwrap();
|
||||
self.max = read_file_as_u64(self.device_path.join("max_brightness").as_path()).unwrap();
|
||||
let Some(dev) = &self.device_path else {
|
||||
return;
|
||||
};
|
||||
if let Ok(cur) = read_file_as_u64(dev.join("brightness").as_path()) {
|
||||
self.cur = cur;
|
||||
}
|
||||
if let Ok(max) = read_file_as_u64(dev.join("max_brightness").as_path()) {
|
||||
self.max = max;
|
||||
}
|
||||
}
|
||||
|
||||
// Wraps the impl in the generic BarWidget on purpose.
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(path: Option<&str>, fm: &mut FontMap, font: &'static str, size: f32) -> BarWidget {
|
||||
let mut device_path = None;
|
||||
if let Some(path) = path {
|
||||
device_path = Some(Path::new("/sys/class/backlight").to_path_buf().join(path));
|
||||
let device_path = match path {
|
||||
Some(path) => {
|
||||
let p = Path::new("/sys/class/backlight").join(path);
|
||||
if p.is_dir() {
|
||||
Some(p)
|
||||
} else {
|
||||
for entry in WalkDir::new("/sys/class/backlight") {
|
||||
if let Ok(entry) = entry {
|
||||
device_path = Some(entry.path().to_path_buf());
|
||||
eprintln!(
|
||||
"wldash: backlight device {:?} not found, widget disabled",
|
||||
p
|
||||
);
|
||||
None
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let p = find_device();
|
||||
if p.is_none() {
|
||||
eprintln!(
|
||||
"wldash: no backlight device under /sys/class/backlight, widget disabled"
|
||||
);
|
||||
}
|
||||
p
|
||||
}
|
||||
};
|
||||
let mut dev = Backlight {
|
||||
device_path: device_path.expect("did not find backlight device"),
|
||||
device_path,
|
||||
cur: 0,
|
||||
max: 0,
|
||||
dirty: true,
|
||||
@@ -61,18 +99,19 @@ impl Backlight {
|
||||
}
|
||||
|
||||
pub fn detect() -> bool {
|
||||
for entry in WalkDir::new("/sys/class/backlight") {
|
||||
if entry.is_ok() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
find_device().is_some()
|
||||
}
|
||||
|
||||
pub fn set(&mut self, brightness: f32) {
|
||||
let val = (self.max as f32 * brightness) as u64;
|
||||
let _ = write_file_as_u64(self.device_path.join("brightness").as_path(), val);
|
||||
self.cur = read_file_as_u64(self.device_path.join("brightness").as_path()).unwrap();
|
||||
let Some(dev) = &self.device_path else {
|
||||
return;
|
||||
};
|
||||
let val = (self.max as f32 * brightness.clamp(0.0, 1.0)) as u64;
|
||||
let brightness_path = dev.join("brightness");
|
||||
let _ = write_file_as_u64(&brightness_path, val);
|
||||
if let Ok(cur) = read_file_as_u64(&brightness_path) {
|
||||
self.cur = cur;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,12 +123,14 @@ impl BarWidgetImpl for Backlight {
|
||||
self.dirty
|
||||
}
|
||||
fn value(&mut self) -> f32 {
|
||||
if self.cur > self.max {
|
||||
// what.
|
||||
self.dirty = false;
|
||||
if self.device_path.is_none() {
|
||||
return 0.0;
|
||||
}
|
||||
if self.max == 0 || self.cur > self.max {
|
||||
// Sysfs handed us nonsense; show full rather than a bogus ratio.
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
self.dirty = false;
|
||||
self.cur as f32 / self.max as f32
|
||||
}
|
||||
fn color(&self) -> Color {
|
||||
@@ -97,9 +138,8 @@ impl BarWidgetImpl for Backlight {
|
||||
}
|
||||
fn click(&mut self, pos: f32, btn: PointerButton) {
|
||||
self.dirty = true;
|
||||
match btn {
|
||||
PointerButton::Left => self.set(pos),
|
||||
_ => (),
|
||||
if let PointerButton::Left = btn {
|
||||
self.set(pos)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,21 +62,13 @@ impl Widget for BarWidget {
|
||||
let val = self.inner_widget.value();
|
||||
|
||||
let c = self.inner_widget.color();
|
||||
draw_bar(
|
||||
&mut view.offset((bar_offset, 0)),
|
||||
c,
|
||||
self.geometry.width - bar_offset,
|
||||
size,
|
||||
val,
|
||||
)
|
||||
.unwrap();
|
||||
let bar_width = self.geometry.width.saturating_sub(bar_offset);
|
||||
if bar_width < 2 {
|
||||
return self.geometry;
|
||||
}
|
||||
draw_bar(&mut view.offset((bar_offset, 0)), c, bar_width, size, val).unwrap();
|
||||
|
||||
draw_box(
|
||||
&mut view.offset((bar_offset, 0)),
|
||||
c,
|
||||
(self.geometry.width - bar_offset, size),
|
||||
)
|
||||
.unwrap();
|
||||
draw_box(&mut view.offset((bar_offset, 0)), c, (bar_width, size)).unwrap();
|
||||
self.geometry
|
||||
}
|
||||
|
||||
@@ -87,7 +79,7 @@ impl Widget for BarWidget {
|
||||
x += geometry.width - w;
|
||||
}
|
||||
self.geometry = Geometry {
|
||||
x: x,
|
||||
x,
|
||||
y: geometry.y,
|
||||
width: w,
|
||||
height: self.size.ceil() as u32,
|
||||
@@ -105,15 +97,12 @@ impl Widget for BarWidget {
|
||||
}
|
||||
|
||||
fn event(&mut self, event: &Event) {
|
||||
match event {
|
||||
Event::PointerEvent(ev) => {
|
||||
if let Event::PointerEvent(ev) = event {
|
||||
let offset = 4 * self.size.ceil() as u32;
|
||||
if ev.pos.0 >= offset {
|
||||
if ev.pos.0 >= offset && self.geometry.width > offset {
|
||||
let val = (ev.pos.0 - offset) as f32 / (self.geometry.width - offset) as f32;
|
||||
self.inner_widget.click(val, ev.button);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+48
-39
@@ -6,8 +6,8 @@ use std::{
|
||||
};
|
||||
|
||||
use dbus::blocking::{
|
||||
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
|
||||
LocalConnection,
|
||||
stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged},
|
||||
};
|
||||
|
||||
use crate::{
|
||||
@@ -47,77 +47,87 @@ struct InnerBattery {
|
||||
dirty: bool,
|
||||
}
|
||||
|
||||
fn get_battery_state() -> Result<UpowerBatteryState, Box<dyn Error>> {
|
||||
const DEVICE_PATH: &str = "/org/freedesktop/UPower/devices/DisplayDevice";
|
||||
const DEVICE_IFACE: &str = "org.freedesktop.UPower.Device";
|
||||
|
||||
/// True if UPower reports a present battery. The DisplayDevice object exists
|
||||
/// even on machines without a battery, so checking for mere reachability
|
||||
/// (as before) made every desktop grow a battery widget.
|
||||
fn battery_present() -> Result<bool, Box<dyn Error>> {
|
||||
let conn = LocalConnection::new_system()?;
|
||||
let device_path = "/org/freedesktop/UPower/devices/DisplayDevice";
|
||||
let proxy = conn.with_proxy(
|
||||
"org.freedesktop.UPower",
|
||||
device_path,
|
||||
DEVICE_PATH,
|
||||
Duration::from_millis(500),
|
||||
);
|
||||
let state: u32 = proxy.get("org.freedesktop.UPower.Device", "State")?;
|
||||
Ok(UpowerBatteryState::from_dbus(state as u64))
|
||||
let present: bool = proxy.get(DEVICE_IFACE, "IsPresent")?;
|
||||
Ok(present)
|
||||
}
|
||||
|
||||
fn start_monitor(inner: Arc<Mutex<InnerBattery>>, events: Arc<Mutex<Events>>) {
|
||||
thread::Builder::new()
|
||||
.name("battmon".to_string())
|
||||
.spawn(move || {
|
||||
let conn = LocalConnection::new_system().unwrap();
|
||||
let device_path = "/org/freedesktop/UPower/devices/DisplayDevice";
|
||||
fn monitor(
|
||||
inner: Arc<Mutex<InnerBattery>>,
|
||||
events: Arc<Mutex<Events>>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let conn = LocalConnection::new_system()?;
|
||||
let proxy = conn.with_proxy(
|
||||
"org.freedesktop.UPower",
|
||||
device_path,
|
||||
DEVICE_PATH,
|
||||
Duration::from_millis(500),
|
||||
);
|
||||
|
||||
let capacity: f64 = proxy
|
||||
.get("org.freedesktop.UPower.Device", "Percentage")
|
||||
.expect("unable to get property");
|
||||
let state: u32 = proxy
|
||||
.get("org.freedesktop.UPower.Device", "State")
|
||||
.expect("unable to get state");
|
||||
let capacity: f64 = proxy.get(DEVICE_IFACE, "Percentage")?;
|
||||
let state: u32 = proxy.get(DEVICE_IFACE, "State")?;
|
||||
|
||||
{
|
||||
let mut inner = inner.lock().unwrap();
|
||||
inner.value = capacity as f32 / 100.;
|
||||
inner.state = UpowerBatteryState::from_dbus(state as u64);
|
||||
inner.dirty = true;
|
||||
}
|
||||
events.lock().unwrap().add_event(Event::PowerUpdate);
|
||||
|
||||
proxy
|
||||
.match_signal(
|
||||
move |c: PropertiesPropertiesChanged,
|
||||
_: &LocalConnection,
|
||||
_: &dbus::Message| {
|
||||
if c.interface_name != "org.freedesktop.UPower.Device" {
|
||||
proxy.match_signal(
|
||||
move |c: PropertiesPropertiesChanged, _: &LocalConnection, _: &dbus::Message| {
|
||||
if c.interface_name != DEVICE_IFACE {
|
||||
return true;
|
||||
}
|
||||
let mut inner = inner.lock().unwrap();
|
||||
for (key, value) in c.changed_properties {
|
||||
match key.as_str() {
|
||||
"State" => {
|
||||
inner.state =
|
||||
UpowerBatteryState::from_dbus(value.0.as_u64().unwrap());
|
||||
if let Some(v) = value.0.as_u64() {
|
||||
inner.state = UpowerBatteryState::from_dbus(v);
|
||||
inner.dirty = true;
|
||||
let mut events = events.lock().unwrap();
|
||||
events.add_event(Event::PowerUpdate);
|
||||
events.lock().unwrap().add_event(Event::PowerUpdate);
|
||||
}
|
||||
}
|
||||
"Percentage" => {
|
||||
inner.value = value.0.as_f64().unwrap() as f32 / 100.;
|
||||
if let Some(v) = value.0.as_f64() {
|
||||
inner.value = v as f32 / 100.;
|
||||
inner.dirty = true;
|
||||
let mut events = events.lock().unwrap();
|
||||
events.add_event(Event::PowerUpdate);
|
||||
events.lock().unwrap().add_event(Event::PowerUpdate);
|
||||
}
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
true
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
)?;
|
||||
|
||||
loop {
|
||||
conn.process(Duration::from_millis(60000)).unwrap();
|
||||
conn.process(Duration::from_millis(60000))?;
|
||||
}
|
||||
}
|
||||
|
||||
fn start_monitor(inner: Arc<Mutex<InnerBattery>>, events: Arc<Mutex<Events>>) {
|
||||
thread::Builder::new()
|
||||
.name("battmon".to_string())
|
||||
.spawn(move || {
|
||||
// The release profile uses panic = "abort": a panic here would take
|
||||
// the whole dashboard down, so report and leave the bar at 0.
|
||||
if let Err(e) = monitor(inner, events) {
|
||||
eprintln!("wldash: battery monitor stopped: {}", e);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
@@ -128,6 +138,8 @@ pub struct Battery {
|
||||
}
|
||||
|
||||
impl Battery {
|
||||
// Wraps the impl in the generic BarWidget on purpose.
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(
|
||||
events: Arc<Mutex<Events>>,
|
||||
fm: &mut FontMap,
|
||||
@@ -146,10 +158,7 @@ impl Battery {
|
||||
}
|
||||
|
||||
pub fn detect() -> bool {
|
||||
match get_battery_state() {
|
||||
Ok(_) => true,
|
||||
Err(_) => false,
|
||||
}
|
||||
battery_present().unwrap_or(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-17
@@ -69,7 +69,7 @@ impl Calendar {
|
||||
fn draw_month(
|
||||
&mut self,
|
||||
fonts: &mut FontMap,
|
||||
mut view: &mut BufferView,
|
||||
view: &mut BufferView,
|
||||
orig: NaiveDate,
|
||||
mut time: NaiveDate,
|
||||
) {
|
||||
@@ -100,7 +100,7 @@ impl Calendar {
|
||||
+ (self.size * DAY_FACTOR * 0.2).ceil() as u32,
|
||||
)),
|
||||
c,
|
||||
&wk_chr,
|
||||
wk_chr,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
@@ -124,9 +124,7 @@ impl Calendar {
|
||||
12 => "December",
|
||||
_ => panic!("impossible value"),
|
||||
};
|
||||
month_font
|
||||
.draw_text(&mut view, Color::WHITE, month_str)
|
||||
.unwrap();
|
||||
month_font.draw_text(view, Color::WHITE, month_str).unwrap();
|
||||
|
||||
//
|
||||
// Draw the year
|
||||
@@ -199,7 +197,7 @@ impl Calendar {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Widget for Calendar {
|
||||
impl Widget for Calendar {
|
||||
fn get_dirty(&self) -> bool {
|
||||
self.dirty
|
||||
}
|
||||
@@ -209,12 +207,9 @@ impl<'a> Widget for Calendar {
|
||||
}
|
||||
|
||||
fn event(&mut self, event: &Event) {
|
||||
match event {
|
||||
Event::NewMinute => {
|
||||
if let Event::NewMinute = event {
|
||||
self.dirty = true;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(&mut self, fonts: &mut FontMap, view: &mut BufferView) -> Geometry {
|
||||
@@ -299,9 +294,8 @@ impl<'a> Widget for Calendar {
|
||||
self.geometry = Geometry {
|
||||
x: geometry.x,
|
||||
y: geometry.y,
|
||||
width: cal_width * self.shown_sections_x as u32
|
||||
+ cal_pad * (self.shown_sections_x as u32 - 1),
|
||||
height: cal_height * self.shown_sections_y as u32,
|
||||
width: cal_width * self.shown_sections_x + cal_pad * (self.shown_sections_x - 1),
|
||||
height: cal_height * self.shown_sections_y,
|
||||
};
|
||||
self.geometry
|
||||
}
|
||||
@@ -323,7 +317,7 @@ impl<'a> Widget for Calendar {
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
x => x,
|
||||
};
|
||||
@@ -335,7 +329,7 @@ impl<'a> Widget for Calendar {
|
||||
y: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
}
|
||||
};
|
||||
}
|
||||
y => y,
|
||||
};
|
||||
@@ -344,8 +338,8 @@ impl<'a> Widget for Calendar {
|
||||
Geometry {
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: width,
|
||||
height: height,
|
||||
width,
|
||||
height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct Clock {
|
||||
colon_width: u32,
|
||||
}
|
||||
|
||||
impl<'a> Clock {
|
||||
impl Clock {
|
||||
pub fn new(fm: &mut FontMap, font: &'static str, size: f32) -> Clock {
|
||||
fm.queue_font(font, size, "0123456789: ");
|
||||
Clock {
|
||||
@@ -33,7 +33,7 @@ impl<'a> Clock {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Widget for Clock {
|
||||
impl Widget for Clock {
|
||||
fn get_dirty(&self) -> bool {
|
||||
self.dirty
|
||||
}
|
||||
@@ -43,12 +43,9 @@ impl<'a> Widget for Clock {
|
||||
}
|
||||
|
||||
fn event(&mut self, event: &Event) {
|
||||
match event {
|
||||
Event::NewMinute => {
|
||||
if let Event::NewMinute = event {
|
||||
self.dirty = true;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(&mut self, fonts: &mut FontMap, view: &mut BufferView) -> Geometry {
|
||||
|
||||
+2
-5
@@ -29,7 +29,7 @@ impl Date {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Widget for Date {
|
||||
impl Widget for Date {
|
||||
fn get_dirty(&self) -> bool {
|
||||
self.dirty
|
||||
}
|
||||
@@ -39,12 +39,9 @@ impl<'a> Widget for Date {
|
||||
}
|
||||
|
||||
fn event(&mut self, event: &Event) {
|
||||
match event {
|
||||
Event::NewMinute => {
|
||||
if let Event::NewMinute = event {
|
||||
self.dirty = true;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn draw(&mut self, fonts: &mut FontMap, view: &mut BufferView) -> Geometry {
|
||||
|
||||
+200
-66
@@ -1,10 +1,10 @@
|
||||
use std::{
|
||||
cmp::{max, min, Ordering},
|
||||
cmp::{Ordering, max, min},
|
||||
collections::HashMap,
|
||||
default::Default,
|
||||
fs::{read_to_string, File},
|
||||
fs::{File, read_to_string},
|
||||
io::Write,
|
||||
process::{exit, Command},
|
||||
process::{Command, exit},
|
||||
sync::{Arc, Mutex},
|
||||
thread,
|
||||
};
|
||||
@@ -14,18 +14,18 @@ use crate::{
|
||||
color::Color,
|
||||
event::{Event, Events, PointerButton, PointerEvent},
|
||||
fonts::FontMap,
|
||||
keyboard::{keysyms, KeyEvent},
|
||||
keyboard::{KeyEvent, keysyms},
|
||||
utils::{
|
||||
desktop::{load_desktop_cache, load_desktop_files, write_desktop_cache, Desktop},
|
||||
desktop::{Desktop, load_desktop_files},
|
||||
xdg,
|
||||
},
|
||||
widgets::{Geometry, Widget},
|
||||
};
|
||||
|
||||
use fuzzy_matcher::skim::SkimMatcherV2;
|
||||
use fuzzy_matcher::FuzzyMatcher;
|
||||
use fuzzy_matcher::skim::SkimMatcherV2;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use wayland_client::{protocol::wl_keyboard, WEnum};
|
||||
use wayland_client::{WEnum, protocol::wl_keyboard};
|
||||
|
||||
struct Matcher {
|
||||
matches: HashMap<Desktop, i64>,
|
||||
@@ -96,13 +96,19 @@ impl Prompt {
|
||||
}
|
||||
}
|
||||
|
||||
/// Length of the input in graphemes. The cursor is a grapheme index, not
|
||||
/// a byte offset, so this (and never `input.len()`) is the upper bound.
|
||||
fn len(&self) -> usize {
|
||||
self.input.graphemes(true).count()
|
||||
}
|
||||
|
||||
fn move_cursor(&mut self, distance: isize) {
|
||||
let new_cursor = self.cursor as isize + distance;
|
||||
let len = self.len() as isize;
|
||||
if new_cursor < 0 {
|
||||
self.cursor = 0;
|
||||
return;
|
||||
} else if new_cursor > self.input.len() as isize {
|
||||
self.cursor = self.input.len()
|
||||
} else if new_cursor > len {
|
||||
self.cursor = len as usize;
|
||||
} else {
|
||||
self.cursor = new_cursor as usize;
|
||||
}
|
||||
@@ -110,11 +116,11 @@ impl Prompt {
|
||||
|
||||
fn set(&mut self, v: &str) {
|
||||
self.input = v.to_string();
|
||||
self.cursor = self.input.len();
|
||||
self.cursor = self.len();
|
||||
}
|
||||
|
||||
fn append(&mut self, v: &str) {
|
||||
if self.input.len() == 0 {
|
||||
if self.input.is_empty() {
|
||||
match v {
|
||||
"!" => {
|
||||
self.mode = PromptMode::Shell;
|
||||
@@ -128,13 +134,14 @@ impl Prompt {
|
||||
}
|
||||
}
|
||||
let indices: Vec<(usize, &str)> = self.input.grapheme_indices(true).collect();
|
||||
if self.cursor == indices.len() {
|
||||
self.input += &v;
|
||||
if self.cursor >= indices.len() {
|
||||
self.cursor = indices.len();
|
||||
self.input += v;
|
||||
} else {
|
||||
let index_at = indices[self.cursor].0;
|
||||
self.input.insert_str(index_at, &v);
|
||||
self.input.insert_str(index_at, v);
|
||||
}
|
||||
self.cursor += 1;
|
||||
self.cursor += v.graphemes(true).count();
|
||||
}
|
||||
|
||||
fn backspace(&mut self) {
|
||||
@@ -168,6 +175,7 @@ impl Prompt {
|
||||
fn clear_right(&mut self) {
|
||||
let indices: Vec<(usize, &str)> = self.input.grapheme_indices(true).collect();
|
||||
if !indices.is_empty() {
|
||||
self.cursor = min(self.cursor, indices.len());
|
||||
self.input = indices[0..self.cursor]
|
||||
.iter()
|
||||
.fold("".into(), |acc, el| acc + el.1);
|
||||
@@ -179,6 +187,7 @@ impl Prompt {
|
||||
fn clear_left(&mut self) {
|
||||
let indices: Vec<(usize, &str)> = self.input.grapheme_indices(true).collect();
|
||||
if !indices.is_empty() {
|
||||
self.cursor = min(self.cursor, indices.len());
|
||||
self.input = indices[self.cursor..indices.len()]
|
||||
.iter()
|
||||
.fold("".into(), |acc, el| acc + el.1);
|
||||
@@ -193,11 +202,55 @@ impl Prompt {
|
||||
}
|
||||
|
||||
fn end(&mut self) {
|
||||
self.cursor = self.input.len();
|
||||
self.cursor = self.len();
|
||||
}
|
||||
}
|
||||
|
||||
/// Strip desktop-entry field codes (%f, %u, %i, %c, ...) from an Exec line and
|
||||
/// unescape `%%`. We never pass files/URLs, so the codes expand to nothing.
|
||||
fn strip_field_codes(exec: &str) -> String {
|
||||
let mut out = String::with_capacity(exec.len());
|
||||
let mut chars = exec.chars().peekable();
|
||||
while let Some(c) = chars.next() {
|
||||
if c != '%' {
|
||||
out.push(c);
|
||||
continue;
|
||||
}
|
||||
match chars.next() {
|
||||
Some('%') => out.push('%'),
|
||||
Some(_) => (),
|
||||
None => (),
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Path of a small persistent state file (calc history, saved prompt)
|
||||
/// under $XDG_STATE_HOME/wldash.
|
||||
fn state_path(name: &str) -> String {
|
||||
format!("{}/wldash/{}", xdg::state_folder(), name)
|
||||
}
|
||||
|
||||
/// Read a state file, falling back to where older versions kept it
|
||||
/// ($XDG_CACHE_HOME/wldash) so nothing is lost on upgrade.
|
||||
fn read_state(name: &str) -> Option<String> {
|
||||
read_to_string(state_path(name))
|
||||
.or_else(|_| read_to_string(format!("{}/wldash/{}", xdg::cache_folder(), name)))
|
||||
.ok()
|
||||
}
|
||||
|
||||
/// Create (truncate) a state file, making the directory on demand.
|
||||
fn create_state(name: &str) -> Option<File> {
|
||||
let path = state_path(name);
|
||||
if let Some(dir) = std::path::Path::new(&path).parent() {
|
||||
let _ = std::fs::create_dir_all(dir);
|
||||
}
|
||||
File::create(path).ok()
|
||||
}
|
||||
|
||||
trait InterfaceWidget {
|
||||
/// Number of selectable rows (used to clamp the selection).
|
||||
fn rows(&self) -> usize;
|
||||
fn trigger(&mut self, intf: &mut InnerInterface);
|
||||
fn draw(
|
||||
&mut self,
|
||||
@@ -223,16 +276,8 @@ impl Launcher {
|
||||
thread::Builder::new()
|
||||
.name("desktopini".to_string())
|
||||
.spawn(move || {
|
||||
let mut options = options.lock().unwrap();
|
||||
*options = match load_desktop_cache() {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
let v = load_desktop_files();
|
||||
write_desktop_cache(&v).unwrap();
|
||||
v
|
||||
}
|
||||
};
|
||||
drop(options);
|
||||
let loaded = load_desktop_files();
|
||||
*options.lock().unwrap() = loaded;
|
||||
let mut events = events.lock().unwrap();
|
||||
events.add_event(Event::LauncherUpdate);
|
||||
})
|
||||
@@ -241,7 +286,7 @@ impl Launcher {
|
||||
|
||||
Launcher {
|
||||
next_token: None,
|
||||
options: options,
|
||||
options,
|
||||
matches: Vec::new(),
|
||||
launch_cmd,
|
||||
}
|
||||
@@ -258,24 +303,37 @@ impl Launcher {
|
||||
} else {
|
||||
cmd.arg(cmdline);
|
||||
}
|
||||
cmd.spawn().unwrap();
|
||||
exit(0);
|
||||
match cmd.spawn() {
|
||||
Ok(_) => exit(0),
|
||||
Err(e) => {
|
||||
eprintln!("wldash: failed to launch {:?}: {}", cmdline, e);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InterfaceWidget for Launcher {
|
||||
fn rows(&self) -> usize {
|
||||
self.matches.len()
|
||||
}
|
||||
|
||||
fn trigger(&mut self, intf: &mut InnerInterface) {
|
||||
if self.matches.len() > intf.selection {
|
||||
let d = &self.matches[intf.selection];
|
||||
if let Some(exec) = &d.exec {
|
||||
let exec = exec
|
||||
.replace("%f", "")
|
||||
.replace("%F", "")
|
||||
.replace("%u", "")
|
||||
.replace("%U", "");
|
||||
|
||||
self.exec(&exec);
|
||||
}
|
||||
let cmd = match (&d.exec, &d.url) {
|
||||
(Some(exec), _) => strip_field_codes(exec),
|
||||
// Type=Link entries have no Exec; open the URL instead.
|
||||
(None, Some(url)) => format!("xdg-open '{}'", url.replace('\'', "'\\''")),
|
||||
(None, None) => return,
|
||||
};
|
||||
// Terminal=true: run inside the user's terminal when one is
|
||||
// configured, otherwise as before.
|
||||
let cmd = match (d.term, std::env::var("TERMINAL")) {
|
||||
(true, Ok(term)) if !term.is_empty() => format!("{} -e {}", term, cmd),
|
||||
_ => cmd,
|
||||
};
|
||||
self.exec(&cmd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +379,7 @@ impl InterfaceWidget for Launcher {
|
||||
.auto_draw_text_with_cursor(
|
||||
&mut prompt_line,
|
||||
fg,
|
||||
&format!(" {}", &intf.prompt.input),
|
||||
&format!(" {}", intf.prompt.input),
|
||||
intf.prompt.cursor + 3,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -345,8 +403,9 @@ impl InterfaceWidget for Launcher {
|
||||
.fuzzy_indices(&m.name.to_lowercase(), &intf.prompt.input.to_lowercase())
|
||||
.unwrap_or((0, vec![]));
|
||||
|
||||
let mut colors = Vec::with_capacity(m.name.len());
|
||||
for pos in 0..m.name.len() {
|
||||
let nchars = m.name.chars().count();
|
||||
let mut colors = Vec::with_capacity(nchars);
|
||||
for pos in 0..nchars {
|
||||
if indices.contains(&pos) {
|
||||
colors.push(Color::LIGHTORANGE);
|
||||
} else {
|
||||
@@ -394,12 +453,21 @@ impl Shell {
|
||||
if let Some(token) = &self.next_token {
|
||||
cmd.env("XDG_ACTIVATION_TOKEN", token);
|
||||
}
|
||||
cmd.args(&args[1..]).spawn().unwrap();
|
||||
exit(0);
|
||||
match cmd.args(&args[1..]).spawn() {
|
||||
Ok(_) => exit(0),
|
||||
Err(e) => {
|
||||
eprintln!("wldash: failed to run {:?}: {}", args, e);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl InterfaceWidget for Shell {
|
||||
fn rows(&self) -> usize {
|
||||
1
|
||||
}
|
||||
|
||||
fn trigger(&mut self, intf: &mut InnerInterface) {
|
||||
let args = vec![
|
||||
"/bin/sh".to_string(),
|
||||
@@ -431,7 +499,7 @@ impl InterfaceWidget for Shell {
|
||||
.auto_draw_text_with_cursor(
|
||||
&mut prompt_line,
|
||||
fg,
|
||||
&format!(" {}", &intf.prompt.input),
|
||||
&format!(" {}", intf.prompt.input),
|
||||
intf.prompt.cursor + 3,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -459,9 +527,9 @@ impl Calc {
|
||||
thread::Builder::new()
|
||||
.name("calc".to_string())
|
||||
.spawn(move || {
|
||||
let s = match read_to_string(format!("{}/wldash/calc", xdg::cache_folder())) {
|
||||
Ok(s) => s,
|
||||
_ => return,
|
||||
let s = match read_state("calc") {
|
||||
Some(s) => s,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let mut old = old_local.lock().unwrap();
|
||||
@@ -481,20 +549,25 @@ impl Calc {
|
||||
}
|
||||
|
||||
fn sync(&self) {
|
||||
let mut f = match File::create(format!("{}/wldash/calc", xdg::cache_folder())) {
|
||||
Ok(f) => f,
|
||||
_ => return,
|
||||
let mut f = match create_state("calc") {
|
||||
Some(f) => f,
|
||||
None => return,
|
||||
};
|
||||
|
||||
let old = self.old.lock().unwrap();
|
||||
for (input, res) in old.iter() {
|
||||
write!(f, "{}={}\n", input, res).unwrap();
|
||||
writeln!(f, "{}={}", input, res).unwrap();
|
||||
}
|
||||
f.sync_data().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl InterfaceWidget for Calc {
|
||||
fn rows(&self) -> usize {
|
||||
// The live result plus the history entries.
|
||||
self.old.lock().unwrap().len() + 1
|
||||
}
|
||||
|
||||
fn trigger(&mut self, intf: &mut InnerInterface) {
|
||||
let mut old = self.old.lock().unwrap();
|
||||
if intf.selection == 0 {
|
||||
@@ -519,10 +592,7 @@ impl InterfaceWidget for Calc {
|
||||
rcalc_lib::parse::eval(&intf.prompt.input, &mut rcalc_lib::parse::CalcState::new())
|
||||
.map(|x| format!("{}", x))
|
||||
.map_err(|x| format!("{}", x));
|
||||
self.result = match res {
|
||||
Ok(v) => Some(v),
|
||||
Err(_) => None,
|
||||
};
|
||||
self.result = res.ok();
|
||||
}
|
||||
|
||||
fn draw(
|
||||
@@ -545,7 +615,7 @@ impl InterfaceWidget for Calc {
|
||||
font.auto_draw_text_with_cursor(
|
||||
&mut prompt_line,
|
||||
fg,
|
||||
&format!(" {} ", &intf.prompt.input),
|
||||
&format!(" {} ", intf.prompt.input),
|
||||
intf.prompt.cursor + 3,
|
||||
)
|
||||
.unwrap();
|
||||
@@ -641,7 +711,10 @@ impl Interface {
|
||||
fn pointer_input(&mut self, event: &PointerEvent) {
|
||||
if let PointerButton::Left = event.button {
|
||||
let line_height = self.inner.size.ceil() as u32;
|
||||
let height = self.inner.geometry.height - line_height - 8;
|
||||
if line_height == 0 {
|
||||
return;
|
||||
}
|
||||
let height = self.inner.geometry.height.saturating_sub(line_height + 8);
|
||||
let lines = height / line_height;
|
||||
|
||||
let offset = height % line_height;
|
||||
@@ -650,19 +723,24 @@ impl Interface {
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
self.inner.selection = (lines - pos / line_height - 1) as usize;
|
||||
let row = pos / line_height;
|
||||
if row >= lines {
|
||||
// Click landed on the prompt line or below.
|
||||
return;
|
||||
}
|
||||
self.inner.selection = (lines - row - 1) as usize;
|
||||
self.inner.dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
fn exit(&mut self) {
|
||||
if self.inner.prompt.input.len() == 0 {
|
||||
if self.inner.prompt.input.is_empty() {
|
||||
std::process::exit(0);
|
||||
}
|
||||
|
||||
if let Ok(mut f) = File::create(format!("{}/wldash/prompt", xdg::cache_folder())) {
|
||||
write!(f, "{}", self.inner.prompt.input).unwrap();
|
||||
f.sync_data().unwrap();
|
||||
if let Some(mut f) = create_state("prompt") {
|
||||
let _ = write!(f, "{}", self.inner.prompt.input);
|
||||
let _ = f.sync_data();
|
||||
}
|
||||
std::process::exit(0);
|
||||
}
|
||||
@@ -691,7 +769,7 @@ impl Interface {
|
||||
widget.update(&self.inner);
|
||||
}
|
||||
keysyms::KEY_r if event.modifiers.ctrl => {
|
||||
if let Ok(s) = read_to_string(format!("{}/wldash/prompt", xdg::cache_folder())) {
|
||||
if let Some(s) = read_state("prompt") {
|
||||
self.inner.prompt.set(&s);
|
||||
}
|
||||
}
|
||||
@@ -712,8 +790,11 @@ impl Interface {
|
||||
keysyms::KEY_Left => self.inner.prompt.move_cursor(-1),
|
||||
keysyms::KEY_Right => self.inner.prompt.move_cursor(1),
|
||||
keysyms::KEY_Up => {
|
||||
let max = widget.rows().saturating_sub(1);
|
||||
if self.inner.selection < max {
|
||||
self.inner.selection += 1;
|
||||
}
|
||||
}
|
||||
keysyms::KEY_Down => {
|
||||
if self.inner.selection > 0 {
|
||||
self.inner.selection -= 1;
|
||||
@@ -721,7 +802,7 @@ impl Interface {
|
||||
}
|
||||
_ => {
|
||||
if let Some(utf8) = &event.utf8 {
|
||||
self.inner.prompt.append(&utf8);
|
||||
self.inner.prompt.append(utf8);
|
||||
self.inner.selection = 0;
|
||||
widget.update(&self.inner);
|
||||
} else {
|
||||
@@ -751,7 +832,7 @@ impl Widget for Interface {
|
||||
}
|
||||
|
||||
fn geometry_update(&mut self, _fonts: &mut FontMap, geometry: &Geometry) -> Geometry {
|
||||
self.inner.geometry = geometry.clone();
|
||||
self.inner.geometry = *geometry;
|
||||
self.inner.geometry
|
||||
}
|
||||
|
||||
@@ -781,3 +862,56 @@ impl Widget for Interface {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Prompt, PromptMode, strip_field_codes};
|
||||
|
||||
#[test]
|
||||
fn prompt_cursor_is_grapheme_based() {
|
||||
let mut p = Prompt::new();
|
||||
p.append("ø");
|
||||
p.append("å");
|
||||
assert_eq!(p.cursor, 2);
|
||||
p.end();
|
||||
assert_eq!(p.cursor, 2);
|
||||
// Used to index past the grapheme table and panic.
|
||||
p.append("a");
|
||||
assert_eq!(p.input, "øåa");
|
||||
p.move_cursor(-10);
|
||||
assert_eq!(p.cursor, 0);
|
||||
p.move_cursor(100);
|
||||
assert_eq!(p.cursor, 3);
|
||||
p.backspace();
|
||||
assert_eq!(p.input, "øå");
|
||||
p.home();
|
||||
p.delete();
|
||||
assert_eq!(p.input, "å");
|
||||
p.set("blå");
|
||||
assert_eq!(p.cursor, 3);
|
||||
p.move_cursor(-1);
|
||||
p.clear_right();
|
||||
assert_eq!(p.input, "bl");
|
||||
p.clear_left();
|
||||
assert_eq!(p.input, "");
|
||||
assert_eq!(p.cursor, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn prompt_prefix_switches_mode() {
|
||||
let mut p = Prompt::new();
|
||||
p.append("=");
|
||||
assert!(matches!(p.mode, PromptMode::Calc));
|
||||
assert_eq!(p.input, "");
|
||||
p.backspace();
|
||||
assert!(matches!(p.mode, PromptMode::Normal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn field_codes_are_stripped() {
|
||||
assert_eq!(strip_field_codes("firefox %u"), "firefox ");
|
||||
assert_eq!(strip_field_codes("app --icon %i %c %k"), "app --icon ");
|
||||
assert_eq!(strip_field_codes("echo 100%% %F"), "echo 100% ");
|
||||
assert_eq!(strip_field_codes("plain"), "plain");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// Constructors here deliberately return Box<dyn Layout> so configs compose.
|
||||
#![allow(clippy::new_ret_no_self)]
|
||||
|
||||
use std::cmp::max;
|
||||
|
||||
use crate::{fonts::FontMap, state::State, widgets::Geometry};
|
||||
@@ -30,7 +33,7 @@ impl Layout for HorizontalLayout {
|
||||
geometry: &Geometry,
|
||||
state: &mut State,
|
||||
) -> Geometry {
|
||||
let mut geo = geometry.clone();
|
||||
let mut geo = *geometry;
|
||||
let mut max_width = 0;
|
||||
let mut max_height = 0;
|
||||
for w in self.widgets.iter() {
|
||||
@@ -79,7 +82,7 @@ impl Layout for VerticalLayout {
|
||||
geometry: &Geometry,
|
||||
state: &mut State,
|
||||
) -> Geometry {
|
||||
let mut geo = geometry.clone();
|
||||
let mut geo = *geometry;
|
||||
let mut max_width = 0;
|
||||
let mut max_height = 0;
|
||||
for w in self.widgets.iter() {
|
||||
@@ -159,10 +162,10 @@ impl Layout for InvertedHorizontalLayout {
|
||||
geometry: &Geometry,
|
||||
state: &mut State,
|
||||
) -> Geometry {
|
||||
let mut geo = geometry.clone();
|
||||
let mut geo = *geometry;
|
||||
let mut max_height = 0;
|
||||
for w in self.widgets.iter() {
|
||||
let mut temp_geo = geo.clone();
|
||||
let mut temp_geo = geo;
|
||||
let temp_result = w.geometry_update(fonts, &temp_geo, state);
|
||||
temp_geo.x = geo.x + (geo.width - temp_result.width);
|
||||
let result = w.geometry_update(fonts, &temp_geo, state);
|
||||
@@ -207,10 +210,10 @@ impl Layout for InvertedVerticalLayout {
|
||||
geometry: &Geometry,
|
||||
state: &mut State,
|
||||
) -> Geometry {
|
||||
let mut geo = geometry.clone();
|
||||
let mut geo = *geometry;
|
||||
let mut max_width = 0;
|
||||
for w in self.widgets.iter() {
|
||||
let mut temp_geo = geo.clone();
|
||||
let mut temp_geo = geo;
|
||||
let temp_result = w.geometry_update(fonts, &temp_geo, state);
|
||||
temp_geo.y = geo.y + (geo.height - temp_result.height);
|
||||
let result = w.geometry_update(fonts, &temp_geo, state);
|
||||
|
||||
+32
-19
@@ -26,13 +26,13 @@ fn monitor(
|
||||
use libpulse_binding::{
|
||||
callbacks::ListResult,
|
||||
context::{
|
||||
subscribe::{Facility, InterestMaskSet},
|
||||
Context, FlagSet, State,
|
||||
subscribe::{Facility, InterestMaskSet},
|
||||
},
|
||||
mainloop::{
|
||||
self, api::Mainloop, events::io::FlagSet as IoFlagSet, standard::IterateResult,
|
||||
},
|
||||
proplist::{properties, Proplist},
|
||||
proplist::{Proplist, properties},
|
||||
volume::Volume,
|
||||
};
|
||||
|
||||
@@ -48,10 +48,17 @@ fn monitor(
|
||||
context.borrow_mut().connect(None, FlagSet::NOFLAGS, None)?;
|
||||
|
||||
loop {
|
||||
mainloop.iterate(false);
|
||||
match mainloop.iterate(true) {
|
||||
IterateResult::Quit(_) | IterateResult::Err(_) => {
|
||||
return Err("pulseaudio mainloop quit while connecting".into());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
match context.borrow().get_state() {
|
||||
State::Ready => break,
|
||||
State::Failed | State::Terminated => panic!("damn"),
|
||||
State::Failed | State::Terminated => {
|
||||
return Err("could not connect to pulseaudio".into());
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -60,15 +67,15 @@ fn monitor(
|
||||
let local_inner = inner.clone();
|
||||
let local_events = events.clone();
|
||||
context.borrow_mut().set_subscribe_callback(Some(Box::new(
|
||||
move |facility, _operation, index| match facility {
|
||||
Some(Facility::Sink) => {
|
||||
move |facility, _operation, index| {
|
||||
if let Some(Facility::Sink) = facility {
|
||||
let introspector = local_context.borrow_mut().introspect();
|
||||
let inner = local_inner.clone();
|
||||
let events = local_events.clone();
|
||||
introspector.get_sink_info_by_index(index, move |res| match res {
|
||||
ListResult::End | ListResult::Error => (),
|
||||
ListResult::Item(sink_info) => {
|
||||
if let Some(_) = &sink_info.name {
|
||||
if sink_info.name.is_some() {
|
||||
let avg = sink_info.volume.avg().0 as f32 / Volume::NORMAL.0 as f32;
|
||||
let mut inner = inner.lock().unwrap();
|
||||
inner.volume = avg;
|
||||
@@ -81,7 +88,6 @@ fn monitor(
|
||||
}
|
||||
});
|
||||
}
|
||||
_ => (),
|
||||
},
|
||||
)));
|
||||
|
||||
@@ -94,7 +100,7 @@ fn monitor(
|
||||
introspector.get_sink_info_by_name("@DEFAULT_SINK@", move |res| match res {
|
||||
ListResult::End | ListResult::Error => (),
|
||||
ListResult::Item(sink_info) => {
|
||||
if let Some(_) = &sink_info.name {
|
||||
if sink_info.name.is_some() {
|
||||
let avg = sink_info.volume.avg().0 as f32 / Volume::NORMAL.0 as f32;
|
||||
let mut inner = local_inner.lock().unwrap();
|
||||
inner.volume = avg;
|
||||
@@ -112,7 +118,7 @@ fn monitor(
|
||||
let local_context = context.clone();
|
||||
let local_inner = inner.clone();
|
||||
let event_source = mainloop.new_io_event(
|
||||
pipe as i32,
|
||||
pipe,
|
||||
IoFlagSet::INPUT,
|
||||
Box::new(move |_, _, _| {
|
||||
let mut buf = [0; 8];
|
||||
@@ -120,15 +126,14 @@ fn monitor(
|
||||
|
||||
let mut inner = local_inner.lock().unwrap();
|
||||
let mut introspector = local_context.borrow_mut().introspect();
|
||||
match inner.last_click.take() {
|
||||
Some(Change::Volume(volume)) => {
|
||||
// do something
|
||||
let mut vol = inner.channel_volume.unwrap();
|
||||
// Clicks arriving before the first sink query finished have no
|
||||
// channel map to work with; drop them instead of panicking.
|
||||
match (inner.last_click.take(), inner.channel_volume) {
|
||||
(Some(Change::Volume(volume)), Some(mut vol)) => {
|
||||
vol.scale(Volume((volume * Volume::NORMAL.0 as f32).round() as u32));
|
||||
introspector.set_sink_volume_by_name("@DEFAULT_SINK@", &vol, None);
|
||||
}
|
||||
Some(Change::VolumeInc(value)) => {
|
||||
let mut vol = inner.channel_volume.unwrap();
|
||||
(Some(Change::VolumeInc(value)), Some(mut vol)) => {
|
||||
// apply step to volumes
|
||||
let step = (value * Volume::NORMAL.0 as f32).round() as i32;
|
||||
if step > 0 {
|
||||
@@ -141,10 +146,10 @@ fn monitor(
|
||||
inner.channel_volume = Some(vol);
|
||||
introspector.set_sink_volume_by_name("@DEFAULT_SINK@", &vol, None);
|
||||
}
|
||||
Some(Change::ToggleMute) => {
|
||||
(Some(Change::ToggleMute), _) => {
|
||||
introspector.set_sink_mute_by_name("@DEFAULT_SINK@", !inner.mute, None);
|
||||
}
|
||||
None => (),
|
||||
_ => (),
|
||||
}
|
||||
}),
|
||||
);
|
||||
@@ -165,7 +170,13 @@ fn monitor(
|
||||
fn start_monitor(events: Arc<Mutex<Events>>, inner: Arc<Mutex<InnerAudio>>, pipe: RawFd) {
|
||||
thread::Builder::new()
|
||||
.name("audiomon".to_string())
|
||||
.spawn(move || monitor(events, inner, pipe).unwrap())
|
||||
.spawn(move || {
|
||||
// panic = "abort" in release: a failed audio connection must not
|
||||
// kill the dashboard. The widget simply stays at 0.
|
||||
if let Err(e) = monitor(events, inner, pipe) {
|
||||
eprintln!("wldash: audio monitor stopped: {}", e);
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
@@ -189,6 +200,8 @@ pub struct PulseAudio {
|
||||
}
|
||||
|
||||
impl PulseAudio {
|
||||
// Wraps the impl in the generic BarWidget on purpose.
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub fn new(
|
||||
events: Arc<Mutex<Events>>,
|
||||
fm: &mut FontMap,
|
||||
|
||||
+31
-1
@@ -40,7 +40,7 @@ impl Geometry {
|
||||
x,
|
||||
y,
|
||||
width: max(self.width + self.x, other.width + other.x) - x,
|
||||
height: max(self.height + self.y, other.height + other.height) - y,
|
||||
height: max(self.height + self.y, other.height + other.y) - y,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,3 +64,33 @@ pub trait Widget {
|
||||
fn draw(&mut self, fonts: &mut FontMap, view: &mut BufferView) -> Geometry;
|
||||
fn event(&mut self, _event: &Event) {}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Geometry;
|
||||
|
||||
#[test]
|
||||
fn expand_is_bounding_box() {
|
||||
let a = Geometry {
|
||||
x: 10,
|
||||
y: 20,
|
||||
width: 5,
|
||||
height: 5,
|
||||
};
|
||||
let b = Geometry {
|
||||
x: 0,
|
||||
y: 100,
|
||||
width: 2,
|
||||
height: 2,
|
||||
};
|
||||
let e = a.expand(b);
|
||||
assert_eq!((e.x, e.y), (0, 20));
|
||||
assert_eq!(e.x + e.width, 15);
|
||||
assert_eq!(e.y + e.height, 102);
|
||||
let e2 = b.expand(a);
|
||||
assert_eq!(
|
||||
(e2.x, e2.y, e2.width, e2.height),
|
||||
(e.x, e.y, e.width, e.height)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user