diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dad703ac..06f07386 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,9 @@ jobs: - name: Build Linux tool run: cargo build -p framework_tool + - name: Build Linux daemon + run: cargo build -p frameworkd + - name: Check if Linux tool can start run: cargo run -- --help @@ -55,6 +58,12 @@ jobs: name: framework_tool_debug path: target/debug/framework_tool + - name: Upload Linux Daemon + uses: actions/upload-artifact@v7 + with: + name: frameworkd + path: target/debug/frameworkd + - name: Build Linux tool (Release) run: cargo build -p framework_tool --release --features nvidia,smartmontools @@ -145,6 +154,9 @@ jobs: cargo build -p framework_tool cargo build -p framework_tool --release --features nvidia,smartmontools + - name: Build Windows daemon + run: cargo build -p frameworkd + - name: Check if Windows tool can start run: target/release/framework_tool.exe --help @@ -168,6 +180,12 @@ jobs: name: framework_tool.exe path: target/release/framework_tool.exe + - name: Upload Windows Daemon + uses: actions/upload-artifact@v7 + with: + name: frameworkd.exe + path: target/debug/frameworkd.exe + test: name: Test Suite @@ -209,7 +227,7 @@ jobs: run: cargo fmt --all -- --check - name: Run cargo clippy - run: cargo clippy -p framework_lib -p framework_tool -- -D warnings + run: cargo clippy -p framework_lib -p framework_tool -p frameworkd -- -D warnings - name: Check shell completions are up to date run: | @@ -247,3 +265,13 @@ jobs: - name: Run cargo doc run: cargo doc + + build-installer: + name: Build frameworkd Windows installer + runs-on: windows-latest + steps: + - name: Build installer + run: cargo wix -p frameworkd --nocapture -d + + - name: Check output + run: dir target\wix \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 776a6be1..ae75b734 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,6 +70,181 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "async-broadcast" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48ccdbf6ca6b121e0f586cbc0e73ae440e56c67c30fa0873b4e110d9c26d2b" +dependencies = [ + "event-listener 2.5.3", + "futures-core", +] + +[[package]] +name = "async-channel" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "924ed96dd52d1b75e9c1a3e6275715fd320f5f9439fb5a4a11fa51f4221158d2" +dependencies = [ + "concurrent-queue", + "event-listener-strategy", + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "async-executor" +version = "1.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f426a31126c735126297bc5ea7a521263c9faff4f63ca415267ee625651c4f37" +dependencies = [ + "async-task", + "concurrent-queue", + "fastrand 2.5.0", + "futures-lite 2.6.1", + "pin-project-lite", + "slab", +] + +[[package]] +name = "async-fs" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "279cf904654eeebfa37ac9bb1598880884924aab82e290aa65c9e77a0e142e06" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "blocking", + "futures-lite 1.13.0", +] + +[[package]] +name = "async-io" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" +dependencies = [ + "async-lock 2.8.0", + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-lite 1.13.0", + "log", + "parking", + "polling 2.8.0", + "rustix 0.37.28", + "slab", + "socket2", + "waker-fn", +] + +[[package]] +name = "async-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc" +dependencies = [ + "autocfg", + "cfg-if", + "concurrent-queue", + "futures-io", + "futures-lite 2.6.1", + "parking", + "polling 3.11.0", + "rustix 1.1.6", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-lock" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" +dependencies = [ + "event-listener 2.5.3", +] + +[[package]] +name = "async-lock" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0876700b0d007ad25d5508865a4259c3af9af6d296bf663a0d586d0bc3369f6f" +dependencies = [ + "event-listener 5.4.2", + "event-listener-strategy", + "pin-project-lite", +] + +[[package]] +name = "async-process" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6438ba0a08d81529c69b36700fa2f95837bfe3e776ab39cde9c14d9149da88" +dependencies = [ + "async-io 1.13.0", + "async-lock 2.8.0", + "async-signal", + "blocking", + "cfg-if", + "event-listener 3.1.0", + "futures-lite 1.13.0", + "rustix 0.38.44", + "windows-sys 0.48.0", +] + +[[package]] +name = "async-recursion" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f8abc12baad266b1c8cec146854c195b5864b4221d4b2ca7296a7ae82d9e451" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "async-signal" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52b5aaafa020cf5053a01f2a60e8ff5dccf550f0f77ec54a4e47285ac2bab485" +dependencies = [ + "async-io 2.6.0", + "async-lock 3.5.0", + "atomic-waker", + "cfg-if", + "futures-core", + "futures-io", + "rustix 1.1.6", + "signal-hook-registry", + "slab", + "windows-sys 0.61.2", +] + +[[package]] +name = "async-task" +version = "4.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" version = "1.5.1" @@ -103,6 +278,35 @@ dependencies = [ "generic-array", ] +[[package]] +name = "blocking" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a70e4329df6cb94385eed412ec92375c3cdd8a6e502493d1229b6414e4036dfa" +dependencies = [ + "async-channel", + "async-task", + "futures-io", + "futures-lite 2.6.1", + "piper", +] + +[[package]] +name = "brightness" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ccf3c64278486354c6c41b71293570a207684a34cceb53137975d781748d33f" +dependencies = [ + "async-trait", + "blocking", + "cfg-if", + "futures", + "itertools", + "thiserror 1.0.69", + "windows 0.39.0", + "zbus", +] + [[package]] name = "built" version = "0.8.1" @@ -119,6 +323,12 @@ version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + [[package]] name = "cc" version = "1.6.0" @@ -151,7 +361,7 @@ checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" dependencies = [ "cfg-if", "cpufeatures 0.3.1", - "rand_core", + "rand_core 0.10.1", ] [[package]] @@ -221,7 +431,7 @@ version = "4.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 3.0.6", @@ -249,6 +459,27 @@ version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" +[[package]] +name = "concat-string" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7439becb5fafc780b6f4de382b1a7a3e70234afe783854a4702ee8adbb838609" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-sha1" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb58b6451e8c2a812ad979ed1d83378caa5e927eef2622017a45f251457c2c9d" + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -273,6 +504,12 @@ dependencies = [ "libc", ] +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + [[package]] name = "crypto-common" version = "0.1.7" @@ -349,6 +586,17 @@ dependencies = [ "thiserror 2.0.21", ] +[[package]] +name = "derivative" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "digest" version = "0.10.7" @@ -369,6 +617,12 @@ dependencies = [ "uuid", ] +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + [[package]] name = "embed-resource" version = "3.0.11" @@ -383,6 +637,27 @@ dependencies = [ "winreg 0.55.0", ] +[[package]] +name = "enumflags2" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1027f7680c853e056ebcec683615fb6fbbc07dbaa13b4d5d9442b146ded4ecef" +dependencies = [ + "enumflags2_derive", + "serde", +] + +[[package]] +name = "enumflags2_derive" +version = "0.7.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67c78a4d8fdf9953a5c9d458f9efe940fd97a0cab0941c075a813ac594733827" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + [[package]] name = "env_filter" version = "2.0.0" @@ -412,12 +687,85 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "event-listener" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93877bcde0eb80ca09131a08d23f0a5c18a620b01db137dba666d18cd9b30c2" +dependencies = [ + "concurrent-queue", + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener" +version = "5.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a23add41df1562121a9393cb065eab5146a1242410f23a644851e90cfd669d2" +dependencies = [ + "parking", + "pin-project-lite", +] + +[[package]] +name = "event-listener-strategy" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8be9f3dfaaffdae2972880079a491a1a8bb7cbed0b8dd7a347f668b4150a3b93" +dependencies = [ + "event-listener 5.4.2", + "pin-project-lite", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + [[package]] name = "find-msvc-tools" version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484" +[[package]] +name = "find-winsdk" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8cbf17b871570c1f8612b763bac3e86290602bcf5dc3c5ce657e0e1e9071d9e" +dependencies = [ + "serde", + "serde_derive", + "winreg 0.5.1", +] + [[package]] name = "fnv" version = "1.0.7" @@ -441,14 +789,14 @@ dependencies = [ "lazy_static", "libc", "log", - "nix", + "nix 0.31.3", "no-std-compat", "num", "num-derive", "num-traits", "nvml-wrapper", "plain", - "rand", + "rand 0.10.3", "regex", "rusb", "sha1", @@ -457,7 +805,7 @@ dependencies = [ "spin 0.12.3", "uefi", "uefi-raw", - "windows", + "windows 0.62.2", "windows-version", "winreg 0.56.0", "zerocopy", @@ -483,12 +831,113 @@ dependencies = [ "uefi", ] +[[package]] +name = "frameworkd" +version = "0.1.0" +dependencies = [ + "brightness", + "framework_lib", + "qmk_hid", + "trayicon", + "winapi", + "windows 0.3.1", + "windres", + "winrt-notification", +] + +[[package]] +name = "futures" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4" +dependencies = [ + "futures-core", + "futures-sink", +] + [[package]] name = "futures-core" version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" +[[package]] +name = "futures-executor" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed" + +[[package]] +name = "futures-lite" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" +dependencies = [ + "fastrand 1.9.0", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-lite" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f78e10609fe0e0b3f4157ffab1876319b5b0db102a2c60dc4626306dc46b44ad" +dependencies = [ + "fastrand 2.5.0", + "futures-core", + "futures-io", + "parking", + "pin-project-lite", +] + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + +[[package]] +name = "futures-sink" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d" + [[package]] name = "futures-task" version = "0.3.34" @@ -501,8 +950,13 @@ version = "0.3.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "slab", ] @@ -517,6 +971,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + [[package]] name = "getrandom" version = "0.4.3" @@ -526,7 +991,7 @@ dependencies = [ "cfg-if", "libc", "r-efi", - "rand_core", + "rand_core 0.10.1", ] [[package]] @@ -542,37 +1007,64 @@ dependencies = [ ] [[package]] -name = "guid-create" -version = "0.5.2" +name = "guid-create" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c525e972d6c182cab88bf69fe99a1a07e153f142453fe44d7e122409c77c5177" +dependencies = [ + "winapi", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c525e972d6c182cab88bf69fe99a1a07e153f142453fe44d7e122409c77c5177" -dependencies = [ - "winapi", -] +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] -name = "hashbrown" -version = "0.17.1" +name = "hermit-abi" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" [[package]] -name = "heck" -version = "0.5.0" +name = "hex" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hidapi" -version = "2.6.7" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "818c0e1d27887aaf76fe737042e27a66b796a7b099e6d2e1a72d106c2dff3fa6" +checksum = "565dd4c730b8f8b2c0fb36df6be12e5470ae10895ddcc4e9dcfbfb495de202b0" dependencies = [ "cc", "cfg-if", "libc", "pkg-config", - "windows-sys 0.61.2", + "windows-sys 0.48.0", ] [[package]] @@ -615,12 +1107,41 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + [[package]] name = "jiff" version = "0.2.37" @@ -664,7 +1185,7 @@ version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" dependencies = [ - "getrandom", + "getrandom 0.4.3", "libc", ] @@ -740,6 +1261,24 @@ dependencies = [ "vcpkg", ] +[[package]] +name = "linux-raw-sys" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "lock_api" version = "0.4.14" @@ -761,6 +1300,36 @@ version = "2.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" +[[package]] +name = "memoffset" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" +dependencies = [ + "autocfg", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "nix" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" +dependencies = [ + "bitflags 1.3.2", + "cfg-if", + "libc", + "memoffset 0.7.1", +] + [[package]] name = "nix" version = "0.31.3" @@ -885,12 +1454,39 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "ordered-stream" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" +dependencies = [ + "futures-core", + "pin-project-lite", +] + +[[package]] +name = "parking" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f38d5652c16fde515bb1ecef450ab0f6a219d619a7274976324d5e377f7dceba" + [[package]] name = "pin-project-lite" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" +[[package]] +name = "piper" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c835479a4443ded371d6c535cbfd8d31ad92c5d23ae9770a61bc155e4992a3c1" +dependencies = [ + "atomic-waker", + "fastrand 2.5.0", + "futures-io", +] + [[package]] name = "pkg-config" version = "0.3.34" @@ -903,6 +1499,36 @@ version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +[[package]] +name = "polling" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" +dependencies = [ + "autocfg", + "bitflags 1.3.2", + "cfg-if", + "concurrent-queue", + "libc", + "log", + "pin-project-lite", + "windows-sys 0.48.0", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi 0.5.3", + "pin-project-lite", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + [[package]] name = "portable-atomic" version = "1.15.0" @@ -918,6 +1544,25 @@ dependencies = [ "portable-atomic", ] +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro-crate" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" +dependencies = [ + "once_cell", + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.107" @@ -947,6 +1592,16 @@ dependencies = [ "syn 3.0.6", ] +[[package]] +name = "qmk_hid" +version = "0.1.13" +source = "git+https://github.com/FrameworkComputer/qmk_hid#8f02fe5e34e27dc60260ee564e86a11f2dc7ca87" +dependencies = [ + "clap", + "hidapi", + "static_vcruntime", +] + [[package]] name = "quote" version = "1.0.47" @@ -962,6 +1617,17 @@ version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha", + "rand_core 0.6.4", +] + [[package]] name = "rand" version = "0.10.3" @@ -969,8 +1635,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" dependencies = [ "chacha20", - "getrandom", - "rand_core", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", ] [[package]] @@ -1033,6 +1718,46 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "0.37.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "519165d378b97752ca44bbe15047d5d3409e875f39327546b42ac81d7e18c1b6" +dependencies = [ + "bitflags 1.3.2", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys 0.3.8", + "windows-sys 0.48.0", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + [[package]] name = "rustversion" version = "1.0.23" @@ -1051,6 +1776,16 @@ version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + [[package]] name = "serde_core" version = "1.0.229" @@ -1071,6 +1806,17 @@ dependencies = [ "syn 3.0.6", ] +[[package]] +name = "serde_repr" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d3b1629de253c70a0508c3899572da79ca359fdab27c7920ff00406df418906" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.6", +] + [[package]] name = "serde_spanned" version = "1.1.1" @@ -1108,6 +1854,16 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" +[[package]] +name = "signal-hook-registry" +version = "1.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b" +dependencies = [ + "errno", + "libc", +] + [[package]] name = "slab" version = "0.4.12" @@ -1123,6 +1879,16 @@ dependencies = [ "cc", ] +[[package]] +name = "socket2" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" +dependencies = [ + "libc", + "winapi", +] + [[package]] name = "spin" version = "0.9.9" @@ -1138,6 +1904,12 @@ dependencies = [ "lock_api", ] +[[package]] +name = "squote" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fccf17fd09e2455ea796d2ad267b64fa2c5cbd8701b2a93b555d2aa73449f7d" + [[package]] name = "static_assertions" version = "1.1.0" @@ -1156,6 +1928,38 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7ac893c7d471c8a21f31cfe213ec4f6d9afeed25537c772e08ef3f005f8729e" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "339f799d8b549e3744c7ac7feb216383e4005d94bdb22561b3ab8f3b808ae9fb" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "syn" version = "2.0.119" @@ -1178,6 +1982,19 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand 2.5.0", + "getrandom 0.4.3", + "once_cell", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -1227,35 +2044,92 @@ dependencies = [ "indexmap", "serde_core", "serde_spanned", - "toml_datetime", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", - "winnow", + "winnow 1.0.4", +] + +[[package]] +name = "toml_datetime" +version = "0.6.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" + +[[package]] +name = "toml_datetime" +version = "1.1.1+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "toml_datetime 0.6.11", + "winnow 0.5.40", +] + +[[package]] +name = "toml_parser" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +dependencies = [ + "winnow 1.0.4", +] + +[[package]] +name = "toml_writer" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", ] [[package]] -name = "toml_datetime" -version = "1.1.1+spec-1.1.0" +name = "tracing-attributes" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3165f65f62e28e0115a00b2ebdd37eb6f3b641855f9d636d3cd4103767159ad7" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ - "serde_core", + "proc-macro2", + "quote", + "syn 2.0.119", ] [[package]] -name = "toml_parser" -version = "1.1.3+spec-1.1.0" +name = "tracing-core" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" dependencies = [ - "winnow", + "once_cell", ] [[package]] -name = "toml_writer" -version = "1.1.2+spec-1.1.0" +name = "trayicon" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" +checksum = "c51617694e059fe4b83ab48e435660c1ba5b48b1573b4c143fdabd1c0f279daa" +dependencies = [ + "winapi", +] [[package]] name = "typenum" @@ -1272,6 +2146,17 @@ dependencies = [ "bit_field", ] +[[package]] +name = "uds_windows" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" +dependencies = [ + "memoffset 0.9.1", + "tempfile", + "windows-sys 0.61.2", +] + [[package]] name = "uefi" version = "0.41.0" @@ -1321,6 +2206,12 @@ version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954" +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + [[package]] name = "utf8parse" version = "0.2.2" @@ -1365,6 +2256,18 @@ dependencies = [ "libc", ] +[[package]] +name = "waker-fn" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + [[package]] name = "wasm-bindgen" version = "0.2.129" @@ -1432,6 +2335,43 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "426842497696b65fbfc575691d94ef65befb248ed1a8c4361e293c724e7ebe61" +dependencies = [ + "const-sha1", + "windows_gen", + "windows_macros", + "windows_winmd", +] + +[[package]] +name = "windows" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f39345ae0c8ab072c0ac7fe8a8b411636aa34f89be19ddd0d9226544f13944" +dependencies = [ + "windows_i686_gnu 0.24.0", + "windows_i686_msvc 0.24.0", + "windows_x86_64_gnu 0.24.0", + "windows_x86_64_msvc 0.24.0", +] + +[[package]] +name = "windows" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1c4bd0a50ac6020f65184721f758dba47bb9fbc2133df715ec74a237b26794a" +dependencies = [ + "windows_aarch64_msvc 0.39.0", + "windows_i686_gnu 0.39.0", + "windows_i686_msvc 0.39.0", + "windows_x86_64_gnu 0.39.0", + "windows_x86_64_msvc 0.39.0", +] + [[package]] name = "windows" version = "0.62.2" @@ -1539,13 +2479,22 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -1557,20 +2506,35 @@ dependencies = [ "windows-link 0.2.1", ] +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -1591,18 +2555,79 @@ dependencies = [ "windows-link 0.100.0", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7711666096bd4096ffa835238905bb33fb87267910e154b18b44eaabb340f2" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_gen" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ac8f0f06b647f42ee5459a8e1ffe41795647582c5926ec3fa363a91aad7d77" +dependencies = [ + "proc-macro2", + "quote", + "squote", + "syn 1.0.109", + "windows_gen_macros", + "windows_winmd", +] + +[[package]] +name = "windows_gen_macros" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23eac2169a20173b890c496f9e0e1149a92ef29fe4ba96026b72eec363b993f9" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "windows_i686_gnu" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0866510a3eca9aed73a077490bbbf03e5eaac4e1fd70849d89539e5830501fd" + +[[package]] +name = "windows_i686_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "763fc57100a5f7042e3057e7e8d9bdd7860d330070251a73d003563a3bb49e1b" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.6" @@ -1615,36 +2640,159 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_msvc" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf0ffed56b7e9369a29078d2ab3aaeceea48eb58999d2cff3aa2494a275b95c6" + +[[package]] +name = "windows_i686_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bc7cbfe58828921e10a9f446fcaaf649204dcfe6c1ddd712c5eebae6bda1106" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_macros" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9edc57c944eec106c7823b425ab0fd9f90163489e50a4df747f65fcf9030e1fb" +dependencies = [ + "proc-macro2", + "quote", + "squote", + "syn 1.0.109", + "windows_gen", + "windows_winmd", +] + +[[package]] +name = "windows_winmd" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16d44527d04c9713312ed598f5d6ce3c453754dbfc03ddc376615be4415ffc88" +dependencies = [ + "windows_winmd_macros", +] + +[[package]] +name = "windows_winmd_macros" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2353f43f512938450614a176abf2b6cb31ac3b84fd71c88470fee571303e3f36" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "windows_x86_64_gnu" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384a173630588044205a2993b6864a2f56e5a8c1e7668c07b93ec18cf4888dc4" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6868c165637d653ae1e8dc4d82c25d4f97dd6605eaa8d784b5c6e0ab2a252b65" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_msvc" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bd8f062d8ca5446358159d79a90be12c543b3a965c847c8f3eedf14b321d399" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e4d40883ae9cae962787ca76ba76390ffa29214667a111db9e0a1ad8377e809" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "windres" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82115619221b2b66001a39088b8059d171b1f9005a00d6a10c6e8a71a30a4cdc" +dependencies = [ + "concat-string", + "find-winsdk", +] + +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "winnow" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +[[package]] +name = "winreg" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a27a759395c1195c4cc5cda607ef6f8f6498f64e78f7900f5de0a127a424704a" +dependencies = [ + "serde", + "winapi", +] + [[package]] name = "winreg" version = "0.55.0" @@ -1675,6 +2823,17 @@ dependencies = [ "version_check", ] +[[package]] +name = "winrt-notification" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "007a0353840b23e0c6dc73e5b962ff58ed7f6bc9ceff3ce7fe6fbad8d496edf4" +dependencies = [ + "strum", + "windows 0.24.0", + "xml-rs", +] + [[package]] name = "wrapcenum-derive" version = "0.4.1" @@ -1687,6 +2846,88 @@ dependencies = [ "syn 2.0.119", ] +[[package]] +name = "xdg-home" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "zbus" +version = "3.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "675d170b632a6ad49804c8cf2105d7c31eddd3312555cffd4b740e08e97c25e6" +dependencies = [ + "async-broadcast", + "async-executor", + "async-fs", + "async-io 1.13.0", + "async-lock 2.8.0", + "async-process", + "async-recursion", + "async-task", + "async-trait", + "blocking", + "byteorder", + "derivative", + "enumflags2", + "event-listener 2.5.3", + "futures-core", + "futures-sink", + "futures-util", + "hex", + "nix 0.26.4", + "once_cell", + "ordered-stream", + "rand 0.8.8", + "serde", + "serde_repr", + "sha1", + "static_assertions", + "tracing", + "uds_windows", + "winapi", + "xdg-home", + "zbus_macros", + "zbus_names", + "zvariant", +] + +[[package]] +name = "zbus_macros" +version = "3.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7131497b0f887e8061b430c530240063d33bf9455fa34438f388a245da69e0a5" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "regex", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zbus_names" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "437d738d3750bed6ca9b8d423ccc7a8eb284f6b1d6d4e225a0e4e6258d864c8d" +dependencies = [ + "serde", + "static_assertions", + "zvariant", +] + [[package]] name = "zerocopy" version = "0.8.59" @@ -1706,3 +2947,41 @@ dependencies = [ "quote", "syn 2.0.119", ] + +[[package]] +name = "zvariant" +version = "3.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eef2be88ba09b358d3b58aca6e41cd853631d44787f319a1383ca83424fb2db" +dependencies = [ + "byteorder", + "enumflags2", + "libc", + "serde", + "static_assertions", + "zvariant_derive", +] + +[[package]] +name = "zvariant_derive" +version = "3.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37c24dc0bed72f5f90d1f8bb5b07228cbf63b3c6e9f82d82559d4bae666e7ed9" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 1.0.109", + "zvariant_utils", +] + +[[package]] +name = "zvariant_utils" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7234f0d811589db492d16893e3f21e8e2fd282e6d01b0cddee310322062cc200" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] diff --git a/Cargo.toml b/Cargo.toml index 66801a46..c7daf453 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,8 @@ resolver = "2" members = [ # Linux and Windows tool to inspect and customize the system "framework_tool", + # Linux and Windows daemon to watch for system changes and handle them + "frameworkd", # UEFI tool to inspect and customize the system "framework_uefi", # Catchall library that we'll probably want to split up further diff --git a/README.md b/README.md index 7cc2de5f..2c1861eb 100644 --- a/README.md +++ b/README.md @@ -291,6 +291,10 @@ cargo build -p framework_lib cargo build -p framework_tool ls -l target/debug/framework_tool +# Building only the daemon +cargo build -p frameworkd +ls -l target/debug/frameworkd + # Build the UEFI application # Can't be built with cargo! That's why we need to exclude it in the other commands. make -C framework_uefi diff --git a/framework_lib/Cargo.toml b/framework_lib/Cargo.toml index 83b730ff..5a1031fc 100644 --- a/framework_lib/Cargo.toml +++ b/framework_lib/Cargo.toml @@ -1,4 +1,5 @@ [package] +authors = [ "Framework Computer Inc" ] name = "framework_lib" version = "0.6.6" description = "Library to control Framework Computer systems" diff --git a/framework_lib/src/smart_battery.rs b/framework_lib/src/smart_battery.rs index dc1f2822..d4924977 100644 --- a/framework_lib/src/smart_battery.rs +++ b/framework_lib/src/smart_battery.rs @@ -708,29 +708,17 @@ fn read_password() -> io::Result { }; unsafe { - let handle = GetStdHandle(STD_INPUT_HANDLE).map_err(|e| { - io::Error::new( - io::ErrorKind::Other, - format!("Failed to get stdin handle: {}", e), - ) - })?; + let handle = GetStdHandle(STD_INPUT_HANDLE) + .map_err(|e| io::Error::other(format!("Failed to get stdin handle: {}", e)))?; let mut mode = CONSOLE_MODE::default(); - GetConsoleMode(handle, &mut mode).map_err(|e| { - io::Error::new( - io::ErrorKind::Other, - format!("Failed to get console mode: {}", e), - ) - })?; + GetConsoleMode(handle, &mut mode) + .map_err(|e| io::Error::other(format!("Failed to get console mode: {}", e)))?; // Disable echo let noecho = CONSOLE_MODE(mode.0 & !ENABLE_ECHO_INPUT.0); - SetConsoleMode(handle, noecho).map_err(|e| { - io::Error::new( - io::ErrorKind::Other, - format!("Failed to set console mode: {}", e), - ) - })?; + SetConsoleMode(handle, noecho) + .map_err(|e| io::Error::other(format!("Failed to set console mode: {}", e)))?; // Read the line let mut input = String::new(); diff --git a/frameworkd/Cargo.toml b/frameworkd/Cargo.toml new file mode 100644 index 00000000..09fde611 --- /dev/null +++ b/frameworkd/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "frameworkd" +authors = [ "Framework Computer Inc" ] +version = "0.1.0" +edition = "2021" + +[features] +lotus = [] + +# The tray application is Windows-only for now +[target.'cfg(windows)'.dependencies] +trayicon = "0.2.0" +winapi = { version = "0.3.9", features = ["winuser", "windef", "minwindef", "shellapi", "libloaderapi", "commctrl", "basetsd"] } +#crossbeam-channel = "0.5" +brightness = "0.5.0" +qmk_hid = { git = 'https://github.com/FrameworkComputer/qmk_hid' } +winrt-notification = "0.5.1" +windows = "0.3" + +[target.'cfg(windows)'.build-dependencies] +windows = "0.3" +windres = "0.2" + +[dependencies.framework_lib] +path = "../framework_lib" diff --git a/frameworkd/build.rs b/frameworkd/build.rs new file mode 100644 index 00000000..d28fbe0e --- /dev/null +++ b/frameworkd/build.rs @@ -0,0 +1,8 @@ +fn main() { + // if compiling for windows bundle the rc file + #[cfg(windows)] + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") { + windres::Build::new().compile("res/res.rc").unwrap(); + windows::build!(windows::win32::shell::SetCurrentProcessExplicitAppUserModelID); + } +} diff --git a/frameworkd/res/logo_cropped_transparent_32x32.ico b/frameworkd/res/logo_cropped_transparent_32x32.ico new file mode 100644 index 00000000..b14c4480 Binary files /dev/null and b/frameworkd/res/logo_cropped_transparent_32x32.ico differ diff --git a/frameworkd/res/res.rc b/frameworkd/res/res.rc new file mode 100644 index 00000000..00fc6b42 --- /dev/null +++ b/frameworkd/res/res.rc @@ -0,0 +1 @@ +1 ICON "res\logo_cropped_transparent_32x32.ico" \ No newline at end of file diff --git a/frameworkd/src/icon2.ico b/frameworkd/src/icon2.ico new file mode 100644 index 00000000..9a356183 Binary files /dev/null and b/frameworkd/src/icon2.ico differ diff --git a/frameworkd/src/main.rs b/frameworkd/src/main.rs new file mode 100644 index 00000000..46642333 --- /dev/null +++ b/frameworkd/src/main.rs @@ -0,0 +1,17 @@ +// In debug builds don't disable terminal +// Otherwise we can't see println and can't exit with CTRL+C +#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] + +#[cfg(windows)] +mod tray; + +#[cfg(windows)] +fn main() { + tray::main(); +} + +#[cfg(not(windows))] +fn main() { + eprintln!("frameworkd is currently only supported on Windows"); + std::process::exit(1); +} diff --git a/frameworkd/src/tray.rs b/frameworkd/src/tray.rs new file mode 100644 index 00000000..8edec648 --- /dev/null +++ b/frameworkd/src/tray.rs @@ -0,0 +1,500 @@ +use core::mem::MaybeUninit; +use std::collections::HashMap; +use std::process::Command; +use std::thread; +use std::time::Duration; + +use brightness::blocking::Brightness; +use qmk_hid::via; +use trayicon::*; +use winapi::um::winuser; +use winrt_notification::Toast; + +#[repr(u16)] +enum FrameworkPid { + Macropad = 0x0012, + IsoKeyboard = 0x0018, +} + +const LOGO_32_ICO: &[u8] = include_bytes!("../res/logo_cropped_transparent_32x32.ico"); +const VIA_URL: &str = "https://usevia.app"; +const FWK_MARKETPLACE: &str = "https://frame.work/marketplace"; +const FWK_COMMUNITY: &str = "https://community.frame.work"; +const FWK_KB: &str = "https://knowledgebase.frame.work/"; +const FWK_GUIDES: &str = "https://guides.frame.work/c/Root"; + +// Some menu entries are only added with the lotus feature or still TODO +#[allow(dead_code)] +#[derive(Copy, Clone, Eq, PartialEq, Debug)] +enum Events { + RightClickTrayIcon, + LeftClickTrayIcon, + DoubleClickTrayIcon, + Exit, + LaunchVia, + LaunchQmkGui, + LaunchLedmatrixControl, + LaunchMarketplace, + LaunchCommunity, + LaunchKb, + LaunchGuides, + // SyncKeyboards, + SyncKeyboardScreen, + NumLockOn, + NumLockOff, + NumLockToggle, +} + +enum Tool { + QmkGui, + LedmatrixControl, +} + +struct PrevValues { + brightness: HashMap, + numlock: bool, +} + +impl Default for PrevValues { + fn default() -> Self { + PrevValues { + brightness: HashMap::new(), + numlock: true, + } + } +} + +fn to_wstring(value: &str) -> Vec { + use std::os::windows::ffi::OsStrExt; + + std::ffi::OsStr::new(value) + .encode_wide() + .chain(std::iter::once(0)) + .collect() +} + +fn launch_website(url: &str) { + println!("Launch: {:?}", url); + use std::ptr::null_mut; + use winapi::um::shellapi::*; + use winapi::um::winuser::*; + let wurl = to_wstring(url); + let action = to_wstring("open"); + let ret = unsafe { + ShellExecuteW( + null_mut(), + action.as_ptr(), + wurl.as_ptr(), + null_mut(), + null_mut(), + SW_SHOWNORMAL, + ) + }; + // TODO: Sometimes it fails with 0x1F, which I think is SE_ERR_NOASSOC + // Not sure why, maybe just retry? + println!( + "Launch: done with {:?}, success: {:?}", + ret, + (ret as u8) > 32 + ); +} + +fn launch_tool(t: Tool) { + let path = match t { + Tool::QmkGui => r"C:\Program Files\Framework Computer\qmk_gui.exe", + Tool::LedmatrixControl => r"C:\Program Files\Framework Computer\ledmatrix_control.exe", + }; + // Tool keeps running independently, don't wait for it + #[allow(clippy::zombie_processes)] + Command::new(path).spawn().unwrap(); +} + +// Returns percentage if brightness changed +fn sync_keyboards(prev_brightness: &mut HashMap) -> Option { + match qmk_hid::new_hidapi() { + Ok(api) => { + let found = qmk_hid::find_devices(&api, false, false, Some("32ac"), None); + + let dev_infos = found.raw_usages; + + if dev_infos.len() <= 1 { + // No need to sync + return None; + } + + for dev_info in &dev_infos { + let device = dev_info.open_device(&api).unwrap(); + let white_brightness = + via::get_backlight(&device, via::ViaBacklightValue::Brightness as u8).unwrap(); + let rgb_brightness = + via::get_rgb_u8(&device, via::ViaRgbMatrixValue::Brightness as u8).unwrap(); + //println!("{:?}", dev_info.product_string()); + //println!(" RGB: {}/255 White: {}/255", rgb_brightness, white_brightness); + + let mut br_changed = false; + let mut rgb_br_changed = false; + + let path = dev_info.path(); + if let Some((prev_white, prev_rgb)) = prev_brightness.get(path) { + if white_brightness != *prev_white { + // println!("White changed from {} to {}", prev_white, white_brightness); + br_changed = true + } + if rgb_brightness != *prev_rgb { + // println!("RGB changed from {} to {}", prev_rgb, rgb_brightness); + rgb_br_changed = true + } + } + prev_brightness.insert(path.into(), (white_brightness, rgb_brightness)); + + if br_changed || rgb_br_changed { + // Update other keyboards + let new_brightness = if br_changed { + white_brightness + } else { + rgb_brightness + }; + // println!("Updating based on {:?}", dev_info.product_string()); + // println!(" Updating other keyboards to {}", new_brightness); + for other_info in &dev_infos { + if path == other_info.path() { + continue; + } + // println!(" Updating {:?}", other_info.product_string()); + { + let other_device = other_info.open_device(&api).unwrap(); + via::set_backlight( + &other_device, + via::ViaBacklightValue::Brightness as u8, + new_brightness, + ) + .unwrap(); + via::set_rgb_u8( + &other_device, + via::ViaRgbMatrixValue::Brightness as u8, + new_brightness, + ) + .unwrap(); + } + + // Avoid triggering an update in the other direction + // Need to read the value since the keyboard might only have 3 brightness levels, + // if that's the case, the value we set and the value the keyboard sets itself to are not the same. + // Seems we have to sleep a bit and also connect to the device again to make the change visible. + // TODO: Figure out why QMK changes the value also on the RGB which should have all 255 levels + thread::sleep(Duration::from_millis(100)); + { + let other_device = other_info.open_device(&api).unwrap(); + let actual_white = via::get_backlight( + &other_device, + via::ViaBacklightValue::Brightness as u8, + ) + .unwrap(); + let actual_rgb = via::get_rgb_u8( + &other_device, + via::ViaRgbMatrixValue::Brightness as u8, + ) + .unwrap(); + // println!(" Actually set to white: {}, rgb: {}", actual_white, actual_rgb); + prev_brightness + .insert(other_info.path().into(), (actual_white, actual_rgb)); + } + } + return Some((new_brightness as u32) * 100 / 255); + } + } + //println!(); + } + Err(e) => { + eprintln!("Error: {e}"); + } + } + None +} + +fn sync_keyboard_screen() { + println!("Sync"); + match qmk_hid::new_hidapi() { + Ok(api) => { + let found = qmk_hid::find_devices(&api, false, false, Some("32ac"), None); + + let dev_infos = found.raw_usages; + + let dev_info = if dev_infos.is_empty() { + println!("No device found"); + return; + } else if dev_infos.len() == 1 { + //println!("Found one device"); + dev_infos.first().unwrap() + } else { + println!("More than 1 device found. Select a specific device with --vid and --pid"); + dev_infos.first().unwrap() + }; + //println!("Open"); + let device = dev_info.open_device(&api).unwrap(); + //println!("Opened"); + + //println!("Get RGB"); + let rgb_brightness = + via::get_rgb_u8(&device, via::ViaRgbMatrixValue::Brightness as u8).unwrap(); + //println!("Get white"); + let white_brightness = + via::get_backlight(&device, via::ViaBacklightValue::Brightness as u8).unwrap(); + // println!("RGB: {}/255 White: {}/255", rgb_brightness, brightness); + + // TODO: In firmware it should sync both brightnesses + let pid = dev_info.product_id(); + let brightness = if pid == FrameworkPid::IsoKeyboard as u16 { + white_brightness + // } else if pid == FrameworkPid::Macropad as u16 { + // white_brightness + } else if pid == FrameworkPid::Macropad as u16 { + rgb_brightness + } else { + white_brightness + }; + + let percent = (brightness as u32) * 100 / 255; + println!("Brightness: {}/255, {}%", brightness, percent); + + let devs = brightness::blocking::brightness_devices(); + for dev in devs { + let dev = dev.unwrap(); + dev.set(percent).unwrap(); + } + } + Err(e) => { + eprintln!("Error: {e}"); + } + }; +} + +fn add_menu(menu: MenuBuilder, _icon: &'static [u8], nm: Events) -> MenuBuilder { + let (nm_str, nm_checked) = match nm { + Events::NumLockOff => ("Numlock Off (Arrow Keys)", false), + Events::NumLockOn => ("Numlock On (Number Keys)", true), + _ => ("???", false), + }; + #[cfg(feature = "lotus")] + let menu = menu + .submenu( + "Launch Inputmodule Apps", + MenuBuilder::new() + .item("Keyboard (VIA)", Events::LaunchVia) + .item("Keyboard (QMK GUI)", Events::LaunchQmkGui) + .item("LED Matrix", Events::LaunchLedmatrixControl), + ) + .separator(); + + // TODO + // .item("Sync keyboard brightness", Events::SyncKeyboards) + #[cfg(feature = "lotus")] + let menu = menu.item( + "Sync keyboard brightness with screen", + Events::SyncKeyboardScreen, + ); + + menu + //.separator() + .checkable(nm_str, nm_checked, Events::NumLockToggle) + //.with(MenuItem::Item { + // name: "Item Disabled".into(), + // disabled: true, // Disabled entry example + // id: Events::DisabledItem1, + // icon: Result::ok(Icon::from_buffer(icon, None, None)), + //}) + .separator() + .submenu( + "Framework Websites", + MenuBuilder::new() + .item("Marketplace", Events::LaunchMarketplace) + .item("Community", Events::LaunchCommunity) + .item("Knowledge Base", Events::LaunchKb) + .item("Guides", Events::LaunchGuides), + ) + .separator() + .item("E&xit", Events::Exit) +} + +/// Check if numlock is enabled +/// +/// Enabled means number mode, disabled means arrow mode +fn numlock_enabled() -> bool { + use winapi::um::winuser::*; + unsafe { GetKeyState(VK_NUMLOCK) == 1 } +} + +fn numlock_toggle() { + use winapi::um::winuser::*; + unsafe { + keybd_event(VK_NUMLOCK as u8, 0x3A, 0x1, 0); + keybd_event(VK_NUMLOCK as u8, 0x3A, 0x3, 0); + } +} + +#[allow(unused_imports)] +mod win_bindings { + ::windows::include_bindings!(); + pub use self::windows::win32::shell::SetCurrentProcessExplicitAppUserModelID; +} + +pub fn main() { + unsafe { + win_bindings::SetCurrentProcessExplicitAppUserModelID( + to_wstring("work.frame.tray").as_ptr(), + ) + .unwrap(); + } + Toast::new("work.frame.tray") + .title("Framework Tray Application") + .text1("Started") + .sound(None) + .duration(winrt_notification::Duration::Short) + .show() + .expect("unable to toast"); + + let (s, r) = std::sync::mpsc::channel::(); + let icon = LOGO_32_ICO; + // let icon2 = include_bytes!("icon2.ico"); + // let second_icon = Icon::from_buffer(icon2, None, None).unwrap(); + // let first_icon = Icon::from_buffer(icon, None, None).unwrap(); + + let periodic_s = s.clone(); + + // Needlessly complicated tray icon with all the whistles and bells + let mut tray_icon = TrayIconBuilder::new() + .sender(move |e: &Events| { + let _ = s.send(*e); + }) + .icon_from_buffer(icon) + .tooltip("Framework Computer") + .on_right_click(Events::RightClickTrayIcon) + .on_click(Events::LeftClickTrayIcon) + .on_double_click(Events::DoubleClickTrayIcon) + .menu(add_menu(MenuBuilder::new(), icon, Events::NumLockOn)) + .build() + .unwrap(); + + let mut prev_values = PrevValues::default(); + + std::thread::spawn(move || loop { + let numlock_state = numlock_enabled(); + if numlock_state != prev_values.numlock { + let text = if numlock_state { + periodic_s.send(Events::NumLockOn).unwrap(); + "Numlock enabled" + } else { + periodic_s.send(Events::NumLockOff).unwrap(); + "Numlock disabled" + }; + // TODO: Figure out our own Application User Model ID + Toast::new("work.frame.tray") + .title("Framework Keyboard") + .text1(text) + .sound(None) + .duration(winrt_notification::Duration::Short) + .show() + .expect("unable to toast"); + } + prev_values.numlock = numlock_state; + + //sync_keyboard_screen(); + if let Some(percentage) = sync_keyboards(&mut prev_values.brightness) { + let devs = brightness::blocking::brightness_devices(); + for dev in devs { + let dev = dev.unwrap(); + dev.set(percentage).unwrap(); + } + } + + thread::sleep(Duration::from_secs(1)); + }); + + std::thread::spawn(move || { + r.iter().for_each(|m| match m { + // About Popup + // FontAwesome Icon + // Events::About => {}, + Events::LaunchVia => launch_website(VIA_URL), + Events::LaunchQmkGui => launch_tool(Tool::QmkGui), + Events::LaunchLedmatrixControl => launch_tool(Tool::LedmatrixControl), + Events::LaunchMarketplace => launch_website(FWK_MARKETPLACE), + Events::LaunchCommunity => launch_website(FWK_COMMUNITY), + Events::LaunchKb => launch_website(FWK_KB), + Events::LaunchGuides => launch_website(FWK_GUIDES), + //Events::SyncKeyboards => sync_keyboards(), + Events::SyncKeyboardScreen => sync_keyboard_screen(), + + Events::DoubleClickTrayIcon => { + println!("Double click"); + #[cfg(feature = "lotus")] + { + let devs = brightness::blocking::brightness_devices(); + for dev in devs { + let dev = dev.unwrap(); + dev.set(50).unwrap(); + } + } + } + Events::RightClickTrayIcon => { + tray_icon.show_menu().unwrap(); + } + Events::LeftClickTrayIcon => { + println!("Single click"); + #[cfg(feature = "lotus")] + { + let devs = brightness::blocking::brightness_devices(); + for dev in devs { + // TODO: Skip unsupported monitors + let dev = dev.unwrap(); + println!("{:?}", dev.device_name()); + println!(" {:?}", dev.get()); + } + sync_keyboard_screen(); + } + tray_icon.show_menu().unwrap(); + } + Events::Exit => { + std::process::exit(0); + } + Events::NumLockToggle => { + numlock_toggle(); + } + Events::NumLockOn => { + //println!("Turning numlock on"); + tray_icon + .set_menu(&add_menu(MenuBuilder::new(), icon, Events::NumLockOn)) + .unwrap(); + } + Events::NumLockOff => { + //println!("Turning numlock off"); + tray_icon + .set_menu(&add_menu(MenuBuilder::new(), icon, Events::NumLockOff)) + .unwrap(); + } // Events::Item1 => { + // tray_icon.set_icon(&second_icon).unwrap(); + // } + // Events::Item2 => { + // tray_icon.set_icon(&first_icon).unwrap(); + // } + // e => { + // println!("{:?}", e); + // } + }) + }); + + // Your applications message loop. Because all applications require an + // application loop, you are best served using an `winit` crate. + loop { + unsafe { + let mut msg = MaybeUninit::uninit(); + let bret = winuser::GetMessageA(msg.as_mut_ptr(), 0 as _, 0, 0); + if bret > 0 { + winuser::TranslateMessage(msg.as_ptr()); + winuser::DispatchMessageA(msg.as_ptr()); + } else { + break; + } + } + } +} diff --git a/frameworkd/wix/main.wxs b/frameworkd/wix/main.wxs new file mode 100644 index 00000000..27428eb2 --- /dev/null +++ b/frameworkd/wix/main.wxs @@ -0,0 +1,254 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 1 + + + + + + + + + + + + + + + + + +