Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
162d19d330 | ||
|
|
432a1e0d26 | ||
|
|
5b8a3bec41 | ||
|
|
ba12434b9b | ||
|
|
37e05c8aaf | ||
|
|
816fc96850 | ||
|
|
184d6a1ba5 | ||
|
|
5235fe30a0 | ||
|
|
a2745ac0b0 | ||
|
|
0d969ad4a2 | ||
|
|
1c79b21d55 | ||
|
|
2310a001ba | ||
|
|
e39b52cf05 |
-11
@@ -1,11 +0,0 @@
|
|||||||
image: archlinux
|
|
||||||
packages:
|
|
||||||
- rust
|
|
||||||
- libpulse
|
|
||||||
tasks:
|
|
||||||
- rustfmt-check: |
|
|
||||||
cd wldash
|
|
||||||
cargo fmt -- --check
|
|
||||||
- build: |
|
|
||||||
cd wldash
|
|
||||||
cargo build
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
/target
|
|
||||||
**/*.rs.bk
|
|
||||||
Generated
-848
@@ -1,848 +0,0 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
|
||||||
# It is not intended for manual editing.
|
|
||||||
[[package]]
|
|
||||||
name = "alsa"
|
|
||||||
version = "0.3.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"alsa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "alsa-sys"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "andrew"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rusttype 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "approx"
|
|
||||||
version = "0.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "arrayvec"
|
|
||||||
version = "0.4.11"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "autocfg"
|
|
||||||
version = "0.1.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "0.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bitflags"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block-buffer"
|
|
||||||
version = "0.7.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "block-padding"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byte-tools"
|
|
||||||
version = "0.3.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byteorder"
|
|
||||||
version = "1.3.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cc"
|
|
||||||
version = "1.0.41"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cfg-if"
|
|
||||||
version = "0.1.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "chrono"
|
|
||||||
version = "0.4.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dbus"
|
|
||||||
version = "0.6.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libdbus-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "digest"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dlib"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "downcast-rs"
|
|
||||||
version = "1.0.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "dtoa"
|
|
||||||
version = "0.4.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fake-simd"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fuzzy-matcher"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "generic-array"
|
|
||||||
version = "0.12.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itoa"
|
|
||||||
version = "0.4.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "lazy_static"
|
|
||||||
version = "1.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libc"
|
|
||||||
version = "0.2.62"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libdbus-sys"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libloading"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libpulse-binding"
|
|
||||||
version = "2.11.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libpulse-sys 1.9.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "libpulse-sys"
|
|
||||||
version = "1.9.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "line_drawing"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "linked-hash-map"
|
|
||||||
version = "0.5.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "maplit"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "memmap"
|
|
||||||
version = "0.7.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.13.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.14.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nix"
|
|
||||||
version = "0.15.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nodrop"
|
|
||||||
version = "0.1.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-bigint"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-complex"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-integer"
|
|
||||||
version = "0.1.41"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-rational"
|
|
||||||
version = "0.2.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-traits"
|
|
||||||
version = "0.2.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "opaque-debug"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ordered-float"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "os_pipe"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pest"
|
|
||||||
version = "2.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pest_derive"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pest_generator"
|
|
||||||
version = "2.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pest_meta"
|
|
||||||
version = "2.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pkg-config"
|
|
||||||
version = "0.3.15"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "0.4.30"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "proc-macro2"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "0.6.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "quote"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rcalc_lib"
|
|
||||||
version = "0.9.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redox_syscall"
|
|
||||||
version = "0.1.56"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rust-ini"
|
|
||||||
version = "0.13.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rusttype"
|
|
||||||
version = "0.7.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ryu"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "same-file"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde"
|
|
||||||
version = "1.0.99"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_derive"
|
|
||||||
version = "1.0.99"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_json"
|
|
||||||
version = "1.0.40"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serde_yaml"
|
|
||||||
version = "0.8.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "sha-1"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "shlex"
|
|
||||||
version = "0.1.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "smithay-client-toolkit"
|
|
||||||
version = "0.6.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-client 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-protocols 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "stb_truetype"
|
|
||||||
version = "0.2.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "0.15.44"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "time"
|
|
||||||
version = "0.1.42"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "timerfd"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typenum"
|
|
||||||
version = "1.11.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "ucd-trie"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "unicode-xid"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "void"
|
|
||||||
version = "1.0.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "walkdir"
|
|
||||||
version = "2.2.9"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-client"
|
|
||||||
version = "0.23.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-commons 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-scanner 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-sys 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-commons"
|
|
||||||
version = "0.23.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-sys 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-protocols"
|
|
||||||
version = "0.23.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-client 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-commons 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-scanner 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-scanner"
|
|
||||||
version = "0.23.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wayland-sys"
|
|
||||||
version = "0.23.5"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-i686-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-util"
|
|
||||||
version = "0.1.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "winapi-x86_64-pc-windows-gnu"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wldash"
|
|
||||||
version = "0.2.0"
|
|
||||||
dependencies = [
|
|
||||||
"alsa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"dbus 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"fuzzy-matcher 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"libpulse-binding 2.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"os_pipe 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rcalc_lib 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"rusttype 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"smithay-client-toolkit 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"timerfd 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-client 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"wayland-protocols 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xdg"
|
|
||||||
version = "2.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "xml-rs"
|
|
||||||
version = "0.8.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "yaml-rust"
|
|
||||||
version = "0.4.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
dependencies = [
|
|
||||||
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
]
|
|
||||||
|
|
||||||
[metadata]
|
|
||||||
"checksum alsa 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fe6a5e4eb4879d7cb8d19161927fbf825f0d89761776359c9cf4f9c9c2f35c52"
|
|
||||||
"checksum alsa-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b0edcbbf9ef68f15ae1b620f722180b82a98b6f0628d30baa6b8d2a5abc87d58"
|
|
||||||
"checksum andrew 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9b7f09f89872c2b6b29e319377b1fbe91c6f5947df19a25596e121cf19a7b35e"
|
|
||||||
"checksum approx 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0e60b75072ecd4168020818c0107f2857bb6c4e64252d8d3983f6263b40a5c3"
|
|
||||||
"checksum arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba"
|
|
||||||
"checksum autocfg 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b671c8fb71b457dd4ae18c4ba1e59aa81793daacc361d82fcd410cef0d491875"
|
|
||||||
"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5"
|
|
||||||
"checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"
|
|
||||||
"checksum block-buffer 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
|
||||||
"checksum block-padding 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6d4dc3af3ee2e12f3e5d224e5e1e3d73668abbeb69e566d361f7d5563a4fdf09"
|
|
||||||
"checksum byte-tools 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
|
||||||
"checksum byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c3dd8985a7111efc5c80b44e23ecdd8c007de8ade3b96595387e812b957cf5"
|
|
||||||
"checksum cc 1.0.41 (registry+https://github.com/rust-lang/crates.io-index)" = "8dae9c4b8fedcae85592ba623c4fd08cfdab3e3b72d6df780c6ead964a69bfff"
|
|
||||||
"checksum cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"
|
|
||||||
"checksum chrono 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "77d81f58b7301084de3b958691458a53c3f7e0b1d702f77e550b6a88e3a88abe"
|
|
||||||
"checksum dbus 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "48b5f0f36f1eebe901b0e6bee369a77ed3396334bf3f09abd46454a576f71819"
|
|
||||||
"checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
|
||||||
"checksum dlib 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "77e51249a9d823a4cb79e3eca6dcd756153e8ed0157b6c04775d04bf1b13b76a"
|
|
||||||
"checksum downcast-rs 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b92dfd5c2f75260cbf750572f95d387e7ca0ba5e3fbe9e1a33f23025be020f"
|
|
||||||
"checksum dtoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ea57b42383d091c85abcc2706240b94ab2a8fa1fc81c10ff23c4de06e2a90b5e"
|
|
||||||
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
|
||||||
"checksum fuzzy-matcher 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2db8c952765d7250f5fa509db7f6510ceef4be8672affc9bdbeffa2695923f67"
|
|
||||||
"checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec"
|
|
||||||
"checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"
|
|
||||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|
||||||
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
|
|
||||||
"checksum libdbus-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "69382cb3be797cfe62ba89ac5e594a0e3022914ff44867ffbcfc03daa24eebd7"
|
|
||||||
"checksum libloading 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753"
|
|
||||||
"checksum libpulse-binding 2.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e7712e3c895da914d7d969475238cc43933c5c4cf7ef3654106be9db2b327cbb"
|
|
||||||
"checksum libpulse-sys 1.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "67df96705dc149577155690c05e067334d1d8a62bcac1a1611ef28eaaeb76354"
|
|
||||||
"checksum line_drawing 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5cc7ad3d82c845bdb5dde34ffdcc7a5fb4d2996e1e1ee0f19c33bc80e15196b9"
|
|
||||||
"checksum linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83"
|
|
||||||
"checksum maplit 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
|
|
||||||
"checksum memmap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b"
|
|
||||||
"checksum nix 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4dbdc256eaac2e3bd236d93ad999d3479ef775c863dbda3068c4006a92eec51b"
|
|
||||||
"checksum nix 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c722bee1037d430d0f8e687bbdbf222f27cc6e4e68d5caf630857bb2b6dbdce"
|
|
||||||
"checksum nix 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3b2e0b4f3320ed72aaedb9a5ac838690a8047c7b275da22711fddff4f8a14229"
|
|
||||||
"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"
|
|
||||||
"checksum num-bigint 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "57450397855d951f1a41305e54851b1a7b8f5d2e349543a02a2effe25459f718"
|
|
||||||
"checksum num-complex 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "fcb0cf31fb3ff77e6d2a6ebd6800df7fdcd106f2ad89113c9130bcd07f93dffc"
|
|
||||||
"checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09"
|
|
||||||
"checksum num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f2885278d5fe2adc2f75ced642d52d879bffaceb5a2e0b1d4309ffdfb239b454"
|
|
||||||
"checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32"
|
|
||||||
"checksum opaque-debug 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
|
||||||
"checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518"
|
|
||||||
"checksum os_pipe 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce1d819d394515aae0530eae02156fedfc98b4f0359bf3048a442be89a95157b"
|
|
||||||
"checksum pest 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "933085deae3f32071f135d799d75667b63c8dc1f4537159756e3d4ceab41868c"
|
|
||||||
"checksum pest_derive 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
|
||||||
"checksum pest_generator 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "63120576c4efd69615b5537d3d052257328a4ca82876771d6944424ccfd9f646"
|
|
||||||
"checksum pest_meta 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f249ea6de7c7b7aba92b4ff4376a994c6dbd98fd2166c89d5c4947397ecb574d"
|
|
||||||
"checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af"
|
|
||||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
|
||||||
"checksum proc-macro2 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "175a40b9cf564ce9bf050654633dbf339978706b8ead1a907bb970b63185dd95"
|
|
||||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
|
||||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
|
||||||
"checksum rcalc_lib 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2497fc2d7578e75282922918d96de8d4790714312900d95b6d5f577168f2656e"
|
|
||||||
"checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84"
|
|
||||||
"checksum rust-ini 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3e52c148ef37f8c375d49d5a73aa70713125b7f19095948a923f80afdeb22ec2"
|
|
||||||
"checksum rusttype 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "654103d61a05074b268a107cf6581ce120f0fc0115f2610ed9dfea363bb81139"
|
|
||||||
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
|
|
||||||
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
|
|
||||||
"checksum serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "fec2851eb56d010dc9a21b89ca53ee75e6528bab60c11e89d38390904982da9f"
|
|
||||||
"checksum serde_derive 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)" = "cb4dc18c61206b08dc98216c98faa0232f4337e1e1b8574551d5bad29ea1b425"
|
|
||||||
"checksum serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)" = "051c49229f282f7c6f3813f8286cc1e3323e8051823fce42c7ea80fe13521704"
|
|
||||||
"checksum serde_yaml 0.8.9 (registry+https://github.com/rust-lang/crates.io-index)" = "38b08a9a90e5260fe01c6480ec7c811606df6d3a660415808c3c3fa8ed95b582"
|
|
||||||
"checksum sha-1 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "23962131a91661d643c98940b20fcaffe62d776a823247be80a48fcb8b6fce68"
|
|
||||||
"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
|
|
||||||
"checksum smithay-client-toolkit 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "93960e8975909fcb14cc755de93af2149d8b8f4eb368315537d40cfd0f324054"
|
|
||||||
"checksum stb_truetype 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "69b7df505db8e81d54ff8be4693421e5b543e08214bd8d99eb761fcb4d5668ba"
|
|
||||||
"checksum syn 0.15.44 (registry+https://github.com/rust-lang/crates.io-index)" = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5"
|
|
||||||
"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
|
|
||||||
"checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f"
|
|
||||||
"checksum timerfd 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9a7822e546fa39d0b5ae14a93a33903975b62af6597288aea77f0580a6abbe"
|
|
||||||
"checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9"
|
|
||||||
"checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2"
|
|
||||||
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
|
|
||||||
"checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c"
|
|
||||||
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
|
||||||
"checksum walkdir 2.2.9 (registry+https://github.com/rust-lang/crates.io-index)" = "9658c94fa8b940eab2250bd5a457f9c48b748420d71293b165c8cdbe2f55f71e"
|
|
||||||
"checksum wayland-client 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "80d909ba6616dd772686f421e111f039402a13acecf395bcb4fc665277a504e0"
|
|
||||||
"checksum wayland-commons 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c30463b995db5f8451e921134934319bec89c2458b0bc5c81967060252aa41d8"
|
|
||||||
"checksum wayland-protocols 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "cca5f12d466bb6d060673d9d3f94c4ec72161b44d8123f1ef9d11d1054afd6e7"
|
|
||||||
"checksum wayland-scanner 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "842bc498050e1e70ab3b4a09e2532e9039e371b4d2d19345bc1e8e38998fce62"
|
|
||||||
"checksum wayland-sys 0.23.5 (registry+https://github.com/rust-lang/crates.io-index)" = "b7676aeac62796e1624d1f615c9073ddf8cdd951cbcb7b0bb555e4cdc1818114"
|
|
||||||
"checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"
|
|
||||||
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
|
||||||
"checksum winapi-util 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7168bab6e1daee33b4557efd0e95d5ca70a03706d39fa5f3fe7a236f584b03c9"
|
|
||||||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
||||||
"checksum xdg 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57"
|
|
||||||
"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
|
|
||||||
"checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d"
|
|
||||||
-43
@@ -1,43 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "wldash"
|
|
||||||
version = "0.2.0"
|
|
||||||
authors = ["Kenny Levinsen <kl@kl.wtf>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = "fat"
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = ["alsa-widget", "pulseaudio-widget", "yaml-cfg", "json-cfg"]
|
|
||||||
damage_debug = []
|
|
||||||
|
|
||||||
yaml-cfg = ["serde_yaml"]
|
|
||||||
json-cfg = ["serde_json"]
|
|
||||||
|
|
||||||
alsa-widget = ["alsa"]
|
|
||||||
pulseaudio-widget = ["libpulse-binding"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
smithay-client-toolkit = "0.6.4"
|
|
||||||
byteorder = "1.3"
|
|
||||||
rusttype = "0.7"
|
|
||||||
chrono = "0.4"
|
|
||||||
nix = "0.15"
|
|
||||||
memmap = "0.7"
|
|
||||||
os_pipe = "0.8"
|
|
||||||
wayland-client = { version = "0.23", features = ["dlopen"] }
|
|
||||||
wayland-protocols = { version = "0.23", features = ["client", "unstable_protocols"] }
|
|
||||||
dbus = "0.6"
|
|
||||||
fuzzy-matcher = "0.2"
|
|
||||||
lazy_static = "1.4"
|
|
||||||
rcalc_lib = { version = "0.9" }
|
|
||||||
rust-ini = "0.13"
|
|
||||||
shlex = "0.1"
|
|
||||||
timerfd = "1.0.0"
|
|
||||||
|
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_json = { version = "1.0", optional = true }
|
|
||||||
serde_yaml = { version = "0.8", optional = true }
|
|
||||||
|
|
||||||
libpulse-binding = { version = "2.11", optional = true }
|
|
||||||
alsa = { version = "0.3.0", optional = true }
|
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
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>.
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
# 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.
|
|
||||||
|
|
||||||
## How to use
|
|
||||||
|
|
||||||
1. Checkout: `git clone https://github.com/kennylevinsen/wldash`
|
|
||||||
2. Build: `cargo build --release`
|
|
||||||
3. Put somewhere: `cp target/release/wldash /usr/local/bin/wldash`
|
|
||||||
4. Run: `wldash`
|
|
||||||
|
|
||||||
To see the default configuration, run `wldash print-config`. To configure, place a file in `$XDG_CONFIG_HOME/wldash/config.yaml` (or if `XDG_CONFIG_HOME` is not set, `~/.config/wldash/config.yaml`). JSON is also currently supported.
|
|
||||||
|
|
||||||
Notable settings: `outptuMode` can be `active` or `all`, `scale` can be set to `2` to half the buffer size, and the widgets (and their layout) can be configured.
|
|
||||||
|
|
||||||
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
|
|
||||||
- Configurability
|
|
||||||
- Cleanup and reorganization
|
|
||||||
- Proper line editor for the launcher
|
|
||||||
-55
@@ -1,55 +0,0 @@
|
|||||||
{
|
|
||||||
"widget": {
|
|
||||||
"margin": {
|
|
||||||
"margins": [20,20,20,20],
|
|
||||||
"widget": {
|
|
||||||
"verticalLayout": [{
|
|
||||||
"horizontalLayout": [{
|
|
||||||
"margin": {
|
|
||||||
"margins": [0,88,0,32],
|
|
||||||
"widget": {
|
|
||||||
"verticalLayout": [
|
|
||||||
{"date": {"font_size": 64.0}},
|
|
||||||
{"clock": {"font_size": 256.0}}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
"verticalLayout": [{
|
|
||||||
"margin": {
|
|
||||||
"margins": [0,0,0,8],
|
|
||||||
"widget": {"battery": {"font_size": 24.0,"length": 600}}
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
"margin": {
|
|
||||||
"margins": [0,0,0,8],
|
|
||||||
"widget": {"backlight": {"font_size": 24.0,"length": 600}}
|
|
||||||
}
|
|
||||||
},{
|
|
||||||
"margin": {
|
|
||||||
"margins": [0,0,0,8],
|
|
||||||
"widget": {"pulseAudio": {"font_size": 24.0,"length": 600}}
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
}
|
|
||||||
]},
|
|
||||||
{"calendar": {"font_size": 16.0,"sections": 3}},
|
|
||||||
{"launcher": {
|
|
||||||
"font_size": 32.0,
|
|
||||||
"length": 1200,
|
|
||||||
"app_opener": "swaymsg exec ",
|
|
||||||
"term_opener": "alacritty -e ",
|
|
||||||
"url_opener": "xdg-open "
|
|
||||||
}}
|
|
||||||
]}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputMode": "active",
|
|
||||||
"scale": 1,
|
|
||||||
"background": {
|
|
||||||
"red": 0,
|
|
||||||
"green": 0,
|
|
||||||
"blue": 0,
|
|
||||||
"opacity": 0.9
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-49
@@ -1,49 +0,0 @@
|
|||||||
outputMode: active
|
|
||||||
scale: 1
|
|
||||||
background:
|
|
||||||
red: 0.0
|
|
||||||
green: 0.0
|
|
||||||
blue: 0.0
|
|
||||||
opacity: 0.9
|
|
||||||
widget:
|
|
||||||
margin:
|
|
||||||
margins: [20, 20, 20, 20]
|
|
||||||
widget:
|
|
||||||
verticalLayout:
|
|
||||||
- horizontalLayout:
|
|
||||||
- margin:
|
|
||||||
margins: [0, 88, 0, 32]
|
|
||||||
widget:
|
|
||||||
verticalLayout:
|
|
||||||
- date:
|
|
||||||
font_size: 64.0
|
|
||||||
- clock:
|
|
||||||
font_size: 256.0
|
|
||||||
- verticalLayout:
|
|
||||||
- margin:
|
|
||||||
margins: [0, 0, 0, 8]
|
|
||||||
widget:
|
|
||||||
battery:
|
|
||||||
font_size: 24.0
|
|
||||||
length: 600
|
|
||||||
- margin:
|
|
||||||
margins: [0, 0, 0, 8]
|
|
||||||
widget:
|
|
||||||
backlight:
|
|
||||||
font_size: 24.0
|
|
||||||
length: 600
|
|
||||||
- margin:
|
|
||||||
margins: [0, 0, 0, 8]
|
|
||||||
widget:
|
|
||||||
pulseAudio:
|
|
||||||
font_size: 24.0
|
|
||||||
length: 600
|
|
||||||
- calendar:
|
|
||||||
font_size: 16.0
|
|
||||||
sections: 3
|
|
||||||
- launcher:
|
|
||||||
font_size: 32.0
|
|
||||||
length: 1200
|
|
||||||
app_opener: "swaymsg exec "
|
|
||||||
term_opener: "alacritty -e "
|
|
||||||
url_opener: "xdg-open "
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,38 +0,0 @@
|
|||||||
|
|
||||||
==========================================================
|
|
||||||
|
|
||||||
Wen Quan Yi Micro Hei
|
|
||||||
|
|
||||||
ChangeLog
|
|
||||||
|
|
||||||
----------------------------------------------------------
|
|
||||||
|
|
||||||
WenQuanYi Micro Hei ChangeLog:
|
|
||||||
|
|
||||||
== WenQuanYi Micro Hei 0.2 (BigBang), FangQ <fangq nmr mgh harvard edu> ==
|
|
||||||
|
|
||||||
2009/05/25 Updated contributor list in the NB and announced beta release
|
|
||||||
2009/05/18 fixed hinting instr for M/N in MicroHeiMono by copying cvt table (F
|
|
||||||
angQ)
|
|
||||||
2009/05/16 added Micro Hei Mono by merging with Droid Sans Mono (FangQ)
|
|
||||||
2009/05/15 rename uni00B9 to onesuperior to match the it in DroidSans (FangQ)
|
|
||||||
2009/05/10 updated documentations (FangQ)
|
|
||||||
2009/05/09 scale MicroHei to EM=2048 before merging to Droid Sans, keep
|
|
||||||
all hinting and kerning info. (FangQ)
|
|
||||||
2009/04/12 imported Chinese punctuations from UmeGothic (FangQ)
|
|
||||||
2009/02/08 all characters in U4E00~U9FC3 were complete (review panel, wanghong
|
|
||||||
)
|
|
||||||
2009/01/16 Micro Hei nightly-build became active (FangQ)
|
|
||||||
2009/01/15 GBK glyph review process started (FangQ)
|
|
||||||
2009/01/03 Fontopia supported sub-contour editing (FangQ)
|
|
||||||
2008/12/31 GBK char-set completed 90%, CJK Ext. A became online
|
|
||||||
2008/12/29 project publicly announcement (FangQ)
|
|
||||||
2008/12/09 Droid Font license confirmed (Apache2 as committed in git)
|
|
||||||
2008/12/03 add theme and rename as Fontopia (FangQ)
|
|
||||||
2008/11/23 Droid extension GUI milestone reached (mozbug, FangQ)
|
|
||||||
2008/11/07 initial upload of BezierGlyph/Bezier_lib.js script (mozbug)
|
|
||||||
2008/11/06 code point and script preparation (mozbug)
|
|
||||||
2008/10/21 project conceptualized (FangQ)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,122 +0,0 @@
|
|||||||
Apache License
|
|
||||||
Version 2.0, January 2004
|
|
||||||
http://www.apache.org/licenses/
|
|
||||||
|
|
||||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
||||||
|
|
||||||
1. Definitions.
|
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this
|
|
||||||
document.
|
|
||||||
|
|
||||||
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
||||||
|
|
||||||
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common
|
|
||||||
control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the
|
|
||||||
direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
||||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
||||||
|
|
||||||
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
||||||
|
|
||||||
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code,
|
|
||||||
documentation source, and configuration files.
|
|
||||||
|
|
||||||
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not
|
|
||||||
limited to compiled object code, generated documentation, and conversions to other media types.
|
|
||||||
|
|
||||||
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a
|
|
||||||
copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
||||||
|
|
||||||
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which
|
|
||||||
the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship.
|
|
||||||
For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by
|
|
||||||
name) to the interfaces of, the Work and Derivative Works thereof.
|
|
||||||
|
|
||||||
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to
|
|
||||||
that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner
|
|
||||||
or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition,
|
|
||||||
"submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including
|
|
||||||
but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are
|
|
||||||
managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is
|
|
||||||
conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
||||||
|
|
||||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor
|
|
||||||
and subsequently incorporated within the Work.
|
|
||||||
|
|
||||||
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a
|
|
||||||
perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works
|
|
||||||
of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
||||||
|
|
||||||
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual,
|
|
||||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made,
|
|
||||||
use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable
|
|
||||||
by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with
|
|
||||||
the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim
|
|
||||||
or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or
|
|
||||||
contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the
|
|
||||||
date such litigation is filed.
|
|
||||||
|
|
||||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without
|
|
||||||
modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
||||||
|
|
||||||
1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
||||||
|
|
||||||
2. You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
||||||
|
|
||||||
3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and
|
|
||||||
attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative
|
|
||||||
Works; and
|
|
||||||
|
|
||||||
4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must
|
|
||||||
include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to
|
|
||||||
any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the
|
|
||||||
Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display
|
|
||||||
generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for
|
|
||||||
informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You
|
|
||||||
distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot
|
|
||||||
be construed as modifying the License.
|
|
||||||
|
|
||||||
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions
|
|
||||||
for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use,
|
|
||||||
reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
||||||
|
|
||||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
|
|
||||||
Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions.
|
|
||||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have
|
|
||||||
executed with Licensor regarding such Contributions.
|
|
||||||
|
|
||||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the
|
|
||||||
Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of
|
|
||||||
the NOTICE file.
|
|
||||||
|
|
||||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
|
|
||||||
Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
||||||
implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume
|
|
||||||
any risks associated with Your exercise of permissions under this License.
|
|
||||||
|
|
||||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise,
|
|
||||||
unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be
|
|
||||||
liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as
|
|
||||||
a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill,
|
|
||||||
work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has
|
|
||||||
been advised of the possibility of such damages.
|
|
||||||
|
|
||||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer,
|
|
||||||
and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this
|
|
||||||
License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf
|
|
||||||
of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred
|
|
||||||
by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
|
||||||
APPENDIX: How to apply the Apache License to your work
|
|
||||||
|
|
||||||
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]"
|
|
||||||
replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment
|
|
||||||
syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed
|
|
||||||
page" as the copyright notice for easier identification within third-party archives.
|
|
||||||
Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
|
|
||||||
except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless
|
|
||||||
required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing
|
|
||||||
permissions and limitations under the License.
|
|
||||||
@@ -1,674 +0,0 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
|
||||||
Version 3, 29 June 2007
|
|
||||||
|
|
||||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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
|
|
||||||
<http://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
|
|
||||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
||||||
@@ -1,378 +0,0 @@
|
|||||||
|
|
||||||
==========================================================
|
|
||||||
|
|
||||||
Wen Quan Yi Micro Hei
|
|
||||||
|
|
||||||
Release Notes
|
|
||||||
|
|
||||||
----------------------------------------------------------
|
|
||||||
|
|
||||||
Summary:
|
|
||||||
|
|
||||||
Author : WenQuanYi Project Contributors
|
|
||||||
Webpage : http://wenq.org/en/ or http://wqy.sourceforge.net/en/
|
|
||||||
Font Name: WenQuanYi Micro Hei
|
|
||||||
Version : 0.2.0-beta (Big-Bang)
|
|
||||||
Release : 0
|
|
||||||
Copyright Digitized data copyright © 2007, Google Corporation.
|
|
||||||
Copyright © 2008-2009, WenQuanYi Project Board of
|
|
||||||
Trustees, All rights reserved.
|
|
||||||
|
|
||||||
Droid Sans Fallback extension interface
|
|
||||||
( http://wenq.org/index.cgi?Fontopia(cn) ),
|
|
||||||
copyright © 2008-2009 mozbug and Qianqian Fang
|
|
||||||
License : This font is licensed under Apache2.0 or GPLv3
|
|
||||||
with font embedding exceptions (see Appendix B).
|
|
||||||
Read LICENSE_Apache2.txt and LICENSE_GPLv3.txt for details
|
|
||||||
|
|
||||||
----------------------------------------------------------
|
|
||||||
|
|
||||||
Table of Content
|
|
||||||
|
|
||||||
I. About this font
|
|
||||||
II. Development History
|
|
||||||
III. Credits
|
|
||||||
IV. Language Coverage
|
|
||||||
V. About "WenQuanYi Project"
|
|
||||||
VI. Links
|
|
||||||
VII. Appendix
|
|
||||||
|
|
||||||
----------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
I. About this font
|
|
||||||
|
|
||||||
WenQuanYi Micro Hei font family is a Sans-Serif style (also known as Hei,
|
|
||||||
Gothic or Dotum among the Chinese/Japanese/Korean users) high quality
|
|
||||||
CJK outline font. It was derived from "Droid Sans Fallback", "Droid
|
|
||||||
Sans" and "Droid Sans Mono" released by Google Corp. This font package
|
|
||||||
contains two faces, "Micro Hei" and "Micro Hei Mono", in form of a
|
|
||||||
True-Type Collection (ttc) file. All the unified CJK Han glyphs, i.e.
|
|
||||||
GBK Hanzi, in the range of U+4E00-U+9FC3 defined in Unicode Standard 5.1
|
|
||||||
are covered, with additional support to many other international
|
|
||||||
languages such as Latin, Extended Latin, Hanguls and Kanas. The font
|
|
||||||
file is extremely compact (~5M) compared with most known CJK fonts.
|
|
||||||
As a result, it can be used for hand-held devices or embedded systems, or
|
|
||||||
used on PC with a significantly small memory footprint. Because both
|
|
||||||
font faces carry hinting and kerning instructions for Latin glyphs,
|
|
||||||
they are the excellent choices for desktop fonts.
|
|
||||||
|
|
||||||
|
|
||||||
II. Development History
|
|
||||||
|
|
||||||
The original Droid Sans Fallback font contain 16,000 Unified Han glyphs,
|
|
||||||
and was officially released by Google under Apache2 license on Dec. 9,
|
|
||||||
2008 [2]. With a Javascript-based web interface, Fontopia(TM) [1], developed
|
|
||||||
by mozbug and Qianqian Fang, the WenQuanYi contributors had completed
|
|
||||||
over 10,000 new glyphs by combining the spline contours from the existing
|
|
||||||
Droid Han glyphs. By the end of 2008, project phase-1 had almost
|
|
||||||
completed, and phase-2 for CJK Extension A (U+3400-U+4DB5) was brought
|
|
||||||
online on Dec. 29, 2009. A review panel was formed to reinforce the
|
|
||||||
quality of all submitted glyphs [3]. In Jan. 2009, the reviewers
|
|
||||||
had redone over 2000 Hanzi and completed all the missing characters.
|
|
||||||
The nightly-build font has become online since Jan. 16. As of Feb. 2009, there
|
|
||||||
has been over 5500 CJK Extension A Han glyphs completed, which led this
|
|
||||||
font toward a complete GB18030 coverage.
|
|
||||||
|
|
||||||
In this font, we incorporated the high quality Latin glyphs from "Droid Sans"
|
|
||||||
and "Droid Sans Mono", which contain not only a better coverage but also
|
|
||||||
the additional hinting and kerning information. The EM of MicroHei
|
|
||||||
and MicroHeiMono fonts were unified to 2048 to retain all the advanced
|
|
||||||
typesetting features.
|
|
||||||
|
|
||||||
|
|
||||||
III. Credits
|
|
||||||
|
|
||||||
We cordially thank Google(TM) for generously releasing Droid fonts to
|
|
||||||
public under an open-source license. Google purchased the font from
|
|
||||||
Ascenders Corp. (which was originally designed by a Chinese company).
|
|
||||||
|
|
||||||
The project for extending the Droid fonts is based on the web-based
|
|
||||||
glyph-composing applet [1], created by mozbug and Qianqian Fang
|
|
||||||
jointly. They are constantly improving this application targeting at
|
|
||||||
a web-based collaborative font development environment.
|
|
||||||
|
|
||||||
Over a thousand anonymous contributors have participated the project;
|
|
||||||
they submitted over 10,000 new Hanzi glyphs and many modifications.
|
|
||||||
The full update history of the glyphs can be found at [4].
|
|
||||||
|
|
||||||
The key members of the review panel, i.e. lsz, FangQ, kmc, Xhacker,
|
|
||||||
philacorns, and an "anonymous" (as requested) contributor, had
|
|
||||||
spent significant amount of efforts to redesign nearly half of the
|
|
||||||
submitted glyphs. We appreciate the incredible effort from this team
|
|
||||||
to make this font available. The detailed review credit can be found
|
|
||||||
at [3]
|
|
||||||
|
|
||||||
|
|
||||||
IV. Language Coverage
|
|
||||||
|
|
||||||
The following table is based on the locale data provided by fontconfig
|
|
||||||
(generated by langcover.pl from Dejavu Project
|
|
||||||
http://dejavu.sourceforge.net/wiki/index.php/Font_utilities).
|
|
||||||
----------------------------------------------------------------
|
|
||||||
Locale MicroHei
|
|
||||||
----------------------------------------------------------------
|
|
||||||
aa Afar 100% (62/62)
|
|
||||||
ab Abkhazia 100% (90/90)
|
|
||||||
af Afrikaans 100% (69/69)
|
|
||||||
am Amharic (0/264)
|
|
||||||
ar Arabic (0/125)
|
|
||||||
as (0/89)
|
|
||||||
ast Asturian 100% (72/72)
|
|
||||||
ava Avaric 100% (67/67)
|
|
||||||
ay Aymara 100% (60/60)
|
|
||||||
az Azerbaijani 98% (146/148)
|
|
||||||
az-ir Azerbaijani in Iran (0/130)
|
|
||||||
ba Bashkir 100% (82/82)
|
|
||||||
bam Bambara 90% (54/60)
|
|
||||||
be Byelorussian 100% (68/68)
|
|
||||||
bg Bulgarian 100% (60/60)
|
|
||||||
bh Bihari (Devanagari script) (0/68)
|
|
||||||
bho Bhojpuri (Devanagari script) (0/68)
|
|
||||||
bi Bislama 100% (58/58)
|
|
||||||
bin Edo or Bini 100% (78/78)
|
|
||||||
bn Bengali (0/89)
|
|
||||||
bo Tibetan (0/95)
|
|
||||||
br Breton 100% (64/64)
|
|
||||||
bs Bosnian 100% (62/62)
|
|
||||||
bua Buriat (Buryat) 100% (70/70)
|
|
||||||
ca Catalan 100% (74/74)
|
|
||||||
ce Chechen 100% (67/67)
|
|
||||||
ch Chamorro 100% (58/58)
|
|
||||||
chm Mari (Lower Cheremis / Upper Cheremis) 100% (76/76)
|
|
||||||
chr Cherokee (0/85)
|
|
||||||
co Corsican 100% (85/85)
|
|
||||||
cs Czech 100% (82/82)
|
|
||||||
cu Old Church Slavonic 100% (103/103)
|
|
||||||
cv Chuvash 100% (74/74)
|
|
||||||
cy Welsh 100% (78/78)
|
|
||||||
da Danish 100% (70/70)
|
|
||||||
de German 100% (60/60)
|
|
||||||
dz Dzongkha (0/95)
|
|
||||||
el Greek 100% (70/70)
|
|
||||||
en English 100% (73/73)
|
|
||||||
eo Esperanto 100% (64/64)
|
|
||||||
es Spanish 100% (67/67)
|
|
||||||
et Estonian 100% (64/64)
|
|
||||||
eu Basque 100% (56/56)
|
|
||||||
fa Persian (0/129)
|
|
||||||
fi Finnish 100% (63/63)
|
|
||||||
fj Fijian 100% (52/52)
|
|
||||||
fo Faroese 100% (68/68)
|
|
||||||
fr French 100% (85/85)
|
|
||||||
ful Fulah (Fula) 87% (54/62)
|
|
||||||
fur Friulian 100% (66/66)
|
|
||||||
fy Frisian 100% (75/75)
|
|
||||||
ga Irish 82% (66/80)
|
|
||||||
gd Scots Gaelic 100% (70/70)
|
|
||||||
gez Ethiopic (Geez) (0/218)
|
|
||||||
gl Galician 100% (66/66)
|
|
||||||
gn Guarani 100% (70/70)
|
|
||||||
gu Gujarati (0/78)
|
|
||||||
gv Manx Gaelic 100% (54/54)
|
|
||||||
ha Hausa 86% (52/60)
|
|
||||||
haw Hawaiian 98% (62/63)
|
|
||||||
he Hebrew (0/27)
|
|
||||||
hi Hindi (Devanagari script) (0/68)
|
|
||||||
ho Hiri Motu 100% (52/52)
|
|
||||||
hr Croatian 100% (62/62)
|
|
||||||
hu Hungarian 100% (70/70)
|
|
||||||
hy Armenian (0/77)
|
|
||||||
ia Interlingua 100% (52/52)
|
|
||||||
ibo Igbo 100% (58/58)
|
|
||||||
id Indonesian 100% (54/54)
|
|
||||||
ie Interlingue 100% (52/52)
|
|
||||||
ik Inupiaq (Inupiak, Eskimo) 100% (68/68)
|
|
||||||
io Ido 100% (52/52)
|
|
||||||
is Icelandic 100% (70/70)
|
|
||||||
it Italian 100% (73/73)
|
|
||||||
iu Inuktitut (0/161)
|
|
||||||
ja Japanese 99% (6526/6538)
|
|
||||||
ka Georgian (0/33)
|
|
||||||
kaa Kara-Kalpak (Karakalpak) 100% (78/78)
|
|
||||||
ki Kikuyu 100% (56/56)
|
|
||||||
kk Kazakh 100% (77/77)
|
|
||||||
kl Greenlandic 100% (81/81)
|
|
||||||
km Khmer (0/70)
|
|
||||||
kn Kannada (0/80)
|
|
||||||
ko Korean 100% (2443/2443)
|
|
||||||
kok Kokani (Devanagari script) (0/68)
|
|
||||||
ks Kashmiri (Devanagari script) (0/68)
|
|
||||||
ku Kurdish 100% (64/64)
|
|
||||||
ku-ir Kurdish in Iran (0/32)
|
|
||||||
kum Kumyk 100% (66/66)
|
|
||||||
kv Komi (Komi-Permyak/Komi-Siryan) 100% (70/70)
|
|
||||||
kw Cornish 96% (62/64)
|
|
||||||
ky Kirgiz 100% (70/70)
|
|
||||||
la Latin 100% (68/68)
|
|
||||||
lb Luxembourgish (Letzeburgesch) 100% (75/75)
|
|
||||||
lez Lezghian (Lezgian) 100% (67/67)
|
|
||||||
ln Lingala 92% (75/81)
|
|
||||||
lo Lao (0/65)
|
|
||||||
lt Lithuanian 100% (70/70)
|
|
||||||
lv Latvian 100% (78/78)
|
|
||||||
mg Malagasy 100% (56/56)
|
|
||||||
mh Marshallese 100% (62/62)
|
|
||||||
mi Maori 96% (62/64)
|
|
||||||
mk Macedonian 100% (42/42)
|
|
||||||
ml Malayalam (0/78)
|
|
||||||
mn Mongolian (0/130)
|
|
||||||
mo Moldavian 98% (126/128)
|
|
||||||
mr Marathi (Devanagari script) (0/68)
|
|
||||||
mt Maltese 100% (72/72)
|
|
||||||
my Burmese (Myanmar) (0/48)
|
|
||||||
nb Norwegian Bokmal 100% (70/70)
|
|
||||||
nds Low Saxon 100% (59/59)
|
|
||||||
ne Nepali (Devanagari script) (0/68)
|
|
||||||
nl Dutch 100% (83/83)
|
|
||||||
nn Norwegian Nynorsk 100% (76/76)
|
|
||||||
no Norwegian (Bokmal) 100% (70/70)
|
|
||||||
ny Chichewa 100% (54/54)
|
|
||||||
oc Occitan 100% (70/70)
|
|
||||||
om Oromo or Galla 100% (52/52)
|
|
||||||
or Oriya (0/79)
|
|
||||||
os Ossetic 100% (66/66)
|
|
||||||
pa Punjabi (Gurumukhi script) (0/63)
|
|
||||||
pl Polish 100% (70/70)
|
|
||||||
ps-af Pashto in Afghanistan (0/49)
|
|
||||||
ps-pk Pashto in Pakistan (0/49)
|
|
||||||
pt Portuguese 100% (83/83)
|
|
||||||
rm Rhaeto-Romance (Romansch) 100% (66/66)
|
|
||||||
ro Romanian 96% (60/62)
|
|
||||||
ru Russian 100% (66/66)
|
|
||||||
sa Sanskrit (Devanagari script) (0/68)
|
|
||||||
sah Yakut 100% (76/76)
|
|
||||||
sco Scots 92% (52/56)
|
|
||||||
se North Sami 100% (66/66)
|
|
||||||
sel Selkup (Ostyak-Samoyed) 100% (66/66)
|
|
||||||
sh Serbo-Croatian 100% (76/76)
|
|
||||||
si Sinhala (Sinhalese) (0/77)
|
|
||||||
sk Slovak 100% (86/86)
|
|
||||||
sl Slovenian 100% (62/62)
|
|
||||||
sm Samoan 98% (52/53)
|
|
||||||
sma South Sami 100% (60/60)
|
|
||||||
smj Lule Sami 100% (60/60)
|
|
||||||
smn Inari Sami 100% (68/68)
|
|
||||||
sms Skolt Sami 87% (70/80)
|
|
||||||
so Somali 100% (52/52)
|
|
||||||
sq Albanian 100% (56/56)
|
|
||||||
sr Serbian 100% (76/76)
|
|
||||||
sv Swedish 100% (68/68)
|
|
||||||
sw Swahili 100% (52/52)
|
|
||||||
syr Syriac (0/45)
|
|
||||||
ta Tamil (0/48)
|
|
||||||
te Telugu (0/80)
|
|
||||||
tg Tajik 100% (78/78)
|
|
||||||
th Thai 1% (1/87)
|
|
||||||
ti-er Eritrean Tigrinya (0/256)
|
|
||||||
ti-et Ethiopian Tigrinya (0/282)
|
|
||||||
tig Tigre (0/221)
|
|
||||||
tk Turkmen 100% (74/74)
|
|
||||||
tl Tagalog (0/19)
|
|
||||||
tn Tswana 100% (56/56)
|
|
||||||
to Tonga 98% (52/53)
|
|
||||||
tr Turkish 100% (70/70)
|
|
||||||
ts Tsonga 100% (52/52)
|
|
||||||
tt Tatar 100% (76/76)
|
|
||||||
tw Twi 91% (67/73)
|
|
||||||
tyv Tuvinian 100% (70/70)
|
|
||||||
ug Uighur (0/125)
|
|
||||||
uk Ukrainian 100% (72/72)
|
|
||||||
ur Urdu (0/145)
|
|
||||||
uz Uzbek 100% (68/68)
|
|
||||||
ven Venda 83% (52/62)
|
|
||||||
vi Vietnamese 98% (191/194)
|
|
||||||
vo Volapuk 100% (54/54)
|
|
||||||
vot Votic 100% (62/62)
|
|
||||||
wa Walloon 100% (70/70)
|
|
||||||
wen Sorbian languages (lower and upper) 100% (76/76)
|
|
||||||
wo Wolof 100% (66/66)
|
|
||||||
xh Xhosa 100% (52/52)
|
|
||||||
yap Yapese 100% (58/58)
|
|
||||||
yi Yiddish (0/27)
|
|
||||||
yo Yoruba 91% (109/119)
|
|
||||||
zh-936 99% (21873/21920)
|
|
||||||
zh-cn Chinese (simplified) 99% (6754/6765)
|
|
||||||
zh-hk Chinese Hong Kong Supplementary Character Set 99% (2212/2213)
|
|
||||||
zh-mo Chinese in Macau 99% (2212/2213)
|
|
||||||
zh-sg Chinese in Singapore 99% (6754/6765)
|
|
||||||
zh-tw Chinese (traditional) 99% (13051/13063)
|
|
||||||
zu Zulu 100% (52/52)
|
|
||||||
----------------------------------------------------------------
|
|
||||||
|
|
||||||
V. About "WenQuanYi Project"
|
|
||||||
|
|
||||||
The "Wen Quan Yi" Project [5] was founded by Qianqian Fang [6] in
|
|
||||||
Oct. 2004. The goal of this project is to create a web-based
|
|
||||||
collaborative environment for open-source type-face development.
|
|
||||||
The initial focus of the project is to create high quality bitmap
|
|
||||||
character glyphs and outline fonts for all 70,000+ CJK characters
|
|
||||||
currently encoded by the Unicode Consortium. Some of the fonts
|
|
||||||
released by this project have been widely used as the default
|
|
||||||
Chinese desktop fonts by main-stream GNU/Linux distributions.
|
|
||||||
|
|
||||||
The Wen Quan Yi Project uses wiki [5] as the primary development
|
|
||||||
tool for glyph creation, documentation and coordinations. Wen Quan Yi
|
|
||||||
wiki also supports glyph version control and nightly build.
|
|
||||||
|
|
||||||
|
|
||||||
VI. Links
|
|
||||||
|
|
||||||
[1] http://wenq.org/index.cgi?Fontopia(cn)
|
|
||||||
[2] http://android.git.kernel.org/?p=platform/frameworks/base.git;a=commit;h=1a2
|
|
||||||
d9dbe9c6f54c5e0dc26386dc01df1d18073ad
|
|
||||||
[3] http://wenq.org/dev/index.cgi?BigBang_TASK
|
|
||||||
[4] http://wenq.org/WQYHistory.html.gz
|
|
||||||
[5] http://wenq.org/en/
|
|
||||||
[6] http://nmr.mgh.harvard.edu/~fangq/
|
|
||||||
|
|
||||||
|
|
||||||
VII. Appendix
|
|
||||||
|
|
||||||
Appendix A.
|
|
||||||
|
|
||||||
Copyright disclaimer for UmeFont
|
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
|
||||||
modification, are permitted provided that the following conditions
|
|
||||||
are met:
|
|
||||||
1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer.
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
this list of conditions and the following disclaimer in the documentation
|
|
||||||
and/or other materials provided with the distribution.
|
|
||||||
3. Neither the name of the Wada Laboratory, the University of Tokyo nor
|
|
||||||
the names of its contributors may be used to endorse or promote products
|
|
||||||
derived from this software without specific prior written permission.
|
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY WADA LABORATORY, THE UNIVERSITY OF TOKYO AND
|
|
||||||
CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
|
||||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
||||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LABORATORY OR
|
|
||||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
||||||
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
||||||
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
|
|
||||||
|
|
||||||
Appendix B.
|
|
||||||
|
|
||||||
GPL with font embedding exception:
|
|
||||||
|
|
||||||
http://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.html#FontException
|
|
||||||
|
|
||||||
As a special exception, if you create a document which uses this
|
|
||||||
font, and embed this font or unaltered portions of this font into
|
|
||||||
the document, this font does not by itself cause the resulting
|
|
||||||
document to be covered by the GNU General Public License. This
|
|
||||||
exception does not however invalidate any other reasons why the
|
|
||||||
document might be covered by the GNU General Public License. If you
|
|
||||||
modify this font, you may extend this exception to your version of
|
|
||||||
the font, but you are not obligated to do so. If you do not wish to
|
|
||||||
do so, delete this exception statement from your version.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 201 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 781 KiB |
+102
@@ -0,0 +1,102 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>wldash</title>
|
||||||
|
<meta http-equiv="refresh" content="0; URL=https://kl.wtf/projects/wldash">
|
||||||
|
<link rel="canonical" href="https://kl.wtf/projects/wldash">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
display: grid;
|
||||||
|
justify-items: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
font-size: 3em;
|
||||||
|
text-align: center;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
|
header {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
section {
|
||||||
|
width: 100%;
|
||||||
|
max-width: 720px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration: unset;
|
||||||
|
color: rgb(100, 100, 100);
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
list-style-type: '— ';
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
width: 100%;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<h1>wldash</h1>
|
||||||
|
<h2>wayland launcher/dashboard</h2>
|
||||||
|
</header>
|
||||||
|
<section>
|
||||||
|
<img src="images/wldash.jpg" alt="screenshot of wldash" />
|
||||||
|
<p>
|
||||||
|
<a href="https://github.com/kennylevinsen/wldash"><code>wldash</code></a> is a convenient dashboard and launcher for Wayland (requires wlr-layer-shell-unstable-v1 support), allowing easy access to things like date and time, backlight and volume control.
|
||||||
|
</p>
|
||||||
|
<h3>How to get wldash</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://github.com/kennylevinsen/wldash/releases">Download the latest release from GitHub</a></li>
|
||||||
|
<li>To build:
|
||||||
|
<pre><code>
|
||||||
|
git clone https://github.com/kennylevinsen/wldash
|
||||||
|
cd wldash
|
||||||
|
cargo build --release
|
||||||
|
cp ./target/release/wldash /usr/local/bin/
|
||||||
|
wldash
|
||||||
|
</code></pre>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<h3>Usage</h3>
|
||||||
|
<p>
|
||||||
|
Run <code>wldash print-config</code> to see the current configuration. Use that as template to write a new one to <code>~/.config/wldash/config.json</code>. The widgets, their size and layout can be configured as well.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To make wldash toggle itself every time it is started, instantiate with <code>wldash start-or-kill</code>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To run arbitrary command, type <code>!</code>. To use built-in calculator, type <code>=</code>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Hint: Try to scroll, left-click and right-click on things.
|
||||||
|
</p>
|
||||||
|
<h3>Links</h3>
|
||||||
|
<p>
|
||||||
|
<ul>
|
||||||
|
<li>Github link: <a href="https://github.com/kennylevinsen/wldash">https://github.com/kennylevinsen/wldash</a></li>
|
||||||
|
<li>IRC: #wldash @ irc.freenode.net</li>
|
||||||
|
</ul>
|
||||||
|
</p>
|
||||||
|
<h3>Donate</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://en.liberapay.com/kennylevinsen/">LiberaPay</a></li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
<a href="https://kl.wtf/">© 2019, Kenny Levinsen</a>
|
||||||
|
</p>
|
||||||
|
</section>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
-570
@@ -1,570 +0,0 @@
|
|||||||
use std::collections::VecDeque;
|
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
use chrono::Local;
|
|
||||||
|
|
||||||
use smithay_client_toolkit::keyboard::{
|
|
||||||
keysyms, map_keyboard_auto, Event as KbEvent, KeyState, ModifiersState,
|
|
||||||
};
|
|
||||||
|
|
||||||
use wayland_client::protocol::{wl_compositor, wl_output, wl_pointer, wl_shm, wl_surface};
|
|
||||||
use wayland_client::{Display, EventQueue, GlobalEvent, GlobalManager, NewProxy};
|
|
||||||
use wayland_protocols::wlr::unstable::layer_shell::v1::client::{
|
|
||||||
zwlr_layer_shell_v1, zwlr_layer_surface_v1,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::buffer::Buffer;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::widget::{DrawContext, Widget};
|
|
||||||
|
|
||||||
use crate::cmd::Cmd;
|
|
||||||
use crate::doublemempool::DoubleMemPool;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum OutputMode {
|
|
||||||
Active,
|
|
||||||
All,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct AppInner {
|
|
||||||
compositor: Option<wl_compositor::WlCompositor>,
|
|
||||||
surfaces: Vec<wl_surface::WlSurface>,
|
|
||||||
shell_surfaces: Vec<zwlr_layer_surface_v1::ZwlrLayerSurfaceV1>,
|
|
||||||
configured_surfaces: Arc<Mutex<usize>>,
|
|
||||||
outputs: Vec<(u32, wl_output::WlOutput)>,
|
|
||||||
shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>,
|
|
||||||
draw_tx: Sender<Cmd>,
|
|
||||||
output_mode: OutputMode,
|
|
||||||
visible: bool,
|
|
||||||
scale: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl AppInner {
|
|
||||||
fn new(tx: Sender<Cmd>, output_mode: OutputMode, scale: u32) -> AppInner {
|
|
||||||
AppInner {
|
|
||||||
compositor: None,
|
|
||||||
surfaces: Vec::new(),
|
|
||||||
shell_surfaces: Vec::new(),
|
|
||||||
configured_surfaces: Arc::new(Mutex::new(0)),
|
|
||||||
outputs: Vec::new(),
|
|
||||||
shell: None,
|
|
||||||
draw_tx: tx,
|
|
||||||
output_mode: output_mode,
|
|
||||||
visible: true,
|
|
||||||
scale: scale,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_shell_surface(
|
|
||||||
compositor: &wl_compositor::WlCompositor,
|
|
||||||
shell: &zwlr_layer_shell_v1::ZwlrLayerShellV1,
|
|
||||||
scale: u32,
|
|
||||||
configured_surfaces: Arc<Mutex<usize>>,
|
|
||||||
tx: Sender<Cmd>,
|
|
||||||
output: Option<&wl_output::WlOutput>,
|
|
||||||
) -> (
|
|
||||||
wl_surface::WlSurface,
|
|
||||||
zwlr_layer_surface_v1::ZwlrLayerSurfaceV1,
|
|
||||||
) {
|
|
||||||
let surface = compositor
|
|
||||||
.create_surface(NewProxy::implement_dummy)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let this_is_stupid = Arc::new(Mutex::new(false));
|
|
||||||
|
|
||||||
let shell_surface = shell
|
|
||||||
.get_layer_surface(
|
|
||||||
&surface,
|
|
||||||
output,
|
|
||||||
zwlr_layer_shell_v1::Layer::Overlay,
|
|
||||||
"".to_string(),
|
|
||||||
move |layer| {
|
|
||||||
layer.implement_closure(
|
|
||||||
move |evt, layer| match evt {
|
|
||||||
zwlr_layer_surface_v1::Event::Configure { serial, .. } => {
|
|
||||||
let mut x = this_is_stupid.lock().unwrap();
|
|
||||||
if !*x {
|
|
||||||
*x = true;
|
|
||||||
*(configured_surfaces.lock().unwrap()) += 1;
|
|
||||||
layer.ack_configure(serial);
|
|
||||||
tx.send(Cmd::ForceDraw).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
},
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
shell_surface.set_keyboard_interactivity(1);
|
|
||||||
surface.set_buffer_scale(scale as i32);
|
|
||||||
surface.commit();
|
|
||||||
(surface, shell_surface)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn outputs_changed(&mut self) {
|
|
||||||
let shell = match self.shell {
|
|
||||||
Some(ref shell) => shell.to_owned(),
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
let compositor = match self.compositor {
|
|
||||||
Some(ref c) => c.to_owned(),
|
|
||||||
None => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
for shell_surface in self.shell_surfaces.iter() {
|
|
||||||
shell_surface.destroy();
|
|
||||||
}
|
|
||||||
for surface in self.surfaces.iter() {
|
|
||||||
surface.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
self.configured_surfaces = Arc::new(Mutex::new(0));
|
|
||||||
|
|
||||||
if !self.visible {
|
|
||||||
self.surfaces = Vec::new();
|
|
||||||
self.shell_surfaces = Vec::new();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.output_mode {
|
|
||||||
OutputMode::Active => {
|
|
||||||
if self.shell_surfaces.len() > 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let (surface, shell_surface) = AppInner::add_shell_surface(
|
|
||||||
&compositor,
|
|
||||||
&shell,
|
|
||||||
self.scale,
|
|
||||||
self.configured_surfaces.clone(),
|
|
||||||
self.draw_tx.clone(),
|
|
||||||
None,
|
|
||||||
);
|
|
||||||
self.surfaces = vec![surface];
|
|
||||||
self.shell_surfaces = vec![shell_surface];
|
|
||||||
}
|
|
||||||
OutputMode::All => {
|
|
||||||
let mut surfaces = Vec::new();
|
|
||||||
let mut shell_surfaces = Vec::new();
|
|
||||||
for output in self.outputs.iter() {
|
|
||||||
let (surface, shell_surface) = AppInner::add_shell_surface(
|
|
||||||
&compositor,
|
|
||||||
&shell,
|
|
||||||
self.scale,
|
|
||||||
self.configured_surfaces.clone(),
|
|
||||||
self.draw_tx.clone(),
|
|
||||||
Some(&output.1),
|
|
||||||
);
|
|
||||||
surfaces.push(surface);
|
|
||||||
shell_surfaces.push(shell_surface);
|
|
||||||
}
|
|
||||||
self.surfaces = surfaces;
|
|
||||||
self.shell_surfaces = shell_surfaces;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.draw_tx.send(Cmd::ForceDraw).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_output(&mut self, id: u32, output: wl_output::WlOutput) {
|
|
||||||
self.outputs.push((id, output));
|
|
||||||
self.outputs_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn remove_output(&mut self, id: u32) {
|
|
||||||
let old_output = self.outputs.iter().find(|(output_id, _)| *output_id == id);
|
|
||||||
if let Some(output) = old_output {
|
|
||||||
let new_outputs = self
|
|
||||||
.outputs
|
|
||||||
.iter()
|
|
||||||
.filter(|(output_id, _)| *output_id != id)
|
|
||||||
.map(|(x, y)| (x.clone(), y.clone()))
|
|
||||||
.collect();
|
|
||||||
if output.1.as_ref().version() >= 3 {
|
|
||||||
output.1.release()
|
|
||||||
}
|
|
||||||
self.outputs = new_outputs;
|
|
||||||
self.outputs_changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_compositor(&mut self, compositor: Option<wl_compositor::WlCompositor>) {
|
|
||||||
self.compositor = compositor
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_shell(&mut self, shell: Option<zwlr_layer_shell_v1::ZwlrLayerShellV1>) {
|
|
||||||
self.shell = shell
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct App {
|
|
||||||
pools: DoubleMemPool,
|
|
||||||
display: Display,
|
|
||||||
event_queue: EventQueue,
|
|
||||||
cmd_queue: Arc<Mutex<VecDeque<Cmd>>>,
|
|
||||||
widget: Option<Box<dyn Widget + Send>>,
|
|
||||||
bg: Color,
|
|
||||||
inner: Arc<Mutex<AppInner>>,
|
|
||||||
last_damage: Option<Vec<(i32, i32, i32, i32)>>,
|
|
||||||
last_dim: (u32, u32),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl App {
|
|
||||||
pub fn redraw(&mut self, force: bool) -> Result<(), ::std::io::Error> {
|
|
||||||
let widget = match self.widget {
|
|
||||||
Some(ref mut widget) => widget,
|
|
||||||
None => return Ok(()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let inner = self.inner.lock().unwrap();
|
|
||||||
let time = Local::now();
|
|
||||||
|
|
||||||
if !inner.visible
|
|
||||||
|| inner.shell_surfaces.len() != *inner.configured_surfaces.lock().unwrap()
|
|
||||||
|| inner.surfaces.len() == 0
|
|
||||||
{
|
|
||||||
// Not ready yet
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
let (last, pool) = match self.pools.pool() {
|
|
||||||
Some((last, pool)) => (last, pool),
|
|
||||||
None => return Ok(()),
|
|
||||||
};
|
|
||||||
|
|
||||||
let size = widget.size();
|
|
||||||
let size_changed = self.last_dim != size;
|
|
||||||
let force = force | size_changed;
|
|
||||||
|
|
||||||
// resize the pool if relevant
|
|
||||||
pool.resize((4 * size.0 * size.1) as usize)
|
|
||||||
.expect("Failed to resize the memory pool.");
|
|
||||||
let mmap = pool.mmap();
|
|
||||||
let mut buf = Buffer::new(mmap, size);
|
|
||||||
|
|
||||||
// Copy old damage
|
|
||||||
let force = match (force, &self.last_damage) {
|
|
||||||
(false, Some(d)) => {
|
|
||||||
let lastmmap = last.mmap();
|
|
||||||
let last = Buffer::new(lastmmap, size);
|
|
||||||
|
|
||||||
if cfg!(feature = "damage_debug") {
|
|
||||||
buf.memset(&Color::new(0.5, 0.75, 0.75, 1.0));
|
|
||||||
}
|
|
||||||
for d in d {
|
|
||||||
last.copy_to(&mut buf, d.clone());
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
_ => true,
|
|
||||||
};
|
|
||||||
|
|
||||||
if force {
|
|
||||||
buf.memset(&self.bg);
|
|
||||||
}
|
|
||||||
let report = widget.draw(
|
|
||||||
&mut DrawContext {
|
|
||||||
buf: &mut buf,
|
|
||||||
bg: &self.bg,
|
|
||||||
time: &time,
|
|
||||||
force,
|
|
||||||
},
|
|
||||||
(0, 0),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
mmap.flush().unwrap();
|
|
||||||
|
|
||||||
if !force && !report.full_damage && report.damage.len() == 0 {
|
|
||||||
// Nothing to do
|
|
||||||
self.pools.never_mind();
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a buffer and attach it
|
|
||||||
let new_buffer = pool.buffer(
|
|
||||||
0,
|
|
||||||
report.width as i32,
|
|
||||||
report.height as i32,
|
|
||||||
4 * size.0 as i32,
|
|
||||||
wl_shm::Format::Argb8888,
|
|
||||||
);
|
|
||||||
if size_changed {
|
|
||||||
for shell_surface in inner.shell_surfaces.iter() {
|
|
||||||
shell_surface.set_size(size.0 / inner.scale, size.1 / inner.scale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for surface in inner.surfaces.iter() {
|
|
||||||
surface.attach(Some(&new_buffer), 0, 0);
|
|
||||||
if cfg!(feature = "damage_debug") || force || report.full_damage {
|
|
||||||
surface.damage_buffer(0, 0, size.0 as i32, size.1 as i32);
|
|
||||||
} else {
|
|
||||||
for d in report.damage.iter() {
|
|
||||||
surface.damage_buffer(d.0, d.1, d.2, d.3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
surface.commit();
|
|
||||||
}
|
|
||||||
self.last_damage = if force || report.full_damage {
|
|
||||||
Some(vec![(0, 0, size.0 as i32, size.1 as i32)])
|
|
||||||
} else {
|
|
||||||
Some(report.damage)
|
|
||||||
};
|
|
||||||
self.last_dim = size;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hide(&mut self) {
|
|
||||||
let mut inner = self.inner.lock().unwrap();
|
|
||||||
inner.visible = false;
|
|
||||||
self.last_dim = (0, 0);
|
|
||||||
inner.outputs_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn show(&mut self) {
|
|
||||||
let mut inner = self.inner.lock().unwrap();
|
|
||||||
inner.visible = true;
|
|
||||||
self.last_dim = (0, 0);
|
|
||||||
inner.outputs_changed();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn cmd_queue(&self) -> Arc<Mutex<VecDeque<Cmd>>> {
|
|
||||||
self.cmd_queue.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn flush_display(&mut self) {
|
|
||||||
self.display.flush().expect("unable to flush display");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn event_queue(&mut self) -> &mut EventQueue {
|
|
||||||
&mut self.event_queue
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_widget(&mut self) -> &mut Box<dyn Widget + Send> {
|
|
||||||
self.widget.as_mut().unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_widget(&mut self, w: Box<dyn Widget + Send>) -> Result<(), ::std::io::Error> {
|
|
||||||
self.widget = Some(w);
|
|
||||||
self.redraw(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(tx: Sender<Cmd>, output_mode: OutputMode, bg: Color, scale: u32) -> App {
|
|
||||||
let inner = Arc::new(Mutex::new(AppInner::new(tx.clone(), output_mode, scale)));
|
|
||||||
|
|
||||||
//
|
|
||||||
// Set up modules
|
|
||||||
//
|
|
||||||
|
|
||||||
let cmd_queue = Arc::new(Mutex::new(VecDeque::new()));
|
|
||||||
|
|
||||||
let (display, mut event_queue) = Display::connect_to_env().unwrap();
|
|
||||||
|
|
||||||
let display_wrapper = display
|
|
||||||
.as_ref()
|
|
||||||
.make_wrapper(&event_queue.get_token())
|
|
||||||
.unwrap()
|
|
||||||
.into();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Set up global manager
|
|
||||||
//
|
|
||||||
let inner_global = inner.clone();
|
|
||||||
let manager =
|
|
||||||
GlobalManager::new_with_cb(&display_wrapper, move |event, registry| match event {
|
|
||||||
GlobalEvent::New {
|
|
||||||
id,
|
|
||||||
ref interface,
|
|
||||||
version,
|
|
||||||
} => {
|
|
||||||
if let "wl_output" = &interface[..] {
|
|
||||||
let output = registry
|
|
||||||
.bind(version, id, move |output| {
|
|
||||||
output.implement_closure(move |_, _| {}, ())
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
inner_global.lock().unwrap().add_output(id, output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GlobalEvent::Removed { id, ref interface } => {
|
|
||||||
if let "wl_output" = &interface[..] {
|
|
||||||
inner_global.lock().unwrap().remove_output(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// double sync to retrieve the global list
|
|
||||||
// and the globals metadata
|
|
||||||
event_queue.sync_roundtrip().unwrap();
|
|
||||||
event_queue.sync_roundtrip().unwrap();
|
|
||||||
|
|
||||||
// wl_compositor
|
|
||||||
let compositor: wl_compositor::WlCompositor = manager
|
|
||||||
.instantiate_range(1, 4, NewProxy::implement_dummy)
|
|
||||||
.expect("server didn't advertise `wl_compositor`");
|
|
||||||
|
|
||||||
inner.lock().unwrap().set_compositor(Some(compositor));
|
|
||||||
|
|
||||||
// wl_shm
|
|
||||||
let shm_formats = Arc::new(Mutex::new(Vec::new()));
|
|
||||||
let shm_formats2 = shm_formats.clone();
|
|
||||||
let shm = manager
|
|
||||||
.instantiate_range(1, 1, |shm| {
|
|
||||||
shm.implement_closure(
|
|
||||||
move |evt, _| {
|
|
||||||
if let wl_shm::Event::Format { format } = evt {
|
|
||||||
shm_formats2.lock().unwrap().push(format);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.expect("server didn't advertise `wl_shm`");
|
|
||||||
|
|
||||||
let pools = DoubleMemPool::new(&shm).expect("Failed to create a memory pool !");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get our seat
|
|
||||||
//
|
|
||||||
let seat = manager
|
|
||||||
.instantiate_range(1, 6, NewProxy::implement_dummy)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Keyboard processing
|
|
||||||
//
|
|
||||||
let kbd_clone = cmd_queue.clone();
|
|
||||||
let modifiers_state = Arc::new(Mutex::new(ModifiersState {
|
|
||||||
ctrl: false,
|
|
||||||
alt: false,
|
|
||||||
shift: false,
|
|
||||||
caps_lock: false,
|
|
||||||
logo: false,
|
|
||||||
num_lock: false,
|
|
||||||
}));
|
|
||||||
map_keyboard_auto(&seat, move |event: KbEvent, _| match event {
|
|
||||||
KbEvent::Key {
|
|
||||||
keysym,
|
|
||||||
utf8,
|
|
||||||
state,
|
|
||||||
..
|
|
||||||
} => match state {
|
|
||||||
KeyState::Pressed => match keysym {
|
|
||||||
keysyms::XKB_KEY_Escape => kbd_clone.lock().unwrap().push_back(Cmd::Exit),
|
|
||||||
keysyms::XKB_KEY_c if modifiers_state.lock().unwrap().ctrl => {
|
|
||||||
kbd_clone.lock().unwrap().push_back(Cmd::Exit)
|
|
||||||
}
|
|
||||||
v => kbd_clone.lock().unwrap().push_back(Cmd::Keyboard {
|
|
||||||
key: v,
|
|
||||||
key_state: state,
|
|
||||||
modifiers_state: modifiers_state.lock().unwrap().clone(),
|
|
||||||
interpreted: utf8,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
},
|
|
||||||
KbEvent::Modifiers { modifiers } => *modifiers_state.lock().unwrap() = modifiers,
|
|
||||||
_ => (),
|
|
||||||
})
|
|
||||||
.expect("Failed to map keyboard");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Prepare shell so that we can create our shell surface
|
|
||||||
//
|
|
||||||
inner.lock().unwrap().set_shell(Some(
|
|
||||||
if let Ok(layer) = manager.instantiate_exact(
|
|
||||||
1,
|
|
||||||
|layer: NewProxy<zwlr_layer_shell_v1::ZwlrLayerShellV1>| {
|
|
||||||
layer.implement_closure(|_, _| {}, ())
|
|
||||||
},
|
|
||||||
) {
|
|
||||||
layer
|
|
||||||
} else {
|
|
||||||
panic!("server didn't advertise `zwlr_layer_shell_v1`");
|
|
||||||
},
|
|
||||||
));
|
|
||||||
|
|
||||||
event_queue.sync_roundtrip().unwrap();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Cursor processing
|
|
||||||
//
|
|
||||||
let pointer_clone = cmd_queue.clone();
|
|
||||||
seat.get_pointer(move |ptr| {
|
|
||||||
let mut pos: (u32, u32) = (0, 0);
|
|
||||||
let mut vert_scroll: f64 = 0.0;
|
|
||||||
let mut horiz_scroll: f64 = 0.0;
|
|
||||||
let mut btn: u32 = 0;
|
|
||||||
let mut btn_clicked = false;
|
|
||||||
ptr.implement_closure(
|
|
||||||
move |evt, _| match evt {
|
|
||||||
wl_pointer::Event::Enter {
|
|
||||||
surface_x,
|
|
||||||
surface_y,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
pos = (surface_x as u32, surface_y as u32);
|
|
||||||
}
|
|
||||||
wl_pointer::Event::Leave { .. } => {
|
|
||||||
pos = (0, 0);
|
|
||||||
}
|
|
||||||
wl_pointer::Event::Motion {
|
|
||||||
surface_x,
|
|
||||||
surface_y,
|
|
||||||
..
|
|
||||||
} => {
|
|
||||||
pos = (surface_x as u32 * scale, surface_y as u32 * scale);
|
|
||||||
}
|
|
||||||
wl_pointer::Event::Axis { axis, value, .. } => {
|
|
||||||
if axis == wl_pointer::Axis::VerticalScroll {
|
|
||||||
vert_scroll += value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
wl_pointer::Event::Button { button, state, .. } => match state {
|
|
||||||
wl_pointer::ButtonState::Released => {
|
|
||||||
btn = button;
|
|
||||||
btn_clicked = true;
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
wl_pointer::Event::Frame => {
|
|
||||||
if vert_scroll != 0.0 || horiz_scroll != 0.0 {
|
|
||||||
pointer_clone.lock().unwrap().push_back(Cmd::MouseScroll {
|
|
||||||
scroll: (horiz_scroll, vert_scroll),
|
|
||||||
pos: pos,
|
|
||||||
});
|
|
||||||
vert_scroll = 0.0;
|
|
||||||
horiz_scroll = 0.0;
|
|
||||||
}
|
|
||||||
if btn_clicked {
|
|
||||||
pointer_clone
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.push_back(Cmd::MouseClick { btn: btn, pos: pos });
|
|
||||||
btn_clicked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
display.flush().unwrap();
|
|
||||||
|
|
||||||
App {
|
|
||||||
display: display,
|
|
||||||
event_queue: event_queue,
|
|
||||||
cmd_queue: cmd_queue,
|
|
||||||
pools: pools,
|
|
||||||
widget: None,
|
|
||||||
bg: bg,
|
|
||||||
inner: inner,
|
|
||||||
last_damage: None,
|
|
||||||
last_dim: (0, 0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-180
@@ -1,180 +0,0 @@
|
|||||||
use memmap::MmapMut;
|
|
||||||
|
|
||||||
use crate::color::Color;
|
|
||||||
|
|
||||||
pub struct Buffer<'a> {
|
|
||||||
buf: &'a mut MmapMut,
|
|
||||||
dimensions: (u32, u32),
|
|
||||||
subdimensions: Option<(u32, u32, u32, u32)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> Buffer<'a> {
|
|
||||||
pub fn new(buf: &'a mut MmapMut, dimensions: (u32, u32)) -> Buffer {
|
|
||||||
Buffer {
|
|
||||||
buf: buf,
|
|
||||||
dimensions: dimensions,
|
|
||||||
subdimensions: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_bounds(&self) -> (u32, u32, u32, u32) {
|
|
||||||
if let Some(subdim) = self.subdimensions {
|
|
||||||
subdim
|
|
||||||
} else {
|
|
||||||
(0, 0, self.dimensions.0, self.dimensions.1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_signed_bounds(&self) -> (i32, i32, i32, i32) {
|
|
||||||
if let Some(subdim) = self.subdimensions {
|
|
||||||
(
|
|
||||||
subdim.0 as i32,
|
|
||||||
subdim.1 as i32,
|
|
||||||
subdim.2 as i32,
|
|
||||||
subdim.3 as i32,
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
(0, 0, self.dimensions.0 as i32, self.dimensions.1 as i32)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn copy_to(&self, other: &mut Buffer, (x, y, width, height): (i32, i32, i32, i32)) {
|
|
||||||
debug_assert!(self.dimensions == other.dimensions);
|
|
||||||
debug_assert!(self.subdimensions.is_none() && other.subdimensions.is_none());
|
|
||||||
|
|
||||||
if x == 0 && width as u32 == self.dimensions.0 {
|
|
||||||
// Full-width copy
|
|
||||||
let offset = y as isize * self.dimensions.0 as isize;
|
|
||||||
let n = height as usize * self.dimensions.0 as usize;
|
|
||||||
unsafe {
|
|
||||||
std::ptr::copy(
|
|
||||||
(self.buf.as_ptr() as *const u32).offset(offset),
|
|
||||||
(other.buf.as_mut_ptr() as *mut u32).offset(offset),
|
|
||||||
n,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Row-by-row copy
|
|
||||||
for cur_y in y as isize..(y + height) as isize {
|
|
||||||
let offset = x as isize + cur_y as isize * self.dimensions.0 as isize;
|
|
||||||
unsafe {
|
|
||||||
std::ptr::copy(
|
|
||||||
(self.buf.as_ptr() as *const u32).offset(offset),
|
|
||||||
(other.buf.as_mut_ptr() as *mut u32).offset(offset),
|
|
||||||
width as usize,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn subdimensions(
|
|
||||||
&mut self,
|
|
||||||
subdimensions: (u32, u32, u32, u32),
|
|
||||||
) -> Result<Buffer, ::std::io::Error> {
|
|
||||||
let bounds = self.get_bounds();
|
|
||||||
if subdimensions.0 + subdimensions.2 >= bounds.2
|
|
||||||
|| subdimensions.1 + subdimensions.3 >= bounds.3
|
|
||||||
{
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"cannot create subdimensions larger than buffer: {:?} > {:?}",
|
|
||||||
subdimensions, bounds
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Buffer {
|
|
||||||
buf: self.buf,
|
|
||||||
dimensions: self.dimensions,
|
|
||||||
subdimensions: Some((
|
|
||||||
subdimensions.0 + bounds.0,
|
|
||||||
subdimensions.1 + bounds.1,
|
|
||||||
subdimensions.2,
|
|
||||||
subdimensions.3,
|
|
||||||
)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn offset(&mut self, offset: (u32, u32)) -> Result<Buffer, ::std::io::Error> {
|
|
||||||
let bounds = self.get_bounds();
|
|
||||||
if offset.0 > bounds.2 || offset.1 > bounds.3 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"cannot create offset outside buffer: {:?} > {:?}",
|
|
||||||
offset, bounds
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(Buffer {
|
|
||||||
buf: self.buf,
|
|
||||||
dimensions: self.dimensions,
|
|
||||||
subdimensions: Some((
|
|
||||||
offset.0 + bounds.0,
|
|
||||||
offset.1 + bounds.1,
|
|
||||||
bounds.2 - offset.0,
|
|
||||||
bounds.3 - offset.1,
|
|
||||||
)),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn memset(&mut self, c: &Color) {
|
|
||||||
if let Some(subdim) = self.subdimensions {
|
|
||||||
unsafe {
|
|
||||||
let ptr = self.buf.as_mut_ptr();
|
|
||||||
for y in subdim.1..(subdim.1 + subdim.3) {
|
|
||||||
for x in subdim.0..(subdim.0 + subdim.2) {
|
|
||||||
*((ptr as *mut u32).offset((x + y * self.dimensions.0) as isize)) =
|
|
||||||
c.as_argb8888();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
unsafe {
|
|
||||||
let ptr = self.buf.as_mut_ptr();
|
|
||||||
for p in 0..(self.dimensions.0 * self.dimensions.1) {
|
|
||||||
*((ptr as *mut u32).offset(p as isize)) = c.as_argb8888();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn put(&mut self, pos: (u32, u32), c: &Color) -> Result<(), ::std::io::Error> {
|
|
||||||
let true_pos = if let Some(subdim) = self.subdimensions {
|
|
||||||
if pos.0 >= subdim.2 || pos.1 >= subdim.3 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"put({:?}) is not within subdimensions of buffer ({:?})",
|
|
||||||
pos, subdim
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
(pos.0 + subdim.0, pos.1 + subdim.1)
|
|
||||||
} else {
|
|
||||||
if pos.0 >= self.dimensions.0 || pos.1 >= self.dimensions.1 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
format!(
|
|
||||||
"put({:?}) is not within dimensions of buffer ({:?})",
|
|
||||||
pos, self.dimensions
|
|
||||||
),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
pos
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let ptr = self
|
|
||||||
.buf
|
|
||||||
.as_mut_ptr()
|
|
||||||
.offset(4 * (true_pos.0 + (true_pos.1 * self.dimensions.0)) as isize);
|
|
||||||
*(ptr as *mut u32) = c.as_argb8888();
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
use smithay_client_toolkit::keyboard::{KeyState, ModifiersState};
|
|
||||||
|
|
||||||
pub enum Cmd {
|
|
||||||
Exit,
|
|
||||||
Draw,
|
|
||||||
ForceDraw,
|
|
||||||
ToggleVisible,
|
|
||||||
MouseClick {
|
|
||||||
btn: u32,
|
|
||||||
pos: (u32, u32),
|
|
||||||
},
|
|
||||||
MouseScroll {
|
|
||||||
scroll: (f64, f64),
|
|
||||||
pos: (u32, u32),
|
|
||||||
},
|
|
||||||
Keyboard {
|
|
||||||
key: u32,
|
|
||||||
key_state: KeyState,
|
|
||||||
modifiers_state: ModifiersState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Default)]
|
|
||||||
pub struct Color {
|
|
||||||
red: f32,
|
|
||||||
green: f32,
|
|
||||||
blue: f32,
|
|
||||||
opacity: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Color {
|
|
||||||
pub fn new(red: f32, green: f32, blue: f32, opacity: f32) -> Color {
|
|
||||||
let (red, green, blue, opacity) = clamp(red, green, blue, opacity);
|
|
||||||
Color {
|
|
||||||
red,
|
|
||||||
green,
|
|
||||||
blue,
|
|
||||||
opacity,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn blend(&self, other: &Color, ratio: f32) -> Color {
|
|
||||||
let ratio = clamp_f32(ratio, 0.0, 1.0);
|
|
||||||
|
|
||||||
Color {
|
|
||||||
red: blend_f32(self.red, other.red, ratio),
|
|
||||||
green: blend_f32(self.green, other.green, ratio),
|
|
||||||
blue: blend_f32(self.blue, other.blue, ratio),
|
|
||||||
opacity: blend_f32(self.opacity, other.opacity, ratio),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn as_argb8888(&self) -> u32 {
|
|
||||||
((255.0 * self.opacity) as u32 & 0xFF) << 24
|
|
||||||
| ((255.0 * self.red) as u32 & 0xFF) << 16
|
|
||||||
| ((255.0 * self.green) as u32 & 0xFF) << 8
|
|
||||||
| ((255.0 * self.blue) as u32 & 0xFF)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn clamp(r: f32, g: f32, b: f32, o: f32) -> (f32, f32, f32, f32) {
|
|
||||||
clamp_naive(r, g, b, o)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn clamp_naive(r: f32, g: f32, b: f32, o: f32) -> (f32, f32, f32, f32) {
|
|
||||||
(
|
|
||||||
clamp_f32(r, 0.0, 1.0),
|
|
||||||
clamp_f32(g, 0.0, 1.0),
|
|
||||||
clamp_f32(b, 0.0, 1.0),
|
|
||||||
clamp_f32(o, 0.0, 1.0),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn clamp_f32(v: f32, a: f32, b: f32) -> f32 {
|
|
||||||
if v > b {
|
|
||||||
b
|
|
||||||
} else if v < a {
|
|
||||||
a
|
|
||||||
} else {
|
|
||||||
v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn blend_f32(a: f32, b: f32, r: f32) -> f32 {
|
|
||||||
a + ((b - a) * r)
|
|
||||||
}
|
|
||||||
-237
@@ -1,237 +0,0 @@
|
|||||||
use crate::cmd::Cmd;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::widget;
|
|
||||||
use crate::widgets;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::default::Default;
|
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub enum Widget {
|
|
||||||
Margin {
|
|
||||||
margins: (u32, u32, u32, u32),
|
|
||||||
widget: Box<Widget>,
|
|
||||||
},
|
|
||||||
Fixed {
|
|
||||||
width: u32,
|
|
||||||
height: u32,
|
|
||||||
widget: Box<Widget>,
|
|
||||||
},
|
|
||||||
HorizontalLayout(Vec<Box<Widget>>),
|
|
||||||
VerticalLayout(Vec<Box<Widget>>),
|
|
||||||
Clock {
|
|
||||||
font_size: f32,
|
|
||||||
},
|
|
||||||
Date {
|
|
||||||
font_size: f32,
|
|
||||||
},
|
|
||||||
Calendar {
|
|
||||||
font_size: f32,
|
|
||||||
sections: u32,
|
|
||||||
},
|
|
||||||
Launcher {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
#[serde(default)]
|
|
||||||
app_opener: String,
|
|
||||||
#[serde(default)]
|
|
||||||
term_opener: String,
|
|
||||||
#[serde(default)]
|
|
||||||
url_opener: String,
|
|
||||||
},
|
|
||||||
Battery {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
},
|
|
||||||
Backlight {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
},
|
|
||||||
#[cfg(feature = "pulseaudio-widget")]
|
|
||||||
PulseAudio {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
},
|
|
||||||
#[cfg(feature = "alsa-widget")]
|
|
||||||
AlsaSound {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
},
|
|
||||||
NetworkManager {
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget {
|
|
||||||
pub fn construct(self, tx: Sender<Cmd>) -> Option<Box<dyn widget::Widget + Send>> {
|
|
||||||
match self {
|
|
||||||
Widget::Margin { margins, widget } => match widget.construct(tx.clone()) {
|
|
||||||
Some(w) => Some(widget::Margin::new(margins, w)),
|
|
||||||
None => None,
|
|
||||||
},
|
|
||||||
Widget::Fixed {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
widget,
|
|
||||||
} => match widget.construct(tx.clone()) {
|
|
||||||
Some(w) => Some(widget::Fixed::new((width, height), w)),
|
|
||||||
None => None,
|
|
||||||
},
|
|
||||||
Widget::HorizontalLayout(widgets) => Some(widget::HorizontalLayout::new(
|
|
||||||
widgets
|
|
||||||
.into_iter()
|
|
||||||
.map(|x| x.construct(tx.clone()))
|
|
||||||
.filter(|x| x.is_some())
|
|
||||||
.map(|x| x.unwrap())
|
|
||||||
.collect(),
|
|
||||||
)),
|
|
||||||
Widget::VerticalLayout(widgets) => Some(widget::VerticalLayout::new(
|
|
||||||
widgets
|
|
||||||
.into_iter()
|
|
||||||
.map(|x| x.construct(tx.clone()))
|
|
||||||
.filter(|x| x.is_some())
|
|
||||||
.map(|x| x.unwrap())
|
|
||||||
.collect(),
|
|
||||||
)),
|
|
||||||
Widget::Clock { font_size } => Some(widgets::clock::Clock::new(font_size)),
|
|
||||||
Widget::Date { font_size } => Some(widgets::date::Date::new(font_size)),
|
|
||||||
Widget::Calendar {
|
|
||||||
font_size,
|
|
||||||
sections,
|
|
||||||
} => Some(widgets::calendar::Calendar::new(font_size, sections)),
|
|
||||||
Widget::Launcher {
|
|
||||||
font_size,
|
|
||||||
length,
|
|
||||||
app_opener,
|
|
||||||
term_opener,
|
|
||||||
url_opener,
|
|
||||||
} => Some(widgets::launcher::Launcher::new(
|
|
||||||
font_size,
|
|
||||||
length,
|
|
||||||
tx.clone(),
|
|
||||||
app_opener,
|
|
||||||
term_opener,
|
|
||||||
if url_opener.len() == 0 {
|
|
||||||
"xdg_open ".to_string()
|
|
||||||
} else {
|
|
||||||
url_opener
|
|
||||||
},
|
|
||||||
)),
|
|
||||||
Widget::Battery { font_size, length } => {
|
|
||||||
match widgets::battery::UpowerBattery::new(font_size, length, tx.clone()) {
|
|
||||||
Ok(w) => Some(w),
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Widget::Backlight { font_size, length } => {
|
|
||||||
match widgets::backlight::Backlight::new(font_size, length) {
|
|
||||||
Ok(w) => Some(w),
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(feature = "pulseaudio-widget")]
|
|
||||||
Widget::PulseAudio { font_size, length } => {
|
|
||||||
match widgets::audio::PulseAudio::new(font_size, length, tx.clone()) {
|
|
||||||
Ok(w) => Some(w),
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[cfg(feature = "alsa-widget")]
|
|
||||||
Widget::AlsaSound { font_size, length } => {
|
|
||||||
match widgets::audio::Alsa::new(font_size, length) {
|
|
||||||
Ok(w) => Some(w),
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Widget::NetworkManager { font_size, length } => {
|
|
||||||
match widgets::networkmanager::NetworkManager::new(font_size, length, tx.clone()) {
|
|
||||||
Ok(w) => Some(w),
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub enum OutputMode {
|
|
||||||
All,
|
|
||||||
Active,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for OutputMode {
|
|
||||||
fn default() -> Self {
|
|
||||||
OutputMode::Active
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Config {
|
|
||||||
pub output_mode: OutputMode,
|
|
||||||
pub scale: u32,
|
|
||||||
pub background: Color,
|
|
||||||
pub widget: Widget,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Config {
|
|
||||||
fn default() -> Self {
|
|
||||||
Config {
|
|
||||||
widget: Widget::Margin {
|
|
||||||
margins: (20, 20, 20, 20),
|
|
||||||
widget: Box::new(Widget::VerticalLayout(vec![
|
|
||||||
Box::new(Widget::HorizontalLayout(vec![
|
|
||||||
Box::new(Widget::Margin {
|
|
||||||
margins: (0, 88, 0, 32),
|
|
||||||
widget: Box::new(Widget::VerticalLayout(vec![
|
|
||||||
Box::new(Widget::Date { font_size: 64.0 }),
|
|
||||||
Box::new(Widget::Clock { font_size: 256.0 }),
|
|
||||||
])),
|
|
||||||
}),
|
|
||||||
Box::new(Widget::VerticalLayout(vec![
|
|
||||||
Box::new(Widget::Margin {
|
|
||||||
margins: (0, 0, 0, 8),
|
|
||||||
widget: Box::new(Widget::Battery {
|
|
||||||
font_size: 24.0,
|
|
||||||
length: 600,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
Box::new(Widget::Margin {
|
|
||||||
margins: (0, 0, 0, 8),
|
|
||||||
widget: Box::new(Widget::Backlight {
|
|
||||||
font_size: 24.0,
|
|
||||||
length: 600,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
#[cfg(feature = "pulseaudio-widget")]
|
|
||||||
Box::new(Widget::Margin {
|
|
||||||
margins: (0, 0, 0, 8),
|
|
||||||
widget: Box::new(Widget::PulseAudio {
|
|
||||||
font_size: 24.0,
|
|
||||||
length: 600,
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
])),
|
|
||||||
])),
|
|
||||||
Box::new(Widget::Calendar {
|
|
||||||
font_size: 16.0,
|
|
||||||
sections: 3,
|
|
||||||
}),
|
|
||||||
Box::new(Widget::Launcher {
|
|
||||||
font_size: 32.0,
|
|
||||||
length: 1200,
|
|
||||||
app_opener: "".to_string(),
|
|
||||||
term_opener: "".to_string(),
|
|
||||||
url_opener: "".to_string(),
|
|
||||||
}),
|
|
||||||
])),
|
|
||||||
},
|
|
||||||
output_mode: Default::default(),
|
|
||||||
scale: 1,
|
|
||||||
background: Color::new(0.0, 0.0, 0.0, 0.9),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
use serde::{de::DeserializeOwned, Serialize};
|
|
||||||
use std::io::BufRead;
|
|
||||||
|
|
||||||
pub enum ConfigFmt {
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
Yaml,
|
|
||||||
#[cfg(feature = "json-cfg")]
|
|
||||||
Json,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub const CONFIG_NAMES: &'static [&'static str] = &[
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
"config.yaml",
|
|
||||||
#[cfg(feature = "json-cfg")]
|
|
||||||
"config.json",
|
|
||||||
];
|
|
||||||
|
|
||||||
impl ConfigFmt {
|
|
||||||
#[inline]
|
|
||||||
pub fn new(ext: &str) -> Option<Self> {
|
|
||||||
match ext {
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
"yaml" => Some(ConfigFmt::Yaml),
|
|
||||||
#[cfg(feature = "json-cfg")]
|
|
||||||
"json" => Some(ConfigFmt::Json),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn from_reader<B: BufRead, T: DeserializeOwned>(&self, r: B) -> T {
|
|
||||||
match self {
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
ConfigFmt::Yaml => serde_yaml::from_reader(r).unwrap(),
|
|
||||||
#[cfg(feature = "json-cfg")]
|
|
||||||
ConfigFmt::Json => serde_json::from_reader(r).unwrap(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn to_string<T: Serialize + ?Sized>(&self, src: &T) -> String {
|
|
||||||
match self {
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
ConfigFmt::Yaml => serde_yaml::to_string(&src).unwrap(),
|
|
||||||
#[cfg(feature = "json-cfg")]
|
|
||||||
ConfigFmt::Json => serde_json::to_string_pretty(&src).unwrap(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for ConfigFmt {
|
|
||||||
fn default() -> Self {
|
|
||||||
// attributes require curly braces to work
|
|
||||||
#[cfg(feature = "yaml-cfg")]
|
|
||||||
{
|
|
||||||
ConfigFmt::Yaml
|
|
||||||
}
|
|
||||||
#[cfg(all(feature = "json-cfg", not(feature = "yaml-cfg")))]
|
|
||||||
{
|
|
||||||
ConfigFmt::Json
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-101
@@ -1,101 +0,0 @@
|
|||||||
extern crate ini;
|
|
||||||
use ini::{Ini, ParseOption};
|
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::env;
|
|
||||||
use std::error::Error;
|
|
||||||
use std::fs;
|
|
||||||
use std::io::Error as io_error;
|
|
||||||
use std::io::ErrorKind;
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq)]
|
|
||||||
pub struct Desktop {
|
|
||||||
pub entry_type: String,
|
|
||||||
pub name: String,
|
|
||||||
pub no_display: bool,
|
|
||||||
pub hidden: bool,
|
|
||||||
pub exec: Option<String>,
|
|
||||||
pub url: Option<String>,
|
|
||||||
pub term: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Desktop {
|
|
||||||
fn parse(f: &str) -> Result<Desktop, Box<dyn Error>> {
|
|
||||||
let file = Ini::load_from_file_opt(
|
|
||||||
f,
|
|
||||||
ParseOption {
|
|
||||||
enabled_quote: false,
|
|
||||||
enabled_escape: false,
|
|
||||||
},
|
|
||||||
)?;
|
|
||||||
match file.section(Some("Desktop Entry")) {
|
|
||||||
Some(desktop) => Ok(Desktop {
|
|
||||||
entry_type: desktop.get("Type").unwrap_or(&"".to_string()).to_string(),
|
|
||||||
name: desktop.get("Name").unwrap_or(&"".to_string()).to_string(),
|
|
||||||
term: desktop.get("Terminal").unwrap_or(&"".to_string()) == "true",
|
|
||||||
no_display: desktop.get("NoDisplay").unwrap_or(&"".to_string()) == "true",
|
|
||||||
hidden: desktop.get("Hidden").unwrap_or(&"".to_string()) == "true",
|
|
||||||
exec: desktop.get("Exec").map(|x| x.to_string()),
|
|
||||||
url: desktop.get("URL").map(|x| x.to_string()),
|
|
||||||
}),
|
|
||||||
None => Err(Box::new(io_error::new(
|
|
||||||
ErrorKind::NotFound,
|
|
||||||
"no desktop entry in file",
|
|
||||||
))),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_dir(d: &str) -> Result<Vec<Desktop>, Box<dyn Error>> {
|
|
||||||
let mut files: Vec<Desktop> = Vec::with_capacity(16);
|
|
||||||
for entry in fs::read_dir(d)? {
|
|
||||||
let entry = entry?;
|
|
||||||
let path = entry.path();
|
|
||||||
|
|
||||||
if let Ok(d) = Desktop::parse(path.to_str().unwrap()) {
|
|
||||||
files.push(d)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ord for Desktop {
|
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
|
||||||
self.name.cmp(&other.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialOrd for Desktop {
|
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
|
||||||
Some(self.cmp(other))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PartialEq for Desktop {
|
|
||||||
fn eq(&self, other: &Self) -> bool {
|
|
||||||
self.name == other.name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load_desktop_files() -> Vec<Desktop> {
|
|
||||||
let home = env::var_os("HOME").unwrap().into_string().unwrap();
|
|
||||||
|
|
||||||
let xdg_data_home = match env::var_os("XDG_DATA_HOME") {
|
|
||||||
Some(s) => s.into_string().unwrap(),
|
|
||||||
None => format!("{}/.local/share", home).to_string(),
|
|
||||||
};
|
|
||||||
let xdg_data_dirs = match env::var_os("XDG_DATA_DIRS") {
|
|
||||||
Some(s) => s.into_string().unwrap(),
|
|
||||||
None => "/usr/local/share:/usr/share".to_string(),
|
|
||||||
};
|
|
||||||
|
|
||||||
std::iter::once(xdg_data_home.as_str())
|
|
||||||
.chain(xdg_data_dirs.split(":"))
|
|
||||||
.map(|p| Desktop::parse_dir(&format!("{}/applications", p)))
|
|
||||||
.filter_map(Result::ok)
|
|
||||||
.flatten()
|
|
||||||
.filter(|d| {
|
|
||||||
!d.hidden && !d.no_display && (d.entry_type == "Application" || d.entry_type == "Link")
|
|
||||||
})
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
use smithay_client_toolkit::utils::MemPool;
|
|
||||||
use wayland_client::protocol::wl_shm;
|
|
||||||
|
|
||||||
pub struct DoubleMemPool {
|
|
||||||
pool1: MemPool,
|
|
||||||
pool2: MemPool,
|
|
||||||
switch: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DoubleMemPool {
|
|
||||||
pub fn new(shm: &wl_shm::WlShm) -> ::std::io::Result<DoubleMemPool> {
|
|
||||||
Ok(DoubleMemPool {
|
|
||||||
pool1: MemPool::new(shm, move || {})?,
|
|
||||||
pool2: MemPool::new(shm, move || {})?,
|
|
||||||
switch: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn pool(&mut self) -> Option<(&mut MemPool, &mut MemPool)> {
|
|
||||||
let switch = self.switch;
|
|
||||||
self.switch = !self.switch;
|
|
||||||
let (last, cur) = if !switch {
|
|
||||||
(&mut self.pool2, &mut self.pool1)
|
|
||||||
} else {
|
|
||||||
(&mut self.pool1, &mut self.pool2)
|
|
||||||
};
|
|
||||||
|
|
||||||
if cur.is_used() {
|
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some((last, cur))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn never_mind(&mut self) {
|
|
||||||
self.switch = !self.switch;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-263
@@ -1,263 +0,0 @@
|
|||||||
use crate::buffer::Buffer;
|
|
||||||
use crate::color::Color;
|
|
||||||
|
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
|
||||||
use rusttype::{point, Font as RustFont, Scale};
|
|
||||||
|
|
||||||
pub static DEJAVUSANS_MONO_FONT_DATA: &'static [u8] =
|
|
||||||
include_bytes!("../fonts/dejavu/DejaVuSansMono.ttf");
|
|
||||||
pub static ROBOTO_REGULAR_FONT_DATA: &'static [u8] = include_bytes!("../fonts/Roboto-Regular.ttf");
|
|
||||||
|
|
||||||
lazy_static! {
|
|
||||||
pub static ref DEJAVUSANS_MONO: RustFont<'static> =
|
|
||||||
RustFont::from_bytes(DEJAVUSANS_MONO_FONT_DATA as &[u8])
|
|
||||||
.expect("error constructing DejaVuSansMono");
|
|
||||||
pub static ref ROBOTO_REGULAR: RustFont<'static> =
|
|
||||||
RustFont::from_bytes(ROBOTO_REGULAR_FONT_DATA as &[u8])
|
|
||||||
.expect("error constructing Roboto-Regular");
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CachedGlyph {
|
|
||||||
dimensions: (u32, u32),
|
|
||||||
origin: (i32, i32),
|
|
||||||
render: Vec<f32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CachedGlyph {
|
|
||||||
fn new(font: &RustFont, size: f32, ch: char) -> CachedGlyph {
|
|
||||||
let scale = Scale::uniform(size);
|
|
||||||
let v_metrics = font.v_metrics(scale);
|
|
||||||
let glyph = font
|
|
||||||
.glyph(ch)
|
|
||||||
.scaled(scale)
|
|
||||||
.positioned(point(0.0, v_metrics.ascent));
|
|
||||||
|
|
||||||
if let Some(bounding_box) = glyph.pixel_bounding_box() {
|
|
||||||
let origin = (bounding_box.min.x, bounding_box.min.y);
|
|
||||||
|
|
||||||
let dimensions = (
|
|
||||||
(bounding_box.max.x - bounding_box.min.x) as u32,
|
|
||||||
(bounding_box.max.y - bounding_box.min.y) as u32,
|
|
||||||
);
|
|
||||||
let mut render = vec![0.0; (dimensions.0 * dimensions.1) as usize];
|
|
||||||
glyph.draw(|x, y, o| {
|
|
||||||
let pos = x + (y * dimensions.0);
|
|
||||||
render[pos as usize] = o;
|
|
||||||
});
|
|
||||||
CachedGlyph {
|
|
||||||
origin: origin,
|
|
||||||
dimensions: dimensions,
|
|
||||||
render: render,
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
CachedGlyph {
|
|
||||||
origin: (0, 0),
|
|
||||||
dimensions: ((size / 4.0) as u32, 0),
|
|
||||||
render: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(&self, buf: &mut Buffer, pos: (i32, i32), bg: &Color, c: &Color) {
|
|
||||||
let mut x = 0;
|
|
||||||
let mut y = 0;
|
|
||||||
for v in &self.render {
|
|
||||||
let _ = buf.put(
|
|
||||||
(
|
|
||||||
(x + pos.0 + self.origin.0) as u32,
|
|
||||||
(y + pos.1 + self.origin.1) as u32,
|
|
||||||
),
|
|
||||||
&bg.blend(&c, *v),
|
|
||||||
);
|
|
||||||
|
|
||||||
if x == self.dimensions.0 as i32 - 1 {
|
|
||||||
y += 1;
|
|
||||||
x = 0;
|
|
||||||
} else {
|
|
||||||
x += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Font {
|
|
||||||
glyphs: HashMap<char, CachedGlyph>,
|
|
||||||
font: &'static RustFont<'static>,
|
|
||||||
size: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Font {
|
|
||||||
pub fn new(font: &'static RustFont, size: f32) -> Font {
|
|
||||||
Font {
|
|
||||||
glyphs: HashMap::new(),
|
|
||||||
font: font,
|
|
||||||
size: size,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add_str_to_cache(&mut self, s: &str) {
|
|
||||||
for ch in s.chars() {
|
|
||||||
if self.glyphs.get(&ch).is_none() {
|
|
||||||
let glyph = CachedGlyph::new(self.font, self.size, ch);
|
|
||||||
self.glyphs.insert(ch, glyph);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_text(
|
|
||||||
&self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
bg: &Color,
|
|
||||||
c: &Color,
|
|
||||||
s: &str,
|
|
||||||
) -> Result<(u32, u32), ::std::io::Error> {
|
|
||||||
let mut x_off = 0;
|
|
||||||
let mut off = 0;
|
|
||||||
let mut glyphs = Vec::with_capacity(s.len());
|
|
||||||
for ch in s.chars() {
|
|
||||||
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),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
glyphs.push(glyph);
|
|
||||||
if glyph.origin.1 < off {
|
|
||||||
off = glyph.origin.1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for glyph in glyphs {
|
|
||||||
glyph.draw(buf, (x_off, -off), bg, c);
|
|
||||||
x_off += glyph.dimensions.0 as i32 + glyph.origin.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((x_off as u32, self.size as u32))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn auto_draw_text(
|
|
||||||
&mut self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
bg: &Color,
|
|
||||||
c: &Color,
|
|
||||||
s: &str,
|
|
||||||
) -> Result<(u32, u32), ::std::io::Error> {
|
|
||||||
self.add_str_to_cache(s);
|
|
||||||
self.draw_text(buf, bg, c, s)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_text_fixed_width(
|
|
||||||
&self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
bg: &Color,
|
|
||||||
c: &Color,
|
|
||||||
distances: &[u32],
|
|
||||||
s: &str,
|
|
||||||
) -> Result<(u32, u32), ::std::io::Error> {
|
|
||||||
let mut x_off = 0;
|
|
||||||
let mut off = 0;
|
|
||||||
let mut glyphs = Vec::with_capacity(s.len());
|
|
||||||
for ch in s.chars() {
|
|
||||||
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),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
glyphs.push(glyph);
|
|
||||||
if glyph.origin.1 < off {
|
|
||||||
off = glyph.origin.1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (idx, glyph) in glyphs.into_iter().enumerate() {
|
|
||||||
glyph.draw(buf, (x_off, -off), bg, c);
|
|
||||||
x_off += distances[idx] as i32;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((x_off as u32, self.size as u32))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_text_individual_colors(
|
|
||||||
&self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
bg: &Color,
|
|
||||||
color: &[Color],
|
|
||||||
s: &str,
|
|
||||||
) -> Result<(u32, u32), ::std::io::Error> {
|
|
||||||
let mut x_off = 0;
|
|
||||||
let mut off = 0;
|
|
||||||
let mut glyphs = Vec::with_capacity(s.len());
|
|
||||||
for ch in s.chars() {
|
|
||||||
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),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
glyphs.push(glyph);
|
|
||||||
if glyph.origin.1 < off {
|
|
||||||
off = glyph.origin.1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (idx, glyph) in glyphs.into_iter().enumerate() {
|
|
||||||
glyph.draw(buf, (x_off, -off), bg, &color[idx]);
|
|
||||||
x_off += glyph.dimensions.0 as i32 + glyph.origin.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok((x_off as u32, self.size as u32))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn auto_draw_text_individual_colors(
|
|
||||||
&mut self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
bg: &Color,
|
|
||||||
color: &[Color],
|
|
||||||
s: &str,
|
|
||||||
) -> Result<(u32, u32), ::std::io::Error> {
|
|
||||||
self.add_str_to_cache(s);
|
|
||||||
self.draw_text_individual_colors(buf, bg, color, s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_box(buf: &mut Buffer, c: &Color, dim: (u32, u32)) -> Result<(), ::std::io::Error> {
|
|
||||||
for x in 0..dim.0 {
|
|
||||||
let _ = buf.put((x, 0), c);
|
|
||||||
let _ = buf.put((x, dim.1 - 1), c);
|
|
||||||
}
|
|
||||||
for y in 0..dim.1 {
|
|
||||||
buf.put((0, y), c)?;
|
|
||||||
buf.put((dim.0 - 1, y), c)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_bar(
|
|
||||||
buf: &mut Buffer,
|
|
||||||
color: &Color,
|
|
||||||
length: u32,
|
|
||||||
height: u32,
|
|
||||||
fill: f32,
|
|
||||||
) -> Result<(), ::std::io::Error> {
|
|
||||||
let mut fill_pos = ((length as f32) * fill) as u32;
|
|
||||||
if fill_pos > length {
|
|
||||||
fill_pos = length;
|
|
||||||
}
|
|
||||||
for y in 0..height {
|
|
||||||
for x in 0..fill_pos {
|
|
||||||
let _ = buf.put((x, y), color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
-361
@@ -1,361 +0,0 @@
|
|||||||
use std::env;
|
|
||||||
use std::fs::File;
|
|
||||||
use std::io::{BufRead, BufReader, Read, Write};
|
|
||||||
use std::os::unix::io::AsRawFd;
|
|
||||||
use std::os::unix::net::{UnixListener, UnixStream};
|
|
||||||
use std::sync::mpsc::channel;
|
|
||||||
|
|
||||||
use chrono::{Duration, Local};
|
|
||||||
use nix::poll::{poll, PollFd, PollFlags};
|
|
||||||
use os_pipe::pipe;
|
|
||||||
use timerfd::{SetTimeFlags, TimerFd, TimerState};
|
|
||||||
|
|
||||||
mod app;
|
|
||||||
mod buffer;
|
|
||||||
mod cmd;
|
|
||||||
mod color;
|
|
||||||
mod config;
|
|
||||||
mod configfmt;
|
|
||||||
mod desktop;
|
|
||||||
mod doublemempool;
|
|
||||||
mod draw;
|
|
||||||
mod widget;
|
|
||||||
mod widgets;
|
|
||||||
|
|
||||||
use app::{App, OutputMode};
|
|
||||||
use cmd::Cmd;
|
|
||||||
use config::Config;
|
|
||||||
use configfmt::ConfigFmt;
|
|
||||||
use widget::WaitContext;
|
|
||||||
|
|
||||||
enum Mode {
|
|
||||||
Start,
|
|
||||||
Daemonize,
|
|
||||||
StartOrKill,
|
|
||||||
ToggleVisible,
|
|
||||||
PrintConfig(ConfigFmt),
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let socket_path = match env::var("XDG_RUNTIME_DIR") {
|
|
||||||
Ok(dir) => dir + "/wldash",
|
|
||||||
Err(_) => "/tmp/wldash".to_string(),
|
|
||||||
};
|
|
||||||
let config_home = match env::var("XDG_CONFIG_HOME") {
|
|
||||||
Ok(dir) => dir + "/wldash",
|
|
||||||
Err(_) => match env::var("HOME") {
|
|
||||||
Ok(home) => home + "/.config/wldash",
|
|
||||||
Err(_) => panic!("unable to find user folder"),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// From all existing files take the first readable one and write it's extension to `ext`
|
|
||||||
let mut ext = [0x0; 8];
|
|
||||||
let file = configfmt::CONFIG_NAMES
|
|
||||||
.iter()
|
|
||||||
.map(|name| std::path::Path::new(&config_home).join(name))
|
|
||||||
.filter_map(|path| {
|
|
||||||
match File::open(&path) {
|
|
||||||
Ok(file) => {
|
|
||||||
let e = path.extension().and_then(|e| e.to_str())?;
|
|
||||||
let len = e.len();
|
|
||||||
let from = len.saturating_sub(8); // the longest possible extension
|
|
||||||
ext[0..len - from].copy_from_slice(&e.as_bytes()[from..]);
|
|
||||||
Some(file)
|
|
||||||
}
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.next();
|
|
||||||
|
|
||||||
let fmt = std::str::from_utf8(&ext)
|
|
||||||
.ok()
|
|
||||||
.and_then(ConfigFmt::new)
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let config: Config = file
|
|
||||||
.map(|f| fmt.from_reader(BufReader::new(f)))
|
|
||||||
.unwrap_or_default();
|
|
||||||
|
|
||||||
let scale = config.scale;
|
|
||||||
|
|
||||||
let mut args = env::args();
|
|
||||||
let _ = args.next();
|
|
||||||
let mode = match args.next() {
|
|
||||||
Some(arg) => match arg.as_str() {
|
|
||||||
"start" => Mode::Daemonize,
|
|
||||||
"start-or-kill" => Mode::StartOrKill,
|
|
||||||
"toggle-visible" => Mode::ToggleVisible,
|
|
||||||
"print-config" => Mode::PrintConfig(fmt),
|
|
||||||
s => {
|
|
||||||
let p = "print-config-";
|
|
||||||
let l = p.len();
|
|
||||||
let fmt = if s.starts_with(p) {
|
|
||||||
ConfigFmt::new(&s[l..])
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
};
|
|
||||||
if let Some(fmt) = fmt {
|
|
||||||
Mode::PrintConfig(fmt)
|
|
||||||
} else {
|
|
||||||
eprintln!("unsupported sub-command {}", s);
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => Mode::Start,
|
|
||||||
};
|
|
||||||
if let Some(_) = args.next() {
|
|
||||||
// total = args.count + 2 (the two we skipped + the rest)
|
|
||||||
eprintln!("expected 0 or 1 arguments, got {}", args.count() + 2);
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut daemon = false;
|
|
||||||
|
|
||||||
match mode {
|
|
||||||
Mode::ToggleVisible => {
|
|
||||||
if let Ok(mut socket) = UnixStream::connect(socket_path.clone()) {
|
|
||||||
socket.write_all(b"toggle_visible\n").unwrap();
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
eprintln!("wldash is not running");
|
|
||||||
std::process::exit(1);
|
|
||||||
}
|
|
||||||
Mode::StartOrKill => {
|
|
||||||
if let Ok(mut socket) = UnixStream::connect(socket_path.clone()) {
|
|
||||||
socket.write_all(b"kill\n").unwrap();
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Mode::Start => {
|
|
||||||
if let Ok(_) = UnixStream::connect(socket_path.clone()) {
|
|
||||||
eprintln!("wldash is already running");
|
|
||||||
std::process::exit(1);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Mode::Daemonize => {
|
|
||||||
if let Ok(_) = UnixStream::connect(socket_path.clone()) {
|
|
||||||
eprintln!("wldash is already running");
|
|
||||||
std::process::exit(1);
|
|
||||||
};
|
|
||||||
daemon = true;
|
|
||||||
}
|
|
||||||
Mode::PrintConfig(fmt) => {
|
|
||||||
println!("{}", fmt.to_string(&config));
|
|
||||||
std::process::exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = std::fs::remove_file(socket_path.clone());
|
|
||||||
let listener = UnixListener::bind(socket_path.clone()).unwrap();
|
|
||||||
|
|
||||||
let output_mode = match config.output_mode {
|
|
||||||
config::OutputMode::All => OutputMode::All,
|
|
||||||
config::OutputMode::Active => OutputMode::Active,
|
|
||||||
};
|
|
||||||
|
|
||||||
let background = config.background;
|
|
||||||
|
|
||||||
let (tx_draw, rx_draw) = channel();
|
|
||||||
let tx_draw_mod = tx_draw.clone();
|
|
||||||
let (mod_tx, mod_rx) = channel();
|
|
||||||
std::thread::spawn(move || {
|
|
||||||
// Print, write to a file, or send to an HTTP server.
|
|
||||||
match config.widget.construct(tx_draw_mod) {
|
|
||||||
Some(w) => mod_tx.send(w).unwrap(),
|
|
||||||
None => panic!("no widget configured"),
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut app = App::new(tx_draw, output_mode, background, scale);
|
|
||||||
if daemon {
|
|
||||||
app.hide();
|
|
||||||
} else {
|
|
||||||
app.show();
|
|
||||||
}
|
|
||||||
let widget = mod_rx.recv().unwrap();
|
|
||||||
app.set_widget(widget).unwrap();
|
|
||||||
|
|
||||||
let (mut rx_pipe, mut tx_pipe) = pipe().unwrap();
|
|
||||||
let ipc_pipe = tx_pipe.try_clone().unwrap();
|
|
||||||
|
|
||||||
let worker_queue = app.cmd_queue();
|
|
||||||
let _ = std::thread::Builder::new()
|
|
||||||
.name("cmd_proxy".to_string())
|
|
||||||
.spawn(move || loop {
|
|
||||||
let cmd = rx_draw.recv().unwrap();
|
|
||||||
worker_queue.lock().unwrap().push_back(cmd);
|
|
||||||
tx_pipe.write_all(&[0x1]).unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
let mut timer = TimerFd::new().unwrap();
|
|
||||||
let ev_fd = PollFd::new(app.event_queue().get_connection_fd(), PollFlags::POLLIN);
|
|
||||||
let rx_fd = PollFd::new(rx_pipe.as_raw_fd(), PollFlags::POLLIN);
|
|
||||||
let tm_fd = PollFd::new(timer.as_raw_fd(), PollFlags::POLLIN);
|
|
||||||
let ipc_fd = PollFd::new(listener.as_raw_fd(), PollFlags::POLLIN);
|
|
||||||
|
|
||||||
app.cmd_queue().lock().unwrap().push_back(Cmd::Draw);
|
|
||||||
|
|
||||||
let mut visible = !daemon;
|
|
||||||
let mut wait_ctx = WaitContext {
|
|
||||||
fds: Vec::new(),
|
|
||||||
target_time: None,
|
|
||||||
};
|
|
||||||
|
|
||||||
let q = app.cmd_queue();
|
|
||||||
loop {
|
|
||||||
let cmd = q.lock().unwrap().pop_front();
|
|
||||||
match cmd {
|
|
||||||
Some(cmd) => match cmd {
|
|
||||||
Cmd::Draw => {
|
|
||||||
app.redraw(false).expect("Failed to draw");
|
|
||||||
app.flush_display();
|
|
||||||
}
|
|
||||||
Cmd::ForceDraw => {
|
|
||||||
app.redraw(true).expect("Failed to draw");
|
|
||||||
app.flush_display();
|
|
||||||
}
|
|
||||||
Cmd::MouseClick { btn, pos } => {
|
|
||||||
app.get_widget().mouse_click(btn, pos);
|
|
||||||
q.lock().unwrap().push_back(Cmd::Draw);
|
|
||||||
}
|
|
||||||
Cmd::MouseScroll { scroll, pos } => {
|
|
||||||
app.get_widget().mouse_scroll(scroll, pos);
|
|
||||||
q.lock().unwrap().push_back(Cmd::Draw);
|
|
||||||
}
|
|
||||||
Cmd::Keyboard {
|
|
||||||
key,
|
|
||||||
key_state,
|
|
||||||
modifiers_state,
|
|
||||||
interpreted,
|
|
||||||
} => {
|
|
||||||
app.get_widget()
|
|
||||||
.keyboard_input(key, modifiers_state, key_state, interpreted);
|
|
||||||
q.lock().unwrap().push_back(Cmd::Draw);
|
|
||||||
}
|
|
||||||
Cmd::ToggleVisible => {
|
|
||||||
visible = !visible;
|
|
||||||
if visible {
|
|
||||||
app.get_widget().enter();
|
|
||||||
app.show();
|
|
||||||
} else {
|
|
||||||
app.hide();
|
|
||||||
app.get_widget().leave();
|
|
||||||
}
|
|
||||||
app.flush_display();
|
|
||||||
}
|
|
||||||
Cmd::Exit => {
|
|
||||||
if daemon {
|
|
||||||
visible = false;
|
|
||||||
app.hide();
|
|
||||||
app.get_widget().leave();
|
|
||||||
app.flush_display();
|
|
||||||
} else {
|
|
||||||
let _ = std::fs::remove_file(socket_path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
app.flush_display();
|
|
||||||
|
|
||||||
wait_ctx.fds.clear();
|
|
||||||
wait_ctx.fds.push(ev_fd);
|
|
||||||
wait_ctx.fds.push(rx_fd);
|
|
||||||
wait_ctx.fds.push(ipc_fd);
|
|
||||||
wait_ctx.target_time = None;
|
|
||||||
|
|
||||||
app.get_widget().wait(&mut wait_ctx);
|
|
||||||
|
|
||||||
if let Some(target_time) = wait_ctx.target_time {
|
|
||||||
let n = Local::now();
|
|
||||||
let sleep = if target_time > n {
|
|
||||||
target_time - n
|
|
||||||
} else {
|
|
||||||
Duration::seconds(0)
|
|
||||||
};
|
|
||||||
timer.set_state(
|
|
||||||
TimerState::Oneshot(sleep.to_std().unwrap()),
|
|
||||||
SetTimeFlags::Default,
|
|
||||||
);
|
|
||||||
wait_ctx.fds.push(tm_fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
poll(&mut wait_ctx.fds, -1).unwrap();
|
|
||||||
|
|
||||||
if wait_ctx.fds[0]
|
|
||||||
.revents()
|
|
||||||
.unwrap()
|
|
||||||
.contains(PollFlags::POLLIN)
|
|
||||||
{
|
|
||||||
if let Some(guard) = app.event_queue().prepare_read() {
|
|
||||||
if let Err(e) = guard.read_events() {
|
|
||||||
if e.kind() != ::std::io::ErrorKind::WouldBlock {
|
|
||||||
eprintln!(
|
|
||||||
"Error while trying to read from the wayland socket: {:?}",
|
|
||||||
e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
app.event_queue()
|
|
||||||
.dispatch_pending()
|
|
||||||
.expect("Failed to dispatch all messages.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait_ctx.fds[1]
|
|
||||||
.revents()
|
|
||||||
.unwrap()
|
|
||||||
.contains(PollFlags::POLLIN)
|
|
||||||
{
|
|
||||||
let mut v = [0x00];
|
|
||||||
rx_pipe.read_exact(&mut v).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait_ctx.fds[2]
|
|
||||||
.revents()
|
|
||||||
.unwrap()
|
|
||||||
.contains(PollFlags::POLLIN)
|
|
||||||
{
|
|
||||||
if let Ok((stream, _)) = listener.accept() {
|
|
||||||
let client_queue = q.clone();
|
|
||||||
let mut client_pipe = ipc_pipe.try_clone().unwrap();
|
|
||||||
let _ = std::thread::Builder::new()
|
|
||||||
.name("ipc_client".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
let r = BufReader::new(stream);
|
|
||||||
for line in r.lines() {
|
|
||||||
match line {
|
|
||||||
Ok(v) => match v.as_str() {
|
|
||||||
"kill" => {
|
|
||||||
client_queue.lock().unwrap().push_back(Cmd::Exit)
|
|
||||||
}
|
|
||||||
"toggle_visible" => client_queue
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.push_back(Cmd::ToggleVisible),
|
|
||||||
v => eprintln!("unknown command: {}", v),
|
|
||||||
},
|
|
||||||
Err(_) => return,
|
|
||||||
}
|
|
||||||
client_pipe.write_all(&[0x1]).unwrap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait_ctx.target_time.is_some()
|
|
||||||
&& wait_ctx.fds[wait_ctx.fds.len() - 1]
|
|
||||||
.revents()
|
|
||||||
.unwrap()
|
|
||||||
.contains(PollFlags::POLLIN)
|
|
||||||
{
|
|
||||||
timer.read();
|
|
||||||
q.lock().unwrap().push_back(Cmd::Draw);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-434
@@ -1,434 +0,0 @@
|
|||||||
use crate::buffer::Buffer;
|
|
||||||
use crate::color::Color;
|
|
||||||
use chrono::{DateTime, Local};
|
|
||||||
use nix::poll::PollFd;
|
|
||||||
pub use smithay_client_toolkit::keyboard::{KeyState, ModifiersState};
|
|
||||||
|
|
||||||
pub struct DrawContext<'a> {
|
|
||||||
pub buf: &'a mut Buffer<'a>,
|
|
||||||
pub bg: &'a Color,
|
|
||||||
pub time: &'a DateTime<Local>,
|
|
||||||
pub force: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct DrawReport {
|
|
||||||
pub width: u32,
|
|
||||||
pub height: u32,
|
|
||||||
pub damage: Vec<(i32, i32, i32, i32)>,
|
|
||||||
pub full_damage: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl DrawReport {
|
|
||||||
pub fn empty(width: u32, height: u32) -> DrawReport {
|
|
||||||
DrawReport {
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
damage: Vec::new(),
|
|
||||||
full_damage: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct WaitContext {
|
|
||||||
pub fds: Vec<PollFd>,
|
|
||||||
pub target_time: Option<DateTime<Local>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WaitContext {
|
|
||||||
pub fn set_time(&mut self, new_time: DateTime<Local>) {
|
|
||||||
if let Some(ot) = self.target_time {
|
|
||||||
if new_time < ot {
|
|
||||||
self.target_time = Some(new_time);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
self.target_time = Some(new_time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Widget {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext);
|
|
||||||
fn enter(&mut self);
|
|
||||||
fn leave(&mut self);
|
|
||||||
fn size(&self) -> (u32, u32);
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error>;
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
keysym: u32,
|
|
||||||
modifier_state: ModifiersState,
|
|
||||||
key_state: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
);
|
|
||||||
fn mouse_click(&mut self, button: u32, pos: (u32, u32));
|
|
||||||
fn mouse_scroll(&mut self, scroll: (f64, f64), pos: (u32, u32));
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct VerticalLayout {
|
|
||||||
pub children: Vec<Box<dyn Widget + Send>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl VerticalLayout {
|
|
||||||
pub fn new(children: Vec<Box<dyn Widget + Send>>) -> Box<VerticalLayout> {
|
|
||||||
Box::new(VerticalLayout { children: children })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for VerticalLayout {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.wait(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.enter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn leave(&mut self) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.leave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
let mut width = 0;
|
|
||||||
let mut height = 0;
|
|
||||||
|
|
||||||
for child in &self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if size.0 > width {
|
|
||||||
width = size.0;
|
|
||||||
}
|
|
||||||
height += size.1;
|
|
||||||
}
|
|
||||||
|
|
||||||
(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let mut offset = pos.1;
|
|
||||||
let mut width = 0;
|
|
||||||
let mut damage = Vec::new();
|
|
||||||
let mut full_damage = false;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let mut report = child.draw(ctx, (pos.0, offset))?;
|
|
||||||
if report.width > width {
|
|
||||||
width = report.width;
|
|
||||||
}
|
|
||||||
offset += report.height;
|
|
||||||
full_damage |= report.full_damage;
|
|
||||||
damage.append(&mut report.damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(DrawReport {
|
|
||||||
width,
|
|
||||||
height: offset - pos.1,
|
|
||||||
damage,
|
|
||||||
full_damage,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
keysym: u32,
|
|
||||||
modifier_state: ModifiersState,
|
|
||||||
key_state: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.keyboard_input(keysym, modifier_state, key_state, interpreted.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_click(&mut self, button: u32, pos: (u32, u32)) {
|
|
||||||
let mut height = 0;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if pos.1 >= height && pos.1 < height + size.1 {
|
|
||||||
let pos = (pos.0, pos.1 - height);
|
|
||||||
child.mouse_click(button, pos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
height += size.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_scroll(&mut self, scroll: (f64, f64), pos: (u32, u32)) {
|
|
||||||
let mut height = 0;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if pos.1 >= height && pos.1 < height + size.1 {
|
|
||||||
let pos = (pos.0, pos.1 - height);
|
|
||||||
child.mouse_scroll(scroll, pos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
height += size.1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct HorizontalLayout {
|
|
||||||
pub children: Vec<Box<dyn Widget + Send>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl HorizontalLayout {
|
|
||||||
pub fn new(children: Vec<Box<dyn Widget + Send>>) -> Box<HorizontalLayout> {
|
|
||||||
Box::new(HorizontalLayout { children: children })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for HorizontalLayout {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.wait(ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.enter();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn leave(&mut self) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.leave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
let mut width = 0;
|
|
||||||
let mut height = 0;
|
|
||||||
|
|
||||||
for child in &self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if size.1 > height {
|
|
||||||
height = size.1;
|
|
||||||
}
|
|
||||||
width += size.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
(width, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let mut offset = pos.0;
|
|
||||||
let mut height = 0;
|
|
||||||
let mut damage = Vec::new();
|
|
||||||
let mut full_damage = false;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let mut report = child.draw(ctx, (offset, pos.1))?;
|
|
||||||
if report.height > height {
|
|
||||||
height = report.height;
|
|
||||||
}
|
|
||||||
offset += report.width;
|
|
||||||
full_damage |= report.full_damage;
|
|
||||||
damage.append(&mut report.damage);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: offset - pos.0,
|
|
||||||
height,
|
|
||||||
damage,
|
|
||||||
full_damage,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
keysym: u32,
|
|
||||||
modifier_state: ModifiersState,
|
|
||||||
key_state: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
) {
|
|
||||||
for child in &mut self.children {
|
|
||||||
child.keyboard_input(keysym, modifier_state, key_state, interpreted.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_click(&mut self, button: u32, pos: (u32, u32)) {
|
|
||||||
let mut width = 0;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if pos.0 >= width && pos.0 < width + size.0 {
|
|
||||||
let pos = (pos.0 - width, pos.1);
|
|
||||||
child.mouse_click(button, pos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
width += size.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_scroll(&mut self, scroll: (f64, f64), pos: (u32, u32)) {
|
|
||||||
let mut width = 0;
|
|
||||||
|
|
||||||
for child in &mut self.children {
|
|
||||||
let size = child.size();
|
|
||||||
if pos.0 >= width && pos.0 < width + size.0 {
|
|
||||||
let pos = (pos.0 - width, pos.1);
|
|
||||||
child.mouse_scroll(scroll, pos);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
width += size.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Margin {
|
|
||||||
pub child: Box<dyn Widget + Send>,
|
|
||||||
pub margins: (u32, u32, u32, u32), // left, right, top, bottom
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl Margin {
|
|
||||||
pub fn new(margins: (u32, u32, u32, u32), child: Box<dyn Widget + Send>) -> Box<Margin> {
|
|
||||||
Box::new(Margin {
|
|
||||||
child: child,
|
|
||||||
margins: margins,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Margin {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
self.child.wait(ctx)
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {
|
|
||||||
self.child.enter()
|
|
||||||
}
|
|
||||||
fn leave(&mut self) {
|
|
||||||
self.child.leave()
|
|
||||||
}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
let size = self.child.size();
|
|
||||||
(
|
|
||||||
size.0 + self.margins.0 + self.margins.1,
|
|
||||||
size.1 + self.margins.2 + self.margins.3,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let report = self
|
|
||||||
.child
|
|
||||||
.draw(ctx, (pos.0 + self.margins.0, pos.1 + self.margins.2))?;
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: report.width + self.margins.0 + self.margins.1,
|
|
||||||
height: report.height + self.margins.2 + self.margins.3,
|
|
||||||
damage: report.damage,
|
|
||||||
full_damage: report.full_damage,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
keysym: u32,
|
|
||||||
modifier_state: ModifiersState,
|
|
||||||
key_state: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
) {
|
|
||||||
self.child
|
|
||||||
.keyboard_input(keysym, modifier_state, key_state, interpreted);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_click(&mut self, button: u32, pos: (u32, u32)) {
|
|
||||||
let pos = (
|
|
||||||
pos.0.saturating_sub(self.margins.0),
|
|
||||||
pos.1.saturating_sub(self.margins.2),
|
|
||||||
);
|
|
||||||
self.child.mouse_click(button, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_scroll(&mut self, scroll: (f64, f64), pos: (u32, u32)) {
|
|
||||||
let pos = (
|
|
||||||
pos.0.saturating_sub(self.margins.0),
|
|
||||||
pos.1.saturating_sub(self.margins.2),
|
|
||||||
);
|
|
||||||
self.child.mouse_scroll(scroll, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Fixed {
|
|
||||||
pub child: Box<dyn Widget + Send>,
|
|
||||||
pub size: (u32, u32),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
impl Fixed {
|
|
||||||
pub fn new(size: (u32, u32), child: Box<dyn Widget + Send>) -> Box<Fixed> {
|
|
||||||
Box::new(Fixed {
|
|
||||||
child: child,
|
|
||||||
size: size,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Fixed {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
self.child.wait(ctx)
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {
|
|
||||||
self.child.enter()
|
|
||||||
}
|
|
||||||
fn leave(&mut self) {
|
|
||||||
self.child.leave()
|
|
||||||
}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
self.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let report = self.child.draw(ctx, pos)?;
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: self.size.0,
|
|
||||||
height: self.size.1,
|
|
||||||
damage: report.damage,
|
|
||||||
full_damage: report.full_damage,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
keysym: u32,
|
|
||||||
modifier_state: ModifiersState,
|
|
||||||
key_state: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
) {
|
|
||||||
self.child
|
|
||||||
.keyboard_input(keysym, modifier_state, key_state, interpreted);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_click(&mut self, button: u32, pos: (u32, u32)) {
|
|
||||||
self.child.mouse_click(button, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mouse_scroll(&mut self, scroll: (f64, f64), pos: (u32, u32)) {
|
|
||||||
self.child.mouse_scroll(scroll, pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::widget::WaitContext;
|
|
||||||
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
|
|
||||||
|
|
||||||
use alsa::mixer::{Mixer, Selem, SelemChannelId, SelemId};
|
|
||||||
|
|
||||||
const CARD_NAME: &'static str = "default";
|
|
||||||
const SELEM_NAME: &'static str = "Master";
|
|
||||||
const SELEM_ID: u32 = 0u32;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn alsa_error_to_io_error(fail: &'static str, err: &alsa::Error) -> ::std::io::Error {
|
|
||||||
let kind = ::std::io::ErrorKind::Other;
|
|
||||||
let func = err.func();
|
|
||||||
let errno = err
|
|
||||||
.errno()
|
|
||||||
.map(|errno| format!("; errno = {}", errno))
|
|
||||||
.unwrap_or(String::new());
|
|
||||||
return ::std::io::Error::new(kind, format!("{}: {}{}", fail, func, errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn alsa_volume_to_f32(volume: i64, min: i64, max: i64) -> f32 {
|
|
||||||
(volume - min) as f32 / (max - min) as f32
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn f32_to_alsa_volume(volume: f32, min: i64, max: i64) -> i64 {
|
|
||||||
min + ((max - min) as f32 * volume) as i64
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Alsa {
|
|
||||||
pub mixer: Mixer,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Alsa {
|
|
||||||
pub fn new(font_size: f32, length: u32) -> ::std::io::Result<Box<BarWidget>> {
|
|
||||||
let mixer = Mixer::new(CARD_NAME, true)
|
|
||||||
.map_err(|err| alsa_error_to_io_error("Failed to create ALSA mixer", &err))?;
|
|
||||||
let mixer = Self { mixer };
|
|
||||||
mixer.get_master_volume()?; // probing
|
|
||||||
Ok(BarWidget::new_simple(font_size, length, Box::new(mixer)))
|
|
||||||
}
|
|
||||||
#[inline]
|
|
||||||
pub fn get_master<'a>(&'a self) -> ::std::io::Result<Selem<'a>> {
|
|
||||||
let master_id = SelemId::new(SELEM_NAME, SELEM_ID);
|
|
||||||
match self.mixer.find_selem(&master_id) {
|
|
||||||
Some(master) => Ok(master),
|
|
||||||
None => {
|
|
||||||
let kind = ::std::io::ErrorKind::NotFound;
|
|
||||||
let desc = "`Master` not found";
|
|
||||||
Err(::std::io::Error::new(kind, desc))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn get_master_volume(&self) -> ::std::io::Result<f32> {
|
|
||||||
let master = self.get_master()?;
|
|
||||||
let (min, max) = master.get_playback_volume_range();
|
|
||||||
master
|
|
||||||
.get_playback_volume(SelemChannelId::mono())
|
|
||||||
.map(|volume| alsa_volume_to_f32(volume, min, max))
|
|
||||||
.map_err(|e| alsa_error_to_io_error("Failed to get `Master` volume", &e))
|
|
||||||
}
|
|
||||||
pub fn set_master_volume(&self, volume: f32) -> ::std::io::Result<()> {
|
|
||||||
let master = self.get_master()?;
|
|
||||||
let (min, max) = master.get_playback_volume_range();
|
|
||||||
let volume = f32_to_alsa_volume(volume, min, max);
|
|
||||||
master
|
|
||||||
.set_playback_volume_all(volume)
|
|
||||||
.map_err(|e| alsa_error_to_io_error("Failed to set `Master` volume", &e))
|
|
||||||
}
|
|
||||||
pub fn inc_master_volume(&self, diff: f32) -> ::std::io::Result<()> {
|
|
||||||
let master = self.get_master()?;
|
|
||||||
let (min, max) = master.get_playback_volume_range();
|
|
||||||
master
|
|
||||||
.get_playback_volume(SelemChannelId::mono())
|
|
||||||
.and_then(|volume| {
|
|
||||||
let volume = alsa_volume_to_f32(volume, min, max);
|
|
||||||
let volume = f32_to_alsa_volume(volume + diff, min, max);
|
|
||||||
master.set_playback_volume_all(volume)
|
|
||||||
})
|
|
||||||
.map_err(|e| alsa_error_to_io_error("Failed to inc/dec `Master` volume", &e))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BarWidgetImpl for Alsa {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"volume"
|
|
||||||
}
|
|
||||||
fn value(&self) -> f32 {
|
|
||||||
match self.get_master_volume() {
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(e) => panic!(e),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn color(&self) -> Color {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
}
|
|
||||||
fn inc(&mut self, diff: f32) {
|
|
||||||
if let Err(e) = self.inc_master_volume(diff) {
|
|
||||||
panic!(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn set(&mut self, abs: f32) {
|
|
||||||
if let Err(e) = self.set_master_volume(abs) {
|
|
||||||
panic!(e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn toggle(&mut self) {}
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#[cfg(feature = "alsa-widget")]
|
|
||||||
mod alsa_sound;
|
|
||||||
#[cfg(feature = "alsa-widget")]
|
|
||||||
pub use alsa_sound::Alsa;
|
|
||||||
|
|
||||||
#[cfg(feature = "pulseaudio-widget")]
|
|
||||||
mod pulse_sound;
|
|
||||||
#[cfg(feature = "pulseaudio-widget")]
|
|
||||||
pub use pulse_sound::PulseAudio;
|
|
||||||
@@ -1,530 +0,0 @@
|
|||||||
use crate::cmd::Cmd;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::widget::WaitContext;
|
|
||||||
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::ops::Deref;
|
|
||||||
use std::rc::Rc;
|
|
||||||
use std::sync::mpsc::{channel, Sender};
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
use std::thread;
|
|
||||||
|
|
||||||
use libpulse_binding::callbacks::ListResult;
|
|
||||||
use libpulse_binding::context::{
|
|
||||||
flags, introspect::ServerInfo, introspect::SinkInfo, subscribe::subscription_masks,
|
|
||||||
subscribe::Facility, subscribe::Operation as SubscribeOperation, Context, State as PulseState,
|
|
||||||
};
|
|
||||||
use libpulse_binding::mainloop::standard::IterateResult;
|
|
||||||
use libpulse_binding::mainloop::standard::Mainloop;
|
|
||||||
use libpulse_binding::proplist::{properties, Proplist};
|
|
||||||
use libpulse_binding::volume::{ChannelVolumes, Volume, VOLUME_MAX, VOLUME_NORM};
|
|
||||||
|
|
||||||
struct PulseAudioConnection {
|
|
||||||
mainloop: Rc<RefCell<Mainloop>>,
|
|
||||||
context: Rc<RefCell<Context>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct PulseAudioSinkInfo {
|
|
||||||
volume: ChannelVolumes,
|
|
||||||
mute: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PulseAudioClient {
|
|
||||||
sender: Sender<PulseAudioClientRequest>,
|
|
||||||
default_sink: String,
|
|
||||||
sinks: HashMap<String, PulseAudioSinkInfo>,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PulseAudioClientRequest {
|
|
||||||
GetDefaultDevice(Option<Sender<bool>>),
|
|
||||||
GetSinkInfoByIndex(Option<Sender<bool>>, u32),
|
|
||||||
GetSinkInfoByName(Option<Sender<bool>>, String),
|
|
||||||
SetSinkVolumeByName(Option<Sender<bool>>, String, ChannelVolumes),
|
|
||||||
SetSinkMuteByName(Option<Sender<bool>>, String, bool),
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct PulseAudioSoundDeviceInner {
|
|
||||||
name: Option<String>,
|
|
||||||
volume: Option<ChannelVolumes>,
|
|
||||||
volume_avg: f32,
|
|
||||||
muted: bool,
|
|
||||||
default_sink: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PulseAudioSoundDevice {
|
|
||||||
client: Arc<Mutex<PulseAudioClient>>,
|
|
||||||
inner: Arc<Mutex<PulseAudioSoundDeviceInner>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PulseAudioConnection {
|
|
||||||
fn new() -> Result<Self, ::std::io::Error> {
|
|
||||||
let mut proplist = Proplist::new().unwrap();
|
|
||||||
proplist
|
|
||||||
.set_str(properties::APPLICATION_NAME, "wldash")
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let mainloop = Rc::new(RefCell::new(Mainloop::new().unwrap()));
|
|
||||||
|
|
||||||
let context = Rc::new(RefCell::new(
|
|
||||||
Context::new_with_proplist(mainloop.borrow().deref(), "wldash_context", &proplist)
|
|
||||||
.unwrap(),
|
|
||||||
));
|
|
||||||
|
|
||||||
context
|
|
||||||
.borrow_mut()
|
|
||||||
.connect(None, flags::NOFLAGS, None)
|
|
||||||
.map_err(|_e| {
|
|
||||||
::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to connect to pulseaudio context",
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let mut connection = PulseAudioConnection { mainloop, context };
|
|
||||||
|
|
||||||
// Wait for context to be ready
|
|
||||||
loop {
|
|
||||||
connection.iterate(false)?;
|
|
||||||
match connection.context.borrow().get_state() {
|
|
||||||
PulseState::Ready => {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
PulseState::Failed | PulseState::Terminated => {}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(connection)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn iterate(&mut self, blocking: bool) -> Result<(), ::std::io::Error> {
|
|
||||||
match self.mainloop.borrow_mut().iterate(blocking) {
|
|
||||||
IterateResult::Quit(_) | IterateResult::Err(_) => Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to iterate pulseaudio state",
|
|
||||||
)),
|
|
||||||
IterateResult::Success(_) => Ok(()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PulseAudioClient {
|
|
||||||
fn new<F>(listener: F) -> Result<Arc<Mutex<Self>>, ::std::io::Error>
|
|
||||||
where
|
|
||||||
F: Fn(Arc<Mutex<Self>>) -> (),
|
|
||||||
F: Send + 'static + Clone,
|
|
||||||
{
|
|
||||||
let (tx, rx) = channel();
|
|
||||||
|
|
||||||
let client = Arc::new(Mutex::new(PulseAudioClient {
|
|
||||||
sender: tx,
|
|
||||||
default_sink: "@DEFAULT_SINK@".to_string(),
|
|
||||||
sinks: HashMap::new(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
let loop_client = client.clone();
|
|
||||||
let (tx1, rx1) = channel();
|
|
||||||
let _ = thread::Builder::new()
|
|
||||||
.name("pa_writer".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
let mut conn = match PulseAudioConnection::new() {
|
|
||||||
Ok(v) => {
|
|
||||||
tx1.send(true).unwrap();
|
|
||||||
v
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
tx1.send(false).unwrap();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// make sure mainloop dispatched everything
|
|
||||||
for _ in 0..10 {
|
|
||||||
conn.iterate(false).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
loop {
|
|
||||||
let cl = loop_client.clone();
|
|
||||||
let l = listener.clone();
|
|
||||||
match rx.recv() {
|
|
||||||
Err(_) => return,
|
|
||||||
Ok(req) => {
|
|
||||||
let mut introspector = conn.context.borrow_mut().introspect();
|
|
||||||
|
|
||||||
match req {
|
|
||||||
PulseAudioClientRequest::GetDefaultDevice(s) => {
|
|
||||||
introspector.get_server_info(move |info| {
|
|
||||||
let _res = PulseAudioClient::server_info_callback(
|
|
||||||
cl.clone(),
|
|
||||||
l.clone(),
|
|
||||||
info,
|
|
||||||
);
|
|
||||||
if let Some(s) = &s {
|
|
||||||
let _ = s.send(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
PulseAudioClientRequest::GetSinkInfoByIndex(s, index) => {
|
|
||||||
introspector.get_sink_info_by_index(index, move |res| {
|
|
||||||
PulseAudioClient::sink_info_callback(
|
|
||||||
cl.clone(),
|
|
||||||
l.clone(),
|
|
||||||
res,
|
|
||||||
);
|
|
||||||
if let Some(s) = &s {
|
|
||||||
let _ = s.send(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
PulseAudioClientRequest::GetSinkInfoByName(s, name) => {
|
|
||||||
introspector.get_sink_info_by_name(&name, move |res| {
|
|
||||||
PulseAudioClient::sink_info_callback(
|
|
||||||
cl.clone(),
|
|
||||||
l.clone(),
|
|
||||||
res,
|
|
||||||
);
|
|
||||||
if let Some(s) = &s {
|
|
||||||
let _ = s.send(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
PulseAudioClientRequest::SetSinkVolumeByName(s, name, volumes) => {
|
|
||||||
introspector.set_sink_volume_by_name(&name, &volumes, None);
|
|
||||||
if let Some(s) = &s {
|
|
||||||
let _ = s.send(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PulseAudioClientRequest::SetSinkMuteByName(s, name, mute) => {
|
|
||||||
introspector.set_sink_mute_by_name(&name, mute, None);
|
|
||||||
if let Some(s) = &s {
|
|
||||||
let _ = s.send(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// send request and receive response
|
|
||||||
conn.iterate(true).unwrap();
|
|
||||||
conn.iterate(true).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// subscribe
|
|
||||||
let cl2 = client.clone();
|
|
||||||
let (tx2, rx2) = channel();
|
|
||||||
let _ = thread::Builder::new()
|
|
||||||
.name("pa_reader".to_string())
|
|
||||||
.spawn(move || {
|
|
||||||
let conn = match PulseAudioConnection::new() {
|
|
||||||
Ok(v) => {
|
|
||||||
tx2.send(true).unwrap();
|
|
||||||
v
|
|
||||||
}
|
|
||||||
Err(_) => {
|
|
||||||
tx2.send(false).unwrap();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// subcribe for events
|
|
||||||
conn.context
|
|
||||||
.borrow_mut()
|
|
||||||
.set_subscribe_callback(Some(Box::new(move |facility, operation, index| {
|
|
||||||
cl2.lock()
|
|
||||||
.unwrap()
|
|
||||||
.subscribe_callback(facility, operation, index)
|
|
||||||
})));
|
|
||||||
conn.context.borrow_mut().subscribe(
|
|
||||||
subscription_masks::SERVER | subscription_masks::SINK,
|
|
||||||
|_| {},
|
|
||||||
);
|
|
||||||
|
|
||||||
conn.mainloop.borrow_mut().run().unwrap();
|
|
||||||
});
|
|
||||||
|
|
||||||
let pa_writer_res = rx1.recv().unwrap();
|
|
||||||
let pa_reader_res = rx2.recv().unwrap();
|
|
||||||
|
|
||||||
if !pa_writer_res || !pa_reader_res {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to start pulseaudio thread",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(client)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn send(&self, request: PulseAudioClientRequest) -> Result<(), ::std::io::Error> {
|
|
||||||
let res = self.sender.send(request).map_err(|_e| {
|
|
||||||
::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to send pulseaudio request",
|
|
||||||
)
|
|
||||||
});
|
|
||||||
res
|
|
||||||
}
|
|
||||||
|
|
||||||
fn server_info_callback<F>(s: Arc<Mutex<Self>>, listener: F, server_info: &ServerInfo)
|
|
||||||
where
|
|
||||||
F: Fn(Arc<Mutex<Self>>) -> (),
|
|
||||||
F: Send + 'static,
|
|
||||||
{
|
|
||||||
match server_info.default_sink_name.clone() {
|
|
||||||
None => {}
|
|
||||||
Some(default_sink) => {
|
|
||||||
(*s.lock().unwrap()).default_sink = default_sink.into();
|
|
||||||
listener(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sink_info_callback<F>(s: Arc<Mutex<Self>>, listener: F, result: ListResult<&SinkInfo>)
|
|
||||||
where
|
|
||||||
F: Fn(Arc<Mutex<Self>>) -> (),
|
|
||||||
F: Send + 'static,
|
|
||||||
{
|
|
||||||
match result {
|
|
||||||
ListResult::End | ListResult::Error => {}
|
|
||||||
ListResult::Item(sink_info) => match sink_info.name.clone() {
|
|
||||||
None => {}
|
|
||||||
Some(name) => {
|
|
||||||
let info = PulseAudioSinkInfo {
|
|
||||||
volume: sink_info.volume,
|
|
||||||
mute: sink_info.mute,
|
|
||||||
};
|
|
||||||
s.lock().unwrap().sinks.insert(name.into(), info);
|
|
||||||
listener(s);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn subscribe_callback(
|
|
||||||
&self,
|
|
||||||
facility: Option<Facility>,
|
|
||||||
_operation: Option<SubscribeOperation>,
|
|
||||||
index: u32,
|
|
||||||
) {
|
|
||||||
match facility {
|
|
||||||
None => {}
|
|
||||||
Some(facility) => match facility {
|
|
||||||
Facility::Server => {
|
|
||||||
let _ = self.send(PulseAudioClientRequest::GetDefaultDevice(None));
|
|
||||||
}
|
|
||||||
Facility::Sink => {
|
|
||||||
let _ = self.send(PulseAudioClientRequest::GetSinkInfoByIndex(None, index));
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PulseAudioSoundDevice {
|
|
||||||
fn new<F>(listener: F) -> Result<Self, ::std::io::Error>
|
|
||||||
where
|
|
||||||
F: Fn() -> (),
|
|
||||||
F: Send + 'static + Clone,
|
|
||||||
{
|
|
||||||
let inner = Arc::new(Mutex::new(PulseAudioSoundDeviceInner {
|
|
||||||
name: None,
|
|
||||||
volume: None,
|
|
||||||
volume_avg: 0.0,
|
|
||||||
muted: false,
|
|
||||||
default_sink: "@DEFAULT_SINK@".to_string(),
|
|
||||||
}));
|
|
||||||
|
|
||||||
let cb_inner = inner.clone();
|
|
||||||
let client = PulseAudioClient::new(move |client| {
|
|
||||||
let mut inner = cb_inner.lock().unwrap();
|
|
||||||
inner.default_sink = client.lock().unwrap().default_sink.clone();
|
|
||||||
let name = inner
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| inner.default_sink.clone());
|
|
||||||
let sink_info = match client.lock().unwrap().sinks.get(&name) {
|
|
||||||
None => return,
|
|
||||||
Some(sink_info) => (*sink_info).clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
inner.volume = Some(sink_info.volume);
|
|
||||||
inner.volume_avg = sink_info.volume.avg().0 as f32 / VOLUME_NORM.0 as f32;
|
|
||||||
inner.muted = sink_info.mute;
|
|
||||||
|
|
||||||
listener();
|
|
||||||
})?;
|
|
||||||
|
|
||||||
let cl = client.clone();
|
|
||||||
let (tx, rx) = channel();
|
|
||||||
{
|
|
||||||
let cl = client.lock().unwrap();
|
|
||||||
cl.send(PulseAudioClientRequest::GetDefaultDevice(Some(tx)))?;
|
|
||||||
}
|
|
||||||
rx.recv().unwrap();
|
|
||||||
let name = {
|
|
||||||
let cl = client.lock().unwrap();
|
|
||||||
cl.default_sink.to_string()
|
|
||||||
};
|
|
||||||
(*inner.lock().unwrap()).name = Some(name.clone());
|
|
||||||
let device = PulseAudioSoundDevice {
|
|
||||||
client: cl,
|
|
||||||
inner: inner,
|
|
||||||
};
|
|
||||||
let (tx, rx) = channel();
|
|
||||||
{
|
|
||||||
let cl = client.lock().unwrap();
|
|
||||||
cl.send(PulseAudioClientRequest::GetSinkInfoByName(Some(tx), name))?;
|
|
||||||
}
|
|
||||||
rx.recv().unwrap();
|
|
||||||
|
|
||||||
Ok(device)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn muted(&self) -> bool {
|
|
||||||
let inner = self.inner.lock().unwrap();
|
|
||||||
inner.muted
|
|
||||||
}
|
|
||||||
|
|
||||||
fn volume(&self) -> f32 {
|
|
||||||
let inner = self.inner.lock().unwrap();
|
|
||||||
inner.volume_avg
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inc_volume(&mut self, step: f32) -> Result<(), ::std::io::Error> {
|
|
||||||
let mut inner = self.inner.lock().unwrap();
|
|
||||||
let mut volume = match inner.volume {
|
|
||||||
Some(volume) => volume,
|
|
||||||
None => {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to set volume",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// apply step to volumes
|
|
||||||
let step = (step * VOLUME_NORM.0 as f32).round() as i32;
|
|
||||||
if step > 0 {
|
|
||||||
volume.inc_clamp(Volume(step as u32), VOLUME_MAX);
|
|
||||||
} else {
|
|
||||||
volume.decrease(Volume(-step as u32));
|
|
||||||
}
|
|
||||||
|
|
||||||
let name = inner
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| inner.default_sink.clone());
|
|
||||||
|
|
||||||
// update volumes
|
|
||||||
inner.volume = Some(volume);
|
|
||||||
inner.volume_avg = volume.avg().0 as f32 / VOLUME_NORM.0 as f32;
|
|
||||||
self.client
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.send(PulseAudioClientRequest::SetSinkVolumeByName(
|
|
||||||
None, name, volume,
|
|
||||||
))?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_volume(&mut self, val: f32) -> Result<(), ::std::io::Error> {
|
|
||||||
let mut inner = self.inner.lock().unwrap();
|
|
||||||
let mut volume = match inner.volume {
|
|
||||||
Some(volume) => volume,
|
|
||||||
None => {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to set volume",
|
|
||||||
))
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// apply step to volumes
|
|
||||||
volume.scale(Volume((val * VOLUME_NORM.0 as f32).round() as u32));
|
|
||||||
|
|
||||||
let name = inner
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| inner.default_sink.clone());
|
|
||||||
|
|
||||||
// update volumes
|
|
||||||
inner.volume = Some(volume);
|
|
||||||
inner.volume_avg = volume.avg().0 as f32 / VOLUME_NORM.0 as f32;
|
|
||||||
self.client
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.send(PulseAudioClientRequest::SetSinkVolumeByName(
|
|
||||||
None, name, volume,
|
|
||||||
))?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggle(&mut self) -> Result<(), ::std::io::Error> {
|
|
||||||
let mut inner = self.inner.lock().unwrap();
|
|
||||||
inner.muted = !inner.muted;
|
|
||||||
self.client
|
|
||||||
.lock()
|
|
||||||
.unwrap()
|
|
||||||
.send(PulseAudioClientRequest::SetSinkMuteByName(
|
|
||||||
None,
|
|
||||||
inner
|
|
||||||
.name
|
|
||||||
.clone()
|
|
||||||
.unwrap_or_else(|| inner.default_sink.clone()),
|
|
||||||
inner.muted,
|
|
||||||
))?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct PulseAudio {
|
|
||||||
device: PulseAudioSoundDevice,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PulseAudio {
|
|
||||||
pub fn new(
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
sender: Sender<Cmd>,
|
|
||||||
) -> Result<Box<BarWidget>, ::std::io::Error> {
|
|
||||||
BarWidget::new(font_size, length, move |dirty| {
|
|
||||||
let device = PulseAudioSoundDevice::new(move || {
|
|
||||||
*dirty.lock().unwrap() = true;
|
|
||||||
sender.send(Cmd::Draw).unwrap();
|
|
||||||
})?;
|
|
||||||
Ok(Box::new(PulseAudio { device: device }))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BarWidgetImpl for PulseAudio {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"volume"
|
|
||||||
}
|
|
||||||
fn value(&self) -> f32 {
|
|
||||||
self.device.volume()
|
|
||||||
}
|
|
||||||
fn color(&self) -> Color {
|
|
||||||
let muted = self.device.muted();
|
|
||||||
if muted {
|
|
||||||
Color::new(1.0, 1.0, 0.0, 1.0)
|
|
||||||
} else {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn inc(&mut self, inc: f32) {
|
|
||||||
self.device.inc_volume(inc).unwrap();
|
|
||||||
}
|
|
||||||
fn set(&mut self, val: f32) {
|
|
||||||
self.device.set_volume(val).unwrap();
|
|
||||||
}
|
|
||||||
fn toggle(&mut self) {
|
|
||||||
self.device.toggle().unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,141 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::widget::WaitContext;
|
|
||||||
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
|
|
||||||
|
|
||||||
use std::fs::OpenOptions;
|
|
||||||
use std::io::{Error, ErrorKind};
|
|
||||||
use std::io::{Read, Write};
|
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
|
|
||||||
pub struct Backlight {
|
|
||||||
device_path: PathBuf,
|
|
||||||
cur_brightness: u64,
|
|
||||||
max_brightness: u64,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_file_as_u64(path: &Path) -> Result<u64, Error> {
|
|
||||||
let mut file = OpenOptions::new().read(true).open(path)?;
|
|
||||||
let mut str = String::new();
|
|
||||||
file.read_to_string(&mut str)?;
|
|
||||||
str.pop();
|
|
||||||
str.parse::<u64>()
|
|
||||||
.map_err(|_e| Error::new(ErrorKind::Other, "unable to parse value"))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_file_as_u64(path: &Path, value: u64) -> Result<(), Error> {
|
|
||||||
let mut file = OpenOptions::new().write(true).open(path)?;
|
|
||||||
file.write_fmt(format_args!("{}", value))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Backlight {
|
|
||||||
pub fn update(&mut self) -> Result<(), Error> {
|
|
||||||
self.cur_brightness = read_file_as_u64(self.device_path.join("brightness").as_path())?;
|
|
||||||
self.max_brightness = read_file_as_u64(self.device_path.join("max_brightness").as_path())?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn sync(&mut self) -> Result<(), Error> {
|
|
||||||
write_file_as_u64(
|
|
||||||
self.device_path.join("brightness").as_path(),
|
|
||||||
self.cur_brightness,
|
|
||||||
)?;
|
|
||||||
self.update()?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn brightness(&self) -> f32 {
|
|
||||||
if self.cur_brightness > self.max_brightness {
|
|
||||||
// what.
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
(self.cur_brightness as f32 / self.max_brightness as f32)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set(&mut self, val: f32) -> Result<(), Error> {
|
|
||||||
self.cur_brightness = (self.max_brightness as f32 * val) as u64;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn add(&mut self, diff: f32) -> Result<(), Error> {
|
|
||||||
let inc = (self.max_brightness as f32 * diff) as i64;
|
|
||||||
|
|
||||||
self.cur_brightness = if self.cur_brightness as i64 + inc < 1 {
|
|
||||||
1
|
|
||||||
} else if self.cur_brightness as i64 + inc > self.max_brightness as i64 {
|
|
||||||
self.max_brightness
|
|
||||||
} else {
|
|
||||||
(self.cur_brightness as i64 + inc) as u64
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(font_size: f32, length: u32) -> Result<Box<BarWidget>, Error> {
|
|
||||||
let devices = Path::new("/sys/class/backlight").read_dir()?;
|
|
||||||
|
|
||||||
let first_device = match devices.take(1).next() {
|
|
||||||
Some(v) => match v {
|
|
||||||
Ok(v) => v,
|
|
||||||
Err(_) => return Err(Error::new(ErrorKind::Other, "no backlight device")),
|
|
||||||
},
|
|
||||||
None => return Err(Error::new(ErrorKind::Other, "no backlight device")),
|
|
||||||
};
|
|
||||||
let mut dev = Backlight {
|
|
||||||
device_path: first_device.path(),
|
|
||||||
cur_brightness: 0,
|
|
||||||
max_brightness: 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
dev.update()?;
|
|
||||||
|
|
||||||
Ok(BarWidget::new_simple(font_size, length, Box::new(dev)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BarWidgetImpl for Backlight {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"backlight"
|
|
||||||
}
|
|
||||||
fn value(&self) -> f32 {
|
|
||||||
self.brightness()
|
|
||||||
}
|
|
||||||
fn color(&self) -> Color {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
}
|
|
||||||
fn inc(&mut self, inc: f32) {
|
|
||||||
self.add(inc).unwrap();
|
|
||||||
match self.sync() {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Error while trying to change brightness: {}", err);
|
|
||||||
()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn set(&mut self, val: f32) {
|
|
||||||
self.set(val).unwrap();
|
|
||||||
match self.sync() {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Error while trying to change brightness: {}", err);
|
|
||||||
()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn toggle(&mut self) {
|
|
||||||
self.cur_brightness = if self.cur_brightness == 1 {
|
|
||||||
self.max_brightness
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
};
|
|
||||||
match self.sync() {
|
|
||||||
Ok(val) => val,
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Error while trying to change brightness: {}", err);
|
|
||||||
()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,150 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::draw::{draw_bar, draw_box, Font, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
pub trait BarWidgetImpl {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext);
|
|
||||||
fn name(&self) -> &str;
|
|
||||||
fn value(&self) -> f32;
|
|
||||||
fn color(&self) -> Color;
|
|
||||||
fn inc(&mut self, inc: f32);
|
|
||||||
fn set(&mut self, val: f32);
|
|
||||||
fn toggle(&mut self);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct BarWidget {
|
|
||||||
bar_impl: Box<dyn BarWidgetImpl + Send>,
|
|
||||||
font: Font,
|
|
||||||
font_size: u32,
|
|
||||||
length: u32,
|
|
||||||
dirty: Arc<Mutex<bool>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BarWidget {
|
|
||||||
pub fn new_simple(
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
w: Box<dyn BarWidgetImpl + Send>,
|
|
||||||
) -> Box<BarWidget> {
|
|
||||||
let mut font = Font::new(&ROBOTO_REGULAR, font_size);
|
|
||||||
font.add_str_to_cache(w.name());
|
|
||||||
|
|
||||||
Box::new(BarWidget {
|
|
||||||
bar_impl: w,
|
|
||||||
dirty: Arc::new(Mutex::new(true)),
|
|
||||||
font,
|
|
||||||
font_size: font_size as u32,
|
|
||||||
length,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new<F>(font_size: f32, length: u32, f: F) -> Result<Box<BarWidget>, ::std::io::Error>
|
|
||||||
where
|
|
||||||
F: FnOnce(Arc<Mutex<bool>>) -> Result<Box<dyn BarWidgetImpl + Send>, ::std::io::Error>,
|
|
||||||
F: Send + 'static + Clone,
|
|
||||||
{
|
|
||||||
let dirty = Arc::new(Mutex::new(true));
|
|
||||||
let im = f(dirty.clone())?;
|
|
||||||
|
|
||||||
let mut font = Font::new(&ROBOTO_REGULAR, font_size);
|
|
||||||
font.add_str_to_cache(im.name());
|
|
||||||
|
|
||||||
Ok(Box::new(BarWidget {
|
|
||||||
bar_impl: im,
|
|
||||||
dirty,
|
|
||||||
font,
|
|
||||||
font_size: font_size as u32,
|
|
||||||
length,
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for BarWidget {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
self.bar_impl.wait(ctx);
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
(self.length, self.font_size)
|
|
||||||
}
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
{
|
|
||||||
let mut d = self.dirty.lock().unwrap();
|
|
||||||
if !*d && !ctx.force {
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
*d = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
|
|
||||||
let c = Color::new(1.0, 1.0, 1.0, 1.0);
|
|
||||||
self.font.draw_text(buf, ctx.bg, &c, self.bar_impl.name())?;
|
|
||||||
|
|
||||||
let c = self.bar_impl.color();
|
|
||||||
let bar_off = 5 * self.font_size;
|
|
||||||
let mut val = self.bar_impl.value();
|
|
||||||
draw_bar(
|
|
||||||
&mut buf.offset((bar_off, 0))?,
|
|
||||||
&c,
|
|
||||||
self.length - bar_off,
|
|
||||||
self.font_size,
|
|
||||||
val,
|
|
||||||
)?;
|
|
||||||
let mut iter = 1.0;
|
|
||||||
while val > 1.0 {
|
|
||||||
let c = &Color::new(0.75 / iter, 0.25 / iter, 0.25 / iter, 1.0);
|
|
||||||
val -= 1.0;
|
|
||||||
iter += 1.0;
|
|
||||||
draw_bar(
|
|
||||||
&mut buf.offset((bar_off, 0))?,
|
|
||||||
&c,
|
|
||||||
self.length - bar_off,
|
|
||||||
self.font_size,
|
|
||||||
val,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
draw_box(
|
|
||||||
&mut buf.offset((bar_off, 0))?,
|
|
||||||
&c,
|
|
||||||
(self.length - bar_off, self.font_size),
|
|
||||||
)?;
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![buf.get_signed_bounds()],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(&mut self, _: u32, _: ModifiersState, _: KeyState, _: Option<String>) {}
|
|
||||||
fn mouse_click(&mut self, button: u32, (x, _): (u32, u32)) {
|
|
||||||
*self.dirty.lock().unwrap() = true;
|
|
||||||
match button {
|
|
||||||
272 => {
|
|
||||||
let offset = 5 * self.font_size;
|
|
||||||
if x > offset {
|
|
||||||
self.bar_impl
|
|
||||||
.set(((x - offset) + 1) as f32 / (self.length - offset) as f32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
273 => self.bar_impl.toggle(),
|
|
||||||
x => {
|
|
||||||
dbg!(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn mouse_scroll(&mut self, (_, y): (f64, f64), _: (u32, u32)) {
|
|
||||||
*self.dirty.lock().unwrap() = true;
|
|
||||||
self.bar_impl.inc(y as f32 / -800.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,238 +0,0 @@
|
|||||||
use crate::cmd::Cmd;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::widget::WaitContext;
|
|
||||||
use crate::widgets::bar_widget::{BarWidget, BarWidgetImpl};
|
|
||||||
|
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
use std::sync::{Arc, Mutex};
|
|
||||||
|
|
||||||
use nix::poll::{PollFd, PollFlags};
|
|
||||||
|
|
||||||
use dbus;
|
|
||||||
|
|
||||||
fn get_upower_property(
|
|
||||||
con: &dbus::Connection,
|
|
||||||
device_path: &str,
|
|
||||||
property: &str,
|
|
||||||
) -> Result<dbus::Message, ::std::io::Error> {
|
|
||||||
let msg = dbus::Message::new_method_call(
|
|
||||||
"org.freedesktop.UPower",
|
|
||||||
device_path,
|
|
||||||
"org.freedesktop.DBus.Properties",
|
|
||||||
"Get",
|
|
||||||
)
|
|
||||||
.map_err(|_| {
|
|
||||||
::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not send make dbus method call",
|
|
||||||
)
|
|
||||||
})?
|
|
||||||
.append2(
|
|
||||||
dbus::MessageItem::Str("org.freedesktop.UPower.Device".to_string()),
|
|
||||||
dbus::MessageItem::Str(property.to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
con.send_with_reply_and_block(msg, 1000).map_err(|_| {
|
|
||||||
::std::io::Error::new(::std::io::ErrorKind::Other, "could not send dbus message")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// The widget is created on a different thread than where it will be used, so
|
|
||||||
// we need it to be Send. However, dbus::Connection has a void*, so it's not
|
|
||||||
// auto-derived. So, we make a small wrapper where we make it Send.
|
|
||||||
struct DbusConnection(dbus::Connection);
|
|
||||||
|
|
||||||
impl std::convert::AsRef<dbus::Connection> for DbusConnection {
|
|
||||||
fn as_ref(&self) -> &dbus::Connection {
|
|
||||||
return &self.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl Send for DbusConnection {}
|
|
||||||
|
|
||||||
pub struct UpowerBattery {
|
|
||||||
device_path: String,
|
|
||||||
sender: Sender<Cmd>,
|
|
||||||
dirty: Arc<Mutex<bool>>,
|
|
||||||
state: UpowerBatteryState,
|
|
||||||
capacity: f64,
|
|
||||||
con: DbusConnection,
|
|
||||||
watch: dbus::Watch,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum UpowerBatteryState {
|
|
||||||
Charging,
|
|
||||||
Discharging,
|
|
||||||
Empty,
|
|
||||||
Full,
|
|
||||||
NotCharging,
|
|
||||||
Unknown,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl UpowerBattery {
|
|
||||||
pub fn from_device(
|
|
||||||
dirty: Arc<Mutex<bool>>,
|
|
||||||
sender: Sender<Cmd>,
|
|
||||||
device: &str,
|
|
||||||
) -> Result<Self, ::std::io::Error> {
|
|
||||||
let con = dbus::Connection::get_private(dbus::BusType::System).map_err(|_| {
|
|
||||||
::std::io::Error::new(::std::io::ErrorKind::Other, "unable to open dbus")
|
|
||||||
})?;
|
|
||||||
let device_path = format!("/org/freedesktop/UPower/devices/battery_{}", device);
|
|
||||||
|
|
||||||
let rule = format!(
|
|
||||||
"type='signal',\
|
|
||||||
path='{}',\
|
|
||||||
interface='org.freedesktop.DBus.Properties',\
|
|
||||||
member='PropertiesChanged'",
|
|
||||||
&device_path
|
|
||||||
);
|
|
||||||
con.add_match(&rule).map_err(|_| {
|
|
||||||
::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"unable to add match rule to dbus connection",
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
let upower_type: dbus::arg::Variant<u32> =
|
|
||||||
match get_upower_property(&con, &device_path, "Type")?.get1() {
|
|
||||||
Some(v) => v,
|
|
||||||
None => {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"no such upower device",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// https://upower.freedesktop.org/docs/Device.html#Device:Type
|
|
||||||
if upower_type.0 != 2 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"UPower device is not a battery.",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let capacity: f64 = match get_upower_property(&con, &device_path, "Percentage")?
|
|
||||||
.get1::<dbus::arg::Variant<f64>>()
|
|
||||||
{
|
|
||||||
Some(v) => v.0,
|
|
||||||
None => {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"no such upower device",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let state: UpowerBatteryState = match get_upower_property(&con, &device_path, "State")?
|
|
||||||
.get1::<dbus::arg::Variant<u32>>()
|
|
||||||
{
|
|
||||||
Some(v) => match v.0 {
|
|
||||||
1 => UpowerBatteryState::Charging,
|
|
||||||
2 => UpowerBatteryState::Discharging,
|
|
||||||
3 => UpowerBatteryState::Empty,
|
|
||||||
4 => UpowerBatteryState::Full,
|
|
||||||
5 => UpowerBatteryState::NotCharging,
|
|
||||||
6 => UpowerBatteryState::Discharging,
|
|
||||||
_ => UpowerBatteryState::Unknown,
|
|
||||||
},
|
|
||||||
None => {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"no such upower device",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let fds = con.watch_fds();
|
|
||||||
if fds.len() != 1 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"expected 1 watch fd from dbus",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(UpowerBattery {
|
|
||||||
device_path,
|
|
||||||
con: DbusConnection(con),
|
|
||||||
dirty,
|
|
||||||
sender,
|
|
||||||
capacity: capacity,
|
|
||||||
state: state,
|
|
||||||
watch: fds[0],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
sender: Sender<Cmd>,
|
|
||||||
) -> Result<Box<BarWidget>, ::std::io::Error> {
|
|
||||||
BarWidget::new(font_size, length, move |dirty| {
|
|
||||||
let d = UpowerBattery::from_device(dirty, sender, "BAT0")?;
|
|
||||||
Ok(Box::new(d))
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BarWidgetImpl for UpowerBattery {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
for _ in self
|
|
||||||
.con
|
|
||||||
.as_ref()
|
|
||||||
.watch_handle(self.watch.fd(), dbus::WatchEvent::Readable as u32)
|
|
||||||
{
|
|
||||||
let capacity = get_upower_property(self.con.as_ref(), &self.device_path, "Percentage")
|
|
||||||
.unwrap()
|
|
||||||
.get1::<dbus::arg::Variant<f64>>()
|
|
||||||
.unwrap()
|
|
||||||
.0;
|
|
||||||
let state = match get_upower_property(self.con.as_ref(), &self.device_path, "State")
|
|
||||||
.unwrap()
|
|
||||||
.get1::<dbus::arg::Variant<u32>>()
|
|
||||||
.unwrap()
|
|
||||||
.0
|
|
||||||
{
|
|
||||||
1 => UpowerBatteryState::Charging,
|
|
||||||
2 => UpowerBatteryState::Discharging,
|
|
||||||
3 => UpowerBatteryState::Empty,
|
|
||||||
4 => UpowerBatteryState::Full,
|
|
||||||
5 => UpowerBatteryState::NotCharging,
|
|
||||||
6 => UpowerBatteryState::Discharging,
|
|
||||||
_ => UpowerBatteryState::Unknown,
|
|
||||||
};
|
|
||||||
self.state = state;
|
|
||||||
self.capacity = capacity;
|
|
||||||
*self.dirty.lock().unwrap() = true;
|
|
||||||
self.sender.send(Cmd::Draw).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.fds
|
|
||||||
.push(PollFd::new(self.watch.fd(), PollFlags::POLLIN));
|
|
||||||
}
|
|
||||||
fn name(&self) -> &str {
|
|
||||||
"battery"
|
|
||||||
}
|
|
||||||
fn value(&self) -> f32 {
|
|
||||||
(self.capacity as f32) / 100.0
|
|
||||||
}
|
|
||||||
fn color(&self) -> Color {
|
|
||||||
match self.state {
|
|
||||||
UpowerBatteryState::Discharging | UpowerBatteryState::Unknown => {
|
|
||||||
if self.capacity > 10.0 {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
} else {
|
|
||||||
Color::new(1.0, 0.5, 0.0, 1.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UpowerBatteryState::Charging | UpowerBatteryState::Full => {
|
|
||||||
Color::new(0.5, 1.0, 0.5, 1.0)
|
|
||||||
}
|
|
||||||
UpowerBatteryState::NotCharging | UpowerBatteryState::Empty => {
|
|
||||||
Color::new(1.0, 0.5, 0.5, 1.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn inc(&mut self, _: f32) {}
|
|
||||||
fn set(&mut self, _: f32) {}
|
|
||||||
fn toggle(&mut self) {}
|
|
||||||
}
|
|
||||||
@@ -1,270 +0,0 @@
|
|||||||
use crate::buffer::Buffer;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::draw::{Font, DEJAVUSANS_MONO, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
|
|
||||||
use chrono::{Date, Datelike, Local};
|
|
||||||
|
|
||||||
pub struct Calendar {
|
|
||||||
cur_date: Date<Local>,
|
|
||||||
dirty: bool,
|
|
||||||
offset: f64,
|
|
||||||
sections: u32,
|
|
||||||
font_size: u32,
|
|
||||||
calendar_cache: Font,
|
|
||||||
month_cache: Font,
|
|
||||||
year_cache: Font,
|
|
||||||
day_cache: Font,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Calendar {
|
|
||||||
fn draw_month(
|
|
||||||
&self,
|
|
||||||
buf: &mut Buffer,
|
|
||||||
background_color: &Color,
|
|
||||||
orig: &Date<Local>,
|
|
||||||
time: &Date<Local>,
|
|
||||||
) -> Result<(i32, i32, i32, i32), ::std::io::Error> {
|
|
||||||
let mut time = time.clone();
|
|
||||||
let mut y_off = 1;
|
|
||||||
let mut done = false;
|
|
||||||
|
|
||||||
let month_str = match time.month() {
|
|
||||||
1 => "January",
|
|
||||||
2 => "February",
|
|
||||||
3 => "March",
|
|
||||||
4 => "April",
|
|
||||||
5 => "May",
|
|
||||||
6 => "June",
|
|
||||||
7 => "July",
|
|
||||||
8 => "August",
|
|
||||||
9 => "September",
|
|
||||||
10 => "October",
|
|
||||||
11 => "November",
|
|
||||||
12 => "December",
|
|
||||||
_ => panic!("impossible value"),
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the of the month
|
|
||||||
//
|
|
||||||
|
|
||||||
self.month_cache.draw_text(
|
|
||||||
buf,
|
|
||||||
background_color,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
month_str,
|
|
||||||
)?;
|
|
||||||
if time.year() != orig.year() {
|
|
||||||
self.year_cache.draw_text(
|
|
||||||
&mut buf.offset((self.font_size * 20, 0))?,
|
|
||||||
background_color,
|
|
||||||
&Color::new(0.8, 0.8, 0.8, 1.0),
|
|
||||||
&format!("{:}", time.year()),
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the week day
|
|
||||||
//
|
|
||||||
|
|
||||||
for idx in 1..8 {
|
|
||||||
let wk_chr = match idx {
|
|
||||||
1 => "MON",
|
|
||||||
2 => "TUE",
|
|
||||||
3 => "WED",
|
|
||||||
4 => "THU",
|
|
||||||
5 => "FRI",
|
|
||||||
6 => "SAT",
|
|
||||||
7 => "SUN",
|
|
||||||
_ => panic!("impossible value"),
|
|
||||||
};
|
|
||||||
|
|
||||||
self.day_cache.draw_text(
|
|
||||||
&mut buf.offset((
|
|
||||||
idx * self.font_size * 3 + self.font_size / 5,
|
|
||||||
y_off * self.font_size * 2 + self.font_size * 4,
|
|
||||||
))?,
|
|
||||||
background_color,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
&wk_chr,
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
y_off += 1;
|
|
||||||
|
|
||||||
while !done {
|
|
||||||
let mut x_pos = 0;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Find the start of this week
|
|
||||||
//
|
|
||||||
let mut wkday = time.weekday();
|
|
||||||
while wkday != chrono::Weekday::Mon {
|
|
||||||
x_pos += 1;
|
|
||||||
wkday = wkday.pred();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the week number
|
|
||||||
//
|
|
||||||
let wk = time.iso_week();
|
|
||||||
self.calendar_cache.draw_text(
|
|
||||||
&mut buf.offset((0, y_off * self.font_size * 2 + self.font_size * 4))?,
|
|
||||||
background_color,
|
|
||||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
|
||||||
&format!("{:02}", wk.week()),
|
|
||||||
)?;
|
|
||||||
x_pos += 1;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Draw the dates
|
|
||||||
//
|
|
||||||
while x_pos < 8 {
|
|
||||||
let c = if time.day() == orig.day() && time.month() == orig.month() {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
} else {
|
|
||||||
Color::new(0.5, 0.5, 0.5, 1.0)
|
|
||||||
};
|
|
||||||
|
|
||||||
self.calendar_cache.draw_text(
|
|
||||||
&mut buf.offset((
|
|
||||||
x_pos * self.font_size * 3,
|
|
||||||
y_off * self.font_size * 2 + self.font_size * 4,
|
|
||||||
))?,
|
|
||||||
background_color,
|
|
||||||
&c,
|
|
||||||
&format!("{:02}", time.day()),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
let t = time.with_day(time.day() + 1);
|
|
||||||
if t.is_none() {
|
|
||||||
done = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
time = t.unwrap();
|
|
||||||
x_pos += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
y_off += 1;
|
|
||||||
}
|
|
||||||
Ok(buf.get_signed_bounds())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Calendar {
|
|
||||||
pub fn new(font_size: f32, sections: u32) -> Box<Calendar> {
|
|
||||||
let mut calendar_cache = Font::new(&DEJAVUSANS_MONO, font_size * 2.0);
|
|
||||||
calendar_cache.add_str_to_cache("0123456789");
|
|
||||||
let mut month_cache = Font::new(&ROBOTO_REGULAR, font_size * 4.0);
|
|
||||||
month_cache.add_str_to_cache("JanuryFebMchApilJgstSmOoNvD");
|
|
||||||
let mut year_cache = Font::new(&DEJAVUSANS_MONO, font_size * 1.5);
|
|
||||||
year_cache.add_str_to_cache("-0123456789");
|
|
||||||
let mut day_cache = Font::new(&DEJAVUSANS_MONO, font_size);
|
|
||||||
day_cache.add_str_to_cache("MONTUEWDHFRISA");
|
|
||||||
Box::new(Calendar {
|
|
||||||
cur_date: Local::now().date(),
|
|
||||||
dirty: true,
|
|
||||||
offset: 0.0,
|
|
||||||
sections: sections,
|
|
||||||
font_size: font_size as u32,
|
|
||||||
calendar_cache: calendar_cache,
|
|
||||||
month_cache: month_cache,
|
|
||||||
year_cache: year_cache,
|
|
||||||
day_cache: day_cache,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Calendar {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {}
|
|
||||||
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
let cal_width = 7 * self.font_size * 3 + self.font_size * 2;
|
|
||||||
let cal_pad = self.font_size * 3;
|
|
||||||
(
|
|
||||||
cal_width * self.sections + cal_pad * (self.sections - 1),
|
|
||||||
(self.font_size as f32 * 21.5) as u32,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
if ctx.time.date() == self.cur_date && !ctx.force && !self.dirty {
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
self.dirty = false;
|
|
||||||
self.cur_date = ctx.time.date();
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
let time = ctx.time.date();
|
|
||||||
let mut t = time.with_day(1).unwrap();
|
|
||||||
let o = (self.offset / 100.0) as i32;
|
|
||||||
|
|
||||||
let cals = self.sections - 1;
|
|
||||||
let pre_cals = cals / 2;
|
|
||||||
for _ in 0..pre_cals {
|
|
||||||
t = t.pred().with_day(1).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
if o != 0 {
|
|
||||||
let mut month = (t.month() - 1) as i32 + o;
|
|
||||||
let mut year = t.year();
|
|
||||||
while month > 11 {
|
|
||||||
year += 1;
|
|
||||||
month -= 12;
|
|
||||||
}
|
|
||||||
while month < 0 {
|
|
||||||
year -= 1;
|
|
||||||
month += 12;
|
|
||||||
}
|
|
||||||
t = t
|
|
||||||
.with_year(year)
|
|
||||||
.unwrap()
|
|
||||||
.with_month((month + 1) as u32)
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
let cal_pad = 7 * self.font_size * 3 + self.font_size * 5;
|
|
||||||
for idx in 0..self.sections {
|
|
||||||
self.draw_month(&mut buf.offset((cal_pad * idx, 0))?, ctx.bg, &time, &t)?;
|
|
||||||
|
|
||||||
t = if t.month() == 12 {
|
|
||||||
t.with_year(t.year() + 1).unwrap().with_month(1).unwrap()
|
|
||||||
} else {
|
|
||||||
t.with_month(t.month() + 1).unwrap()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![buf.get_signed_bounds()],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(&mut self, _: u32, _: ModifiersState, _: KeyState, _: Option<String>) {}
|
|
||||||
fn mouse_click(&mut self, _: u32, (x, _): (u32, u32)) {
|
|
||||||
let cal_pad = 7 * self.font_size * 3 + self.font_size * 5;
|
|
||||||
let cals = self.sections - 1;
|
|
||||||
let pre_cals = cals / 2;
|
|
||||||
if x < pre_cals * cal_pad {
|
|
||||||
self.offset -= 100.0;
|
|
||||||
} else if x >= (pre_cals + 1) * cal_pad {
|
|
||||||
self.offset += 100.0;
|
|
||||||
} else {
|
|
||||||
self.offset = 0.0;
|
|
||||||
}
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
fn mouse_scroll(&mut self, (_, y): (f64, f64), _: (u32, u32)) {
|
|
||||||
self.offset += y;
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::draw::{Font, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
|
|
||||||
use chrono::{DateTime, Datelike, Duration, Local, Timelike};
|
|
||||||
|
|
||||||
pub struct Clock {
|
|
||||||
cur_time: DateTime<Local>,
|
|
||||||
clock_cache: Font,
|
|
||||||
size: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Clock {
|
|
||||||
pub fn new(size: f32) -> Box<Clock> {
|
|
||||||
let mut clock_cache = Font::new(&ROBOTO_REGULAR, size);
|
|
||||||
clock_cache.add_str_to_cache("0123456789:");
|
|
||||||
|
|
||||||
let time = Local::now();
|
|
||||||
|
|
||||||
Box::new(Clock {
|
|
||||||
cur_time: time.with_year(time.year().saturating_sub(1)).unwrap(),
|
|
||||||
clock_cache: clock_cache,
|
|
||||||
size: size,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Clock {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
let target = (self.cur_time + Duration::seconds(60))
|
|
||||||
.with_second(0)
|
|
||||||
.unwrap()
|
|
||||||
.with_nanosecond(0)
|
|
||||||
.unwrap();
|
|
||||||
ctx.set_time(target);
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
let digit = (self.size * 0.45).ceil() as u32;
|
|
||||||
let colon = (self.size * 0.20).ceil() as u32;
|
|
||||||
(digit * 4 + colon, self.size.ceil() as u32)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
if !(ctx.time.date() != self.cur_time.date()
|
|
||||||
|| ctx.time.hour() != self.cur_time.hour()
|
|
||||||
|| ctx.time.minute() != self.cur_time.minute()
|
|
||||||
|| ctx.force)
|
|
||||||
{
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.cur_time = ctx.time.clone();
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
|
|
||||||
let digit = (self.size * 0.45).ceil() as u32;
|
|
||||||
let colon = (self.size * 0.20).ceil() as u32;
|
|
||||||
self.clock_cache.draw_text_fixed_width(
|
|
||||||
buf,
|
|
||||||
ctx.bg,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
&[digit, digit, colon, digit, digit],
|
|
||||||
&format!("{:02}:{:02}", ctx.time.hour(), ctx.time.minute()),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![(pos.0 as i32, pos.1 as i32, width as i32, height as i32)],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(&mut self, _: u32, _: ModifiersState, _: KeyState, _: Option<String>) {}
|
|
||||||
fn mouse_click(&mut self, _: u32, _: (u32, u32)) {}
|
|
||||||
fn mouse_scroll(&mut self, _: (f64, f64), _: (u32, u32)) {}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::draw::{Font, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
|
|
||||||
use chrono::{DateTime, Datelike, Local};
|
|
||||||
|
|
||||||
pub struct Date {
|
|
||||||
cur_time: DateTime<Local>,
|
|
||||||
date_cache: Font,
|
|
||||||
size: f32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Date {
|
|
||||||
pub fn new(size: f32) -> Box<Date> {
|
|
||||||
let mut date_cache = Font::new(&ROBOTO_REGULAR, size);
|
|
||||||
date_cache
|
|
||||||
.add_str_to_cache("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,/ ");
|
|
||||||
|
|
||||||
let time = Local::now();
|
|
||||||
|
|
||||||
Box::new(Date {
|
|
||||||
cur_time: time.with_year(time.year().saturating_sub(1)).unwrap(),
|
|
||||||
date_cache: date_cache,
|
|
||||||
size: size,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Date {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
((6.5 * self.size).ceil() as u32, self.size.ceil() as u32)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
|
|
||||||
if !(ctx.time.date() != self.cur_time.date() || ctx.force) {
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
|
|
||||||
self.cur_time = ctx.time.clone();
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
self.date_cache.draw_text(
|
|
||||||
buf,
|
|
||||||
ctx.bg,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
&format!(
|
|
||||||
"{:?}, {:02}/{:02}/{:4}",
|
|
||||||
ctx.time.weekday(),
|
|
||||||
ctx.time.day(),
|
|
||||||
ctx.time.month(),
|
|
||||||
ctx.time.year()
|
|
||||||
),
|
|
||||||
)?;
|
|
||||||
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![(pos.0 as i32, pos.1 as i32, width as i32, height as i32)],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(&mut self, _: u32, _: ModifiersState, _: KeyState, _: Option<String>) {}
|
|
||||||
fn mouse_click(&mut self, _: u32, _: (u32, u32)) {}
|
|
||||||
fn mouse_scroll(&mut self, _: (f64, f64), _: (u32, u32)) {}
|
|
||||||
}
|
|
||||||
@@ -1,379 +0,0 @@
|
|||||||
use crate::buffer::Buffer;
|
|
||||||
use crate::cmd::Cmd;
|
|
||||||
use crate::color::Color;
|
|
||||||
use crate::desktop::{load_desktop_files, Desktop};
|
|
||||||
use crate::draw::{Font, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::cmp::Ordering;
|
|
||||||
use std::process::Command;
|
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
|
|
||||||
use fuzzy_matcher::skim::{fuzzy_indices, fuzzy_match};
|
|
||||||
use smithay_client_toolkit::keyboard::keysyms;
|
|
||||||
|
|
||||||
pub struct Launcher {
|
|
||||||
options: Vec<Desktop>,
|
|
||||||
term_opener: String,
|
|
||||||
app_opener: String,
|
|
||||||
url_opener: String,
|
|
||||||
matches: Vec<Desktop>,
|
|
||||||
input: String,
|
|
||||||
result: Option<String>,
|
|
||||||
offset: usize,
|
|
||||||
font: RefCell<Font>,
|
|
||||||
font_size: u32,
|
|
||||||
length: u32,
|
|
||||||
dirty: bool,
|
|
||||||
tx: Sender<Cmd>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Launcher {
|
|
||||||
pub fn new(
|
|
||||||
font_size: f32,
|
|
||||||
length: u32,
|
|
||||||
listener: Sender<Cmd>,
|
|
||||||
app: String,
|
|
||||||
term: String,
|
|
||||||
url: String,
|
|
||||||
) -> Box<Launcher> {
|
|
||||||
Box::new(Launcher {
|
|
||||||
options: load_desktop_files(),
|
|
||||||
term_opener: term,
|
|
||||||
app_opener: app,
|
|
||||||
url_opener: url,
|
|
||||||
matches: vec![],
|
|
||||||
input: "".to_string(),
|
|
||||||
result: None,
|
|
||||||
offset: 0,
|
|
||||||
font: RefCell::new(Font::new(&ROBOTO_REGULAR, font_size)),
|
|
||||||
font_size: font_size as u32,
|
|
||||||
length: length,
|
|
||||||
dirty: true,
|
|
||||||
tx: listener,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_launcher(&self, buf: &mut Buffer, bg: &Color) -> Result<(), ::std::io::Error> {
|
|
||||||
let mut x_off = if self.input.len() > 0 {
|
|
||||||
let c = if self.matches.len() == 0 {
|
|
||||||
Color::new(1.0, 0.5, 0.5, 1.0)
|
|
||||||
} else {
|
|
||||||
Color::new(1.0, 1.0, 1.0, 1.0)
|
|
||||||
};
|
|
||||||
let dim = self
|
|
||||||
.font
|
|
||||||
.borrow_mut()
|
|
||||||
.auto_draw_text(buf, bg, &c, &self.input)?;
|
|
||||||
|
|
||||||
dim.0 + self.font_size / 4
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
let mut width_remaining: i32 = (self.length - x_off) as i32;
|
|
||||||
for (idx, m) in self.matches.iter().enumerate() {
|
|
||||||
let mut b = match buf.offset((x_off, 0)) {
|
|
||||||
Ok(b) => b,
|
|
||||||
Err(_) => break,
|
|
||||||
};
|
|
||||||
let size = if idx == self.offset && self.input.len() > 0 {
|
|
||||||
let (_, indices) =
|
|
||||||
fuzzy_indices(&m.name.to_lowercase(), &self.input.to_lowercase()).unwrap();
|
|
||||||
let mut colors = Vec::with_capacity(m.name.len());
|
|
||||||
for pos in 0..m.name.len() {
|
|
||||||
if indices.contains(&pos) {
|
|
||||||
colors.push(Color::new(1.0, 1.0, 1.0, 1.0));
|
|
||||||
} else {
|
|
||||||
colors.push(Color::new(0.75, 0.75, 0.75, 1.0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.font
|
|
||||||
.borrow_mut()
|
|
||||||
.auto_draw_text_individual_colors(&mut b, bg, &colors, &m.name)?
|
|
||||||
} else {
|
|
||||||
self.font.borrow_mut().auto_draw_text(
|
|
||||||
&mut b,
|
|
||||||
bg,
|
|
||||||
&Color::new(0.5, 0.5, 0.5, 1.0),
|
|
||||||
&m.name,
|
|
||||||
)?
|
|
||||||
};
|
|
||||||
|
|
||||||
x_off += size.0 + self.font_size / 2;
|
|
||||||
width_remaining -= (size.0 + self.font_size / 2) as i32;
|
|
||||||
|
|
||||||
if width_remaining < 0 {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_calc(&self, buf: &mut Buffer, bg: &Color) -> Result<(), ::std::io::Error> {
|
|
||||||
let x_off = self
|
|
||||||
.font
|
|
||||||
.borrow_mut()
|
|
||||||
.auto_draw_text(buf, bg, &Color::new(1.0, 1.0, 0.0, 1.0), "=")?
|
|
||||||
.0
|
|
||||||
+ self.font_size / 4;
|
|
||||||
|
|
||||||
let x_off = if self.input.len() > 0 {
|
|
||||||
let dim = self.font.borrow_mut().auto_draw_text(
|
|
||||||
&mut buf.offset((x_off, 0))?,
|
|
||||||
bg,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
&self.input[1..],
|
|
||||||
)?;
|
|
||||||
|
|
||||||
x_off + dim.0 + self.font_size / 4
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(result) = &self.result {
|
|
||||||
self.font.borrow_mut().auto_draw_text(
|
|
||||||
&mut buf.offset((x_off, 0))?,
|
|
||||||
bg,
|
|
||||||
&Color::new(0.75, 0.75, 0.75, 1.0),
|
|
||||||
&format!(" = {:}", result),
|
|
||||||
)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_shell(&self, buf: &mut Buffer, bg: &Color) -> Result<(), ::std::io::Error> {
|
|
||||||
let x_off = self
|
|
||||||
.font
|
|
||||||
.borrow_mut()
|
|
||||||
.auto_draw_text(
|
|
||||||
&mut buf.offset((0, 0))?,
|
|
||||||
bg,
|
|
||||||
&Color::new(1.0, 1.0, 0.0, 1.0),
|
|
||||||
"!",
|
|
||||||
)?
|
|
||||||
.0
|
|
||||||
+ self.font_size / 4;
|
|
||||||
|
|
||||||
if self.input.len() > 0 {
|
|
||||||
self.font.borrow_mut().auto_draw_text(
|
|
||||||
&mut buf.offset((x_off, 0))?,
|
|
||||||
bg,
|
|
||||||
&Color::new(1.0, 1.0, 1.0, 1.0),
|
|
||||||
&self.input[1..],
|
|
||||||
)?;
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn calc(s: &str) -> Result<String, String> {
|
|
||||||
rcalc_lib::parse::eval(s, &mut rcalc_lib::parse::CalcState::new())
|
|
||||||
.map(|x| format!("{}", x).to_string())
|
|
||||||
.map_err(|x| format!("{}", x).to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wlcopy(s: &str) -> Result<(), String> {
|
|
||||||
let mut child = std::process::Command::new("wl-copy")
|
|
||||||
.stdin(std::process::Stdio::null())
|
|
||||||
.stdout(std::process::Stdio::null())
|
|
||||||
.stderr(std::process::Stdio::null())
|
|
||||||
.arg(s)
|
|
||||||
.spawn()
|
|
||||||
.map_err(|_| "wl-copy not available".to_string())?;
|
|
||||||
child
|
|
||||||
.wait()
|
|
||||||
.map_err(|_| "unable to run wl-copy".to_string())?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for Launcher {
|
|
||||||
fn wait(&mut self, _: &mut WaitContext) {}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {
|
|
||||||
self.input = "".to_string();
|
|
||||||
self.offset = 0;
|
|
||||||
self.result = None;
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
(self.length, self.font_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
if !self.dirty && !ctx.force {
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
self.dirty = false;
|
|
||||||
|
|
||||||
match self.input.chars().next() {
|
|
||||||
Some('=') => {
|
|
||||||
if self.input.len() > 1 {
|
|
||||||
match calc(&self.input.chars().skip(1).collect::<String>()) {
|
|
||||||
Ok(v) => self.result = Some(v),
|
|
||||||
Err(_) => self.result = None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some('!') => (),
|
|
||||||
_ => {
|
|
||||||
let mut m = self
|
|
||||||
.options
|
|
||||||
.iter()
|
|
||||||
.map(|x| {
|
|
||||||
(
|
|
||||||
fuzzy_match(&x.name.to_lowercase(), &self.input.to_lowercase()),
|
|
||||||
x,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.filter(|(x, _)| x.is_some())
|
|
||||||
.map(|(x, y)| (x.unwrap(), y.clone()))
|
|
||||||
.collect::<Vec<(i64, Desktop)>>();
|
|
||||||
|
|
||||||
m.sort_by(|(x1, y1), (x2, y2)| {
|
|
||||||
if x1 > x2 {
|
|
||||||
Ordering::Less
|
|
||||||
} else if x1 < x2 {
|
|
||||||
Ordering::Greater
|
|
||||||
} else if y1.name.len() < y2.name.len() {
|
|
||||||
Ordering::Less
|
|
||||||
} else if y1.name.len() > y2.name.len() {
|
|
||||||
Ordering::Greater
|
|
||||||
} else {
|
|
||||||
y1.cmp(y2)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
self.matches = m.into_iter().map(|(_, x)| x).collect();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
|
|
||||||
match self.input.chars().next() {
|
|
||||||
Some('=') => self.draw_calc(buf, ctx.bg),
|
|
||||||
Some('!') => self.draw_shell(buf, ctx.bg),
|
|
||||||
_ => self.draw_launcher(buf, ctx.bg),
|
|
||||||
}?;
|
|
||||||
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![buf.get_signed_bounds()],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(
|
|
||||||
&mut self,
|
|
||||||
key: u32,
|
|
||||||
modifiers: ModifiersState,
|
|
||||||
_: KeyState,
|
|
||||||
interpreted: Option<String>,
|
|
||||||
) {
|
|
||||||
match key {
|
|
||||||
keysyms::XKB_KEY_u if modifiers.ctrl => self.leave(),
|
|
||||||
keysyms::XKB_KEY_BackSpace => {
|
|
||||||
if self.input.len() > 0 {
|
|
||||||
self.input = self.input[..self.input.len() - 1].to_string();
|
|
||||||
self.offset = 0;
|
|
||||||
self.result = None;
|
|
||||||
self.dirty = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
keysyms::XKB_KEY_Return => {
|
|
||||||
match self.input.chars().next() {
|
|
||||||
Some('=') => match self.result {
|
|
||||||
Some(ref v) => {
|
|
||||||
let _ = wlcopy(&v);
|
|
||||||
}
|
|
||||||
None => (),
|
|
||||||
},
|
|
||||||
Some('!') => {
|
|
||||||
let _ = Command::new("sh")
|
|
||||||
.arg("-c")
|
|
||||||
.arg(self.input.chars().skip(1).collect::<String>())
|
|
||||||
.spawn();
|
|
||||||
self.tx.send(Cmd::Exit).unwrap();
|
|
||||||
}
|
|
||||||
_ => {
|
|
||||||
if self.matches.len() > self.offset {
|
|
||||||
let d = &self.matches[self.offset];
|
|
||||||
if let Some(exec) = &d.exec {
|
|
||||||
let exec = exec
|
|
||||||
.replace("%f", "")
|
|
||||||
.replace("%F", "")
|
|
||||||
.replace("%u", "")
|
|
||||||
.replace("%U", "");
|
|
||||||
let prefix = if d.term {
|
|
||||||
&self.term_opener
|
|
||||||
} else {
|
|
||||||
&self.app_opener
|
|
||||||
};
|
|
||||||
|
|
||||||
let lexed = if prefix.len() > 0 {
|
|
||||||
let mut prefix = shlex::split(prefix).unwrap();
|
|
||||||
prefix.push(exec);
|
|
||||||
prefix
|
|
||||||
} else {
|
|
||||||
shlex::split(&exec).unwrap()
|
|
||||||
};
|
|
||||||
if lexed.len() > 0 {
|
|
||||||
let _ =
|
|
||||||
Command::new(lexed[0].clone()).args(&lexed[1..]).spawn();
|
|
||||||
self.tx.send(Cmd::Exit).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(url) = &d.url {
|
|
||||||
if self.url_opener.len() > 0 {
|
|
||||||
let mut lexed = shlex::split(&self.url_opener).unwrap();
|
|
||||||
lexed.push(url.to_string());
|
|
||||||
if lexed.len() > 0 {
|
|
||||||
let _ = Command::new(lexed[0].clone())
|
|
||||||
.args(&lexed[1..])
|
|
||||||
.spawn();
|
|
||||||
self.tx.send(Cmd::Exit).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
keysyms::XKB_KEY_Right => {
|
|
||||||
if self.matches.len() > 0 && self.offset < self.matches.len() - 1 {
|
|
||||||
self.offset += 1;
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
keysyms::XKB_KEY_Left => {
|
|
||||||
if self.matches.len() > 0 && self.offset > 0 {
|
|
||||||
self.offset -= 1;
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => match interpreted {
|
|
||||||
Some(v) => {
|
|
||||||
self.input += &v;
|
|
||||||
self.offset = 0;
|
|
||||||
self.result = None;
|
|
||||||
self.dirty = true;
|
|
||||||
}
|
|
||||||
None => {}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn mouse_click(&mut self, _: u32, _: (u32, u32)) {}
|
|
||||||
fn mouse_scroll(&mut self, _: (f64, f64), _: (u32, u32)) {}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
pub mod backlight;
|
|
||||||
pub mod bar_widget;
|
|
||||||
pub mod battery;
|
|
||||||
pub mod calendar;
|
|
||||||
pub mod clock;
|
|
||||||
pub mod date;
|
|
||||||
pub mod launcher;
|
|
||||||
pub mod networkmanager;
|
|
||||||
|
|
||||||
#[cfg(any(feature = "alsa-widget", feature = "pulseaudio-widget"))]
|
|
||||||
pub mod audio;
|
|
||||||
@@ -1,516 +0,0 @@
|
|||||||
use crate::color::Color;
|
|
||||||
use crate::draw::{Font, ROBOTO_REGULAR};
|
|
||||||
use crate::widget::{DrawContext, DrawReport, KeyState, ModifiersState, WaitContext, Widget};
|
|
||||||
use crate::cmd::Cmd;
|
|
||||||
|
|
||||||
use std::sync::mpsc::Sender;
|
|
||||||
use std::cell::RefCell;
|
|
||||||
use std::net::Ipv4Addr;
|
|
||||||
use std::fmt;
|
|
||||||
|
|
||||||
use nix::poll::{PollFd, PollFlags};
|
|
||||||
|
|
||||||
use dbus;
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum NetworkState {
|
|
||||||
Unknown = 0,
|
|
||||||
Asleep = 10,
|
|
||||||
Disconnected = 20,
|
|
||||||
Disconnecting = 30,
|
|
||||||
Connecting = 40,
|
|
||||||
ConnectedLocal = 50,
|
|
||||||
ConnectedSite = 60,
|
|
||||||
ConnectedGlobal = 70,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<u32> for NetworkState {
|
|
||||||
fn from(id: u32) -> Self {
|
|
||||||
match id {
|
|
||||||
// https://developer.gnome.org/NetworkManager/unstable/nm-dbus-types.html#NMState
|
|
||||||
10 => NetworkState::Asleep,
|
|
||||||
20 => NetworkState::Disconnected,
|
|
||||||
30 => NetworkState::Disconnecting,
|
|
||||||
40 => NetworkState::Connecting,
|
|
||||||
50 => NetworkState::ConnectedLocal,
|
|
||||||
60 => NetworkState::ConnectedSite,
|
|
||||||
70 => NetworkState::ConnectedGlobal,
|
|
||||||
_ => NetworkState::Unknown,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ActiveConnectionState {
|
|
||||||
Unknown,
|
|
||||||
Activating,
|
|
||||||
Activated,
|
|
||||||
Deactivating,
|
|
||||||
Deactivated,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<u32> for ActiveConnectionState {
|
|
||||||
fn from(id: u32) -> Self {
|
|
||||||
match id {
|
|
||||||
// https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMActiveConnectionState
|
|
||||||
1 => ActiveConnectionState::Activating,
|
|
||||||
2 => ActiveConnectionState::Activated,
|
|
||||||
3 => ActiveConnectionState::Deactivating,
|
|
||||||
4 => ActiveConnectionState::Deactivated,
|
|
||||||
_ => ActiveConnectionState::Unknown,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum DeviceType {
|
|
||||||
Unknown,
|
|
||||||
Ethernet,
|
|
||||||
Wifi,
|
|
||||||
Modem,
|
|
||||||
Bridge,
|
|
||||||
TUN,
|
|
||||||
Wireguard,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<u32> for DeviceType {
|
|
||||||
fn from(id: u32) -> Self {
|
|
||||||
match id {
|
|
||||||
// https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMDeviceType
|
|
||||||
1 => DeviceType::Ethernet,
|
|
||||||
2 => DeviceType::Wifi,
|
|
||||||
8 => DeviceType::Modem,
|
|
||||||
13 => DeviceType::Bridge,
|
|
||||||
16 => DeviceType::TUN,
|
|
||||||
29 => DeviceType::Wireguard,
|
|
||||||
_ => DeviceType::Unknown,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Ipv4Address {
|
|
||||||
address: Ipv4Addr,
|
|
||||||
prefix: u32,
|
|
||||||
gateway: Ipv4Addr,
|
|
||||||
}
|
|
||||||
|
|
||||||
trait ByteOrderSwap {
|
|
||||||
fn swap(&self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ByteOrderSwap for u32 {
|
|
||||||
fn swap(&self) -> u32 {
|
|
||||||
((self & 0x000000FF) << 24) | ((self & 0x0000FF00) << 8) | ((self & 0x00FF0000) >> 8) | ((self & 0xFF000000) >> 24)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> From<dbus::arg::Array<'a, u32, dbus::arg::Iter<'a>>> for Ipv4Address {
|
|
||||||
fn from(s: dbus::arg::Array<'a, u32, dbus::arg::Iter<'a>>) -> Ipv4Address {
|
|
||||||
let mut i = s.into_iter();
|
|
||||||
Ipv4Address {
|
|
||||||
address: Ipv4Addr::from(i.next().unwrap().swap()),
|
|
||||||
prefix: i.next().unwrap(),
|
|
||||||
gateway: Ipv4Addr::from(i.next().unwrap().swap()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl fmt::Display for Ipv4Address {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
|
||||||
write!(f, "{}/{}", self.address, self.prefix)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_nm_property<'a>(
|
|
||||||
con: &dbus::Connection,
|
|
||||||
obj: &str,
|
|
||||||
path: &dbus::Path<'a>,
|
|
||||||
property: &str,
|
|
||||||
) -> Result<dbus::Message, ::std::io::Error> {
|
|
||||||
let msg = dbus::Message::new_method_call(
|
|
||||||
obj,
|
|
||||||
path,
|
|
||||||
"org.freedesktop.DBus.Properties",
|
|
||||||
"Get",
|
|
||||||
)
|
|
||||||
.map_err(|_| {
|
|
||||||
::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not send make dbus method call",
|
|
||||||
)
|
|
||||||
})?
|
|
||||||
.append2(
|
|
||||||
dbus::MessageItem::Str("org.freedesktop.NetworkManager".to_string()),
|
|
||||||
dbus::MessageItem::Str(property.to_string()),
|
|
||||||
);
|
|
||||||
|
|
||||||
con.send_with_reply_and_block(msg, 1000).map_err(|_| {
|
|
||||||
::std::io::Error::new(::std::io::ErrorKind::Other, "could not send dbus message")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn state(con: &dbus::Connection) -> Result<NetworkState, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager", &"/org/freedesktop/NetworkManager".into(), "State").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve state",
|
|
||||||
))?;
|
|
||||||
let state: dbus::arg::Variant<u32> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(NetworkState::from(state.0))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn primary_connection(con: &dbus::Connection) -> Result<NmConnection, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager", &"/org/freedesktop/NetworkManager".into(), "PrimaryConnection").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not primary connection",
|
|
||||||
))?;
|
|
||||||
let primary_connection: dbus::arg::Variant<dbus::Path> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
if let Ok(conn) = primary_connection.0.as_cstr().to_str() {
|
|
||||||
if conn == "/" {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"no primary connection",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(NmConnection { path: primary_connection.0.clone() })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn active_connections(con: &dbus::Connection) -> Result<Vec<NmConnection>, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager", &"/org/freedesktop/NetworkManager".into(), "ActiveConnections").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve active connections",
|
|
||||||
))?;
|
|
||||||
let active_connections: dbus::arg::Variant<dbus::arg::Array<dbus::Path, dbus::arg::Iter>> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(active_connections.0.into_iter().map(|x| NmConnection { path: x }).collect())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct NmConnection<'a> {
|
|
||||||
path: dbus::Path<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> NmConnection<'a> {
|
|
||||||
fn state(&self, con: &dbus::Connection) -> Result<ActiveConnectionState, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Connection.Active", &self.path, "State").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve connection state",
|
|
||||||
))?;
|
|
||||||
let state: dbus::arg::Variant<u32> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(ActiveConnectionState::from(state.0))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn id(&self, con: &dbus::Connection) -> Result<String, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Connection.Active", &self.path, "Id").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve connection ID",
|
|
||||||
))?;
|
|
||||||
let id: dbus::arg::Variant<String> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(id.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn devices(&self, con: &dbus::Connection) -> Result<Vec<NmDevice>, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Connection.Active", &self.path, "Devices").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve connection devices",
|
|
||||||
))?;
|
|
||||||
let devices: dbus::arg::Variant<dbus::arg::Array<dbus::Path, dbus::arg::Iter>> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(devices.0.into_iter().map(|x| NmDevice { path: x }).collect())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct NmDevice<'a> {
|
|
||||||
path: dbus::Path<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> NmDevice<'a> {
|
|
||||||
fn device_type(&self, con: &dbus::Connection) -> Result<DeviceType, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Device", &self.path, "DeviceType").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve device type",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let device_type: dbus::arg::Variant<u32> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(DeviceType::from(device_type.0))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ip4config(&self, con: &dbus::Connection) -> Result<NmIp4Config, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Device", &self.path, "Ip4Config").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve ip4config",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let ip4config: dbus::arg::Variant<dbus::Path> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(NmIp4Config { path: ip4config.0 })
|
|
||||||
}
|
|
||||||
|
|
||||||
fn active_access_point(&self, con: &dbus::Connection) -> Result<NmAccessPoint, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.Device.Wireless", &self.path, "ActiveAccessPoint").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve device type",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let active_ap: dbus::arg::Variant<dbus::Path> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(NmAccessPoint { path: active_ap.0 })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct NmAccessPoint<'a> {
|
|
||||||
path: dbus::Path<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> NmAccessPoint<'a> {
|
|
||||||
fn ssid(&self, con: &dbus::Connection) -> Result<String, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.AccessPoint", &self.path, "Ssid").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve ssid",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let ssid: dbus::arg::Variant<dbus::arg::Array<u8, dbus::arg::Iter>> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(std::str::from_utf8(&ssid.0.into_iter().collect::<Vec<u8>>())
|
|
||||||
.map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not parse ssid",
|
|
||||||
))?
|
|
||||||
.to_string())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn strength(&self, con: &dbus::Connection) -> Result<u8, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.AccessPoint", &self.path, "Strength").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve access point strength",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let strength: dbus::arg::Variant<u8> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(strength.0)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn frequency(&self, con: &dbus::Connection) -> Result<u32, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.AccessPoint", &self.path, "Frequency").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve access point frequency",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let frequency: dbus::arg::Variant<u32> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(frequency.0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct NmIp4Config<'a> {
|
|
||||||
path: dbus::Path<'a>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> NmIp4Config<'a> {
|
|
||||||
fn addresses(&self, con: &dbus::Connection) -> Result<Vec<Ipv4Address>, ::std::io::Error> {
|
|
||||||
let m = get_nm_property(con, "org.freedesktop.NetworkManager.IP4Config", &self.path, "Addresses").map_err(|_| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not retrieve addresses",
|
|
||||||
))?;
|
|
||||||
|
|
||||||
let addresses: dbus::arg::Variant<dbus::arg::Array<dbus::arg::Array<u32, dbus::arg::Iter>, dbus::arg::Iter>> = m.get1().ok_or_else(|| ::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"could not read property",
|
|
||||||
))?;
|
|
||||||
Ok(addresses.0.into_iter().map(|addr| Ipv4Address::from(addr)).collect())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The widget is created on a different thread than where it will be used, so
|
|
||||||
// we need it to be Send. However, dbus::Connection has a void*, so it's not
|
|
||||||
// auto-derived. So, we make a small wrapper where we make it Send.
|
|
||||||
struct DbusConnection(dbus::Connection);
|
|
||||||
|
|
||||||
impl std::convert::AsRef<dbus::Connection> for DbusConnection {
|
|
||||||
fn as_ref(&self) -> &dbus::Connection {
|
|
||||||
return &self.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl Send for DbusConnection {}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct Device {
|
|
||||||
// name: String,
|
|
||||||
t: DeviceType,
|
|
||||||
ips: Vec<Ipv4Address>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Connection {
|
|
||||||
devices: Vec<Device>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct NetworkManager {
|
|
||||||
con: DbusConnection,
|
|
||||||
watch: dbus::Watch,
|
|
||||||
|
|
||||||
font: RefCell<Font>,
|
|
||||||
font_size: u32,
|
|
||||||
state: NetworkState,
|
|
||||||
dirty: bool,
|
|
||||||
tx: Sender<Cmd>,
|
|
||||||
length: u32,
|
|
||||||
connections: Vec<Connection>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl NetworkManager {
|
|
||||||
fn update(&mut self) -> Result<(), ::std::io::Error> {
|
|
||||||
self.state = state(self.con.as_ref())?;
|
|
||||||
|
|
||||||
self.connections = active_connections(self.con.as_ref())?
|
|
||||||
.into_iter()
|
|
||||||
.map(|c| {
|
|
||||||
let devices = c.devices(self.con.as_ref()).unwrap()
|
|
||||||
.into_iter()
|
|
||||||
.map(|d| {
|
|
||||||
let t = d.device_type(self.con.as_ref()).unwrap();
|
|
||||||
let ips = d.ip4config(self.con.as_ref()).unwrap().addresses(self.con.as_ref()).unwrap();
|
|
||||||
Device{
|
|
||||||
t,
|
|
||||||
ips,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
Connection{
|
|
||||||
devices
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(font_size: f32, length: u32, tx: Sender<Cmd>) -> Result<Box<NetworkManager>, ::std::io::Error> {
|
|
||||||
let con = dbus::Connection::get_private(dbus::BusType::System).map_err(|_| {
|
|
||||||
::std::io::Error::new(::std::io::ErrorKind::Other, "unable to open dbus")
|
|
||||||
})?;
|
|
||||||
|
|
||||||
|
|
||||||
let font = Font::new(&ROBOTO_REGULAR, font_size);
|
|
||||||
|
|
||||||
let fds = con.watch_fds();
|
|
||||||
if fds.len() != 1 {
|
|
||||||
return Err(::std::io::Error::new(
|
|
||||||
::std::io::ErrorKind::Other,
|
|
||||||
"expected 1 watch fd from dbus",
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut nm = NetworkManager {
|
|
||||||
con: DbusConnection(con),
|
|
||||||
font: RefCell::new(font),
|
|
||||||
font_size: font_size as u32,
|
|
||||||
length,
|
|
||||||
state: NetworkState::Unknown,
|
|
||||||
dirty: true,
|
|
||||||
watch: fds[0],
|
|
||||||
tx,
|
|
||||||
connections: Vec::new(),
|
|
||||||
};
|
|
||||||
|
|
||||||
nm.update()?;
|
|
||||||
|
|
||||||
Ok(Box::new(nm))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for NetworkManager {
|
|
||||||
fn wait(&mut self, ctx: &mut WaitContext) {
|
|
||||||
let mut stuff = false;
|
|
||||||
for _ in self
|
|
||||||
.con
|
|
||||||
.as_ref()
|
|
||||||
.watch_handle(self.watch.fd(), dbus::WatchEvent::Readable as u32)
|
|
||||||
{
|
|
||||||
stuff = true;
|
|
||||||
}
|
|
||||||
if stuff {
|
|
||||||
self.update().unwrap();
|
|
||||||
self.dirty = true;
|
|
||||||
self.tx.send(Cmd::Draw).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx.fds
|
|
||||||
.push(PollFd::new(self.watch.fd(), PollFlags::POLLIN));
|
|
||||||
}
|
|
||||||
fn enter(&mut self) {}
|
|
||||||
fn leave(&mut self) {}
|
|
||||||
fn size(&self) -> (u32, u32) {
|
|
||||||
(self.length, self.font_size * self.connections.len() as u32)
|
|
||||||
}
|
|
||||||
fn draw(
|
|
||||||
&mut self,
|
|
||||||
ctx: &mut DrawContext,
|
|
||||||
pos: (u32, u32),
|
|
||||||
) -> Result<DrawReport, ::std::io::Error> {
|
|
||||||
let (width, height) = self.size();
|
|
||||||
{
|
|
||||||
if !self.dirty && !ctx.force {
|
|
||||||
return Ok(DrawReport::empty(width, height));
|
|
||||||
}
|
|
||||||
self.dirty = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
let buf = &mut ctx.buf.subdimensions((pos.0, pos.1, width, height))?;
|
|
||||||
buf.memset(ctx.bg);
|
|
||||||
|
|
||||||
for con in &self.connections {
|
|
||||||
if con.devices.len() == 0 {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let d = &con.devices[0];
|
|
||||||
let c = Color::new(1.0, 1.0, 1.0, 1.0);
|
|
||||||
self.font.borrow_mut().auto_draw_text(buf, ctx.bg, &c, "network")?;
|
|
||||||
let bar_off = 5 * self.font_size;
|
|
||||||
self.font.borrow_mut().auto_draw_text(&mut buf.offset((bar_off, 0))?, ctx.bg, &c, &format!("{:?}", d))?;
|
|
||||||
}
|
|
||||||
Ok(DrawReport {
|
|
||||||
width: width,
|
|
||||||
height: height,
|
|
||||||
damage: vec![buf.get_signed_bounds()],
|
|
||||||
full_damage: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn keyboard_input(&mut self, _: u32, _: ModifiersState, _: KeyState, _: Option<String>) {}
|
|
||||||
fn mouse_click(&mut self, _: u32, _: (u32, u32)) {}
|
|
||||||
fn mouse_scroll(&mut self, _: (f64, f64), _: (u32, u32)) {}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user