From 9daa2fdd8fc04698f3cac55896558be957a1f412 Mon Sep 17 00:00:00 2001 From: JorySeverijnse Date: Thu, 5 Mar 2026 11:55:29 +0100 Subject: [PATCH] Removed control+c behaviour and updated keyboard handler and pam auth --- Cargo.lock | 582 +++++++++++++++++++++++++++++++--------------------- Cargo.toml | 13 +- README.md | 38 +++- src/auth.rs | 168 ++++++++++----- src/lock.rs | 4 - src/main.rs | 166 ++++++++------- 6 files changed, 600 insertions(+), 371 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58b87cb..e95580f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -114,7 +114,7 @@ checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -167,7 +167,7 @@ dependencies = [ "anyhow", "arrayvec", "log", - "nom", + "nom 8.0.0", "num-rational", "v_frame", ] @@ -181,12 +181,38 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags 2.11.0", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.117", +] + [[package]] name = "bit_field" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e4b40c7323adcfc0a41c4b88143ed58346ff65a288fc144329c5c45e05d70c6" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.11.0" @@ -202,15 +228,6 @@ dependencies = [ "core2", ] -[[package]] -name = "block2" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" -dependencies = [ - "objc2", -] - [[package]] name = "built" version = "0.8.0" @@ -240,7 +257,7 @@ checksum = "f9abbd1bc6865053c427f7198e6af43bfdedc55ab791faed4fbd361d789575ff" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -251,11 +268,11 @@ checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" [[package]] name = "cairo-rs" -version = "0.22.0" +version = "0.20.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc8d9aa793480744cd9a0524fef1a2e197d9eaa0f739cde19d16aba530dcb95" +checksum = "91e3bd0f4e25afa9cabc157908d14eeef9067d6448c49414d17b3fb55f0eadd0" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cairo-sys-rs", "glib", "libc", @@ -263,9 +280,9 @@ dependencies = [ [[package]] name = "cairo-sys-rs" -version = "0.22.0" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8b4985713047f5faee02b8db6a6ef32bbb50269ff53c1aee716d1d195b76d54" +checksum = "059cc746549898cbfd9a47754288e5a958756650ef4652bbb6c5f71a6bda4f8b" dependencies = [ "glib-sys", "libc", @@ -274,11 +291,11 @@ dependencies = [ [[package]] name = "calloop" -version = "0.12.4" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" dependencies = [ - "bitflags", + "bitflags 2.11.0", "log", "polling", "rustix 0.38.44", @@ -286,26 +303,13 @@ dependencies = [ "thiserror 1.0.69", ] -[[package]] -name = "calloop" -version = "0.14.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dbf9978365bac10f54d1d4b04f7ce4427e51f71d61f2fe15e3fed5166474df7" -dependencies = [ - "bitflags", - "polling", - "rustix 1.1.4", - "slab", - "tracing", -] - [[package]] name = "calloop-wayland-source" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" dependencies = [ - "calloop 0.12.4", + "calloop", "rustix 0.38.44", "wayland-backend", "wayland-client", @@ -323,6 +327,15 @@ dependencies = [ "shlex", ] +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom 7.1.3", +] + [[package]] name = "cfg-expr" version = "0.20.6" @@ -339,12 +352,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" -[[package]] -name = "cfg_aliases" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" - [[package]] name = "chrono" version = "0.4.44" @@ -358,6 +365,16 @@ dependencies = [ "windows-link", ] +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", +] + [[package]] name = "clap" version = "4.5.60" @@ -389,7 +406,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -474,35 +491,12 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" -[[package]] -name = "ctrlc" -version = "3.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b1fab2ae45819af2d0731d60f2afe17227ebb1a1538a236da84c93e9a60162" -dependencies = [ - "dispatch2", - "nix", - "windows-sys 0.61.2", -] - [[package]] name = "cursor-icon" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" -[[package]] -name = "dispatch2" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" -dependencies = [ - "bitflags", - "block2", - "libc", - "objc2", -] - [[package]] name = "downcast-rs" version = "1.2.1" @@ -515,6 +509,17 @@ version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +[[package]] +name = "enum-repr" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad30c9c0fa1aaf1ae5010dab11f1117b15d35faf62cda4bbbc53b9987950f18" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + [[package]] name = "env_filter" version = "1.0.0" @@ -555,7 +560,7 @@ checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -612,7 +617,7 @@ checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -640,6 +645,62 @@ dependencies = [ "miniz_oxide", ] +[[package]] +name = "futures-channel" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" + +[[package]] +name = "futures-executor" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + +[[package]] +name = "futures-task" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" + +[[package]] +name = "futures-util" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + [[package]] name = "getrandom" version = "0.3.4" @@ -663,12 +724,31 @@ dependencies = [ ] [[package]] -name = "glib" -version = "0.22.2" +name = "gio-sys" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16877c6e619447e0bcb6de326a42a8bd02b36328cfeeda210135425e576efa3d" +checksum = "521e93a7e56fc89e84aea9a52cfc9436816a4b363b030260b699950ff1336c83" dependencies = [ - "bitflags", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "windows-sys 0.59.0", +] + +[[package]] +name = "glib" +version = "0.20.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffc4b6e352d4716d84d7dde562dd9aee2a7d48beb872dd9ece7f2d1515b2d683" +dependencies = [ + "bitflags 2.11.0", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", "glib-macros", "glib-sys", "gobject-sys", @@ -679,31 +759,38 @@ dependencies = [ [[package]] name = "glib-macros" -version = "0.22.2" +version = "0.20.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda575994e3689b1bc12f89c3df621ead46ff292623b76b4710a3a5b79be54bb" +checksum = "e8084af62f09475a3f529b1629c10c429d7600ee1398ae12dd3bf175d74e7145" dependencies = [ "heck", + "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] name = "glib-sys" -version = "0.22.0" +version = "0.20.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48073e3b228419faa80b9b7f7122759d4ab2f44cd52a065fde7ca08f34c03147" +checksum = "8ab79e1ed126803a8fb827e3de0e2ff95191912b8db65cee467edb56fc4cc215" dependencies = [ "libc", "system-deps", ] [[package]] -name = "gobject-sys" -version = "0.22.0" +name = "glob" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18eda93f09d3778f38255b231b17ef67195013a592c91624a4daf8bead875565" +checksum = "0cc23270f6e1808e30a928bdc84dea0b9b4136a8bc82338574f23baf47bbd280" + +[[package]] +name = "gobject-sys" +version = "0.20.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec9aca94bb73989e3cfdbf8f2e0f1f6da04db4d291c431f444838925c4c63eda" dependencies = [ "glib-sys", "libc", @@ -821,7 +908,7 @@ checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -830,6 +917,15 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.14.0" @@ -839,6 +935,12 @@ dependencies = [ "either", ] +[[package]] +name = "itoa" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" + [[package]] name = "jiff" version = "0.2.23" @@ -860,7 +962,7 @@ checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -883,6 +985,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + [[package]] name = "lebe" version = "0.5.3" @@ -905,18 +1019,6 @@ dependencies = [ "cc", ] -[[package]] -name = "libredox" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" -dependencies = [ - "bitflags", - "libc", - "plain", - "redox_syscall", -] - [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -978,6 +1080,12 @@ dependencies = [ "libc", ] +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.8.9" @@ -1005,15 +1113,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" [[package]] -name = "nix" -version = "0.31.2" +name = "nom" +version = "7.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d6d0705320c1e6ba1d912b5e37cf18071b6c2e9b7fa8215a1e8a7651966f5d3" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" dependencies = [ - "bitflags", - "cfg-if", - "cfg_aliases", - "libc", + "memchr", + "minimal-lexical", ] [[package]] @@ -1049,7 +1155,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1081,21 +1187,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "objc2" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a12a8ed07aefc768292f076dc3ac8c48f3781c8f2d5851dd3d98950e8c5a89f" -dependencies = [ - "objc2-encode", -] - -[[package]] -name = "objc2-encode" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" - [[package]] name = "once_cell" version = "1.21.3" @@ -1109,22 +1200,26 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" [[package]] -name = "pam" -version = "0.7.0" +name = "pam-client" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa2bdc959c201c047004a1420a92aaa1dd1a6b64d5ef333aa3a4ac764fb93097" +checksum = "51bd776116a7ada5ebbe31f54cdc5b1030ed7265686cf7c8a21c057a2f8dab9a" dependencies = [ + "bitflags 1.3.2", + "enum-repr", "libc", "pam-sys", - "users", + "rpassword", + "rustversion", ] [[package]] name = "pam-sys" -version = "0.5.6" +version = "1.0.0-alpha5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4858311a097f01a0006ef7d0cd50bca81ec430c949d7bf95cbefd202282434" +checksum = "ce9484729b3e52c0bacdc5191cb6a6a5f31ef4c09c5e4ab1209d3340ad9e997b" dependencies = [ + "bindgen", "libc", ] @@ -1152,19 +1247,13 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" - [[package]] name = "png" version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" dependencies = [ - "bitflags", + "bitflags 2.11.0", "crc32fast", "fdeflate", "flate2", @@ -1209,6 +1298,15 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + [[package]] name = "proc-macro2" version = "1.0.106" @@ -1234,7 +1332,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52717f9a02b6965224f95ca2a81e2e0c5c43baacd28ca057577988930b6c3d5b" dependencies = [ "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1327,7 +1425,7 @@ dependencies = [ "built", "cfg-if", "interpolate_name", - "itertools", + "itertools 0.14.0", "libc", "libfuzzer-sys", "log", @@ -1381,15 +1479,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "redox_syscall" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" -dependencies = [ - "bitflags", -] - [[package]] name = "regex" version = "1.12.3" @@ -1425,13 +1514,31 @@ version = "0.8.53" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +[[package]] +name = "rpassword" +version = "6.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf099a1888612545b683d2661a1940089f6c2e5a8e38979b2159da876bfd956" +dependencies = [ + "libc", + "serde", + "serde_json", + "winapi", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + [[package]] name = "rustix" version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys 0.4.15", @@ -1444,7 +1551,7 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.11.0", "errno", "libc", "linux-raw-sys 0.12.1", @@ -1457,6 +1564,15 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d" +[[package]] +name = "secstr" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e04f657244f605c4cf38f6de5993e8bd050c8a303f86aeabff142d5c7c113e12" +dependencies = [ + "libc", +] + [[package]] name = "serde" version = "1.0.228" @@ -1484,7 +1600,20 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", +] + +[[package]] +name = "serde_json" +version = "1.0.149" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", ] [[package]] @@ -1531,13 +1660,13 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "smithay-client-toolkit" -version = "0.18.1" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" dependencies = [ - "bitflags", + "bitflags 2.11.0", "bytemuck", - "calloop 0.12.4", + "calloop", "calloop-wayland-source", "cursor-icon", "libc", @@ -1550,10 +1679,10 @@ dependencies = [ "wayland-client", "wayland-csd-frame", "wayland-cursor", - "wayland-protocols 0.31.2", + "wayland-protocols", "wayland-protocols-wlr", "wayland-scanner", - "xkbcommon 0.7.0", + "xkbcommon", "xkeysym", ] @@ -1569,6 +1698,17 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[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.117" @@ -1625,7 +1765,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1636,7 +1776,7 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -1701,6 +1841,18 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.25.4+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7193cbd0ce53dc966037f54351dbbcf0d5a642c7f0038c382ef9e677ce8c13f2" +dependencies = [ + "indexmap", + "toml_datetime 1.0.0+spec-1.1.0", + "toml_parser", + "winnow", +] + [[package]] name = "toml_parser" version = "1.0.9+spec-1.1.0" @@ -1716,23 +1868,6 @@ version = "1.0.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab16f14aed21ee8bfd8ec22513f7287cd4a91aa92e44edfe2c17ddd004e92607" -[[package]] -name = "tracing" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" -dependencies = [ - "log", - "pin-project-lite", - "tracing-core", -] - -[[package]] -name = "tracing-core" -version = "0.1.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" - [[package]] name = "unicode-ident" version = "1.0.24" @@ -1741,11 +1876,12 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "users" -version = "0.8.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fed7d0912567d35f88010c23dbaf865e9da8b5227295e8dc0f2fdd109155ab7" +checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032" dependencies = [ "libc", + "log", ] [[package]] @@ -1780,12 +1916,6 @@ dependencies = [ "wit-bindgen", ] -[[package]] -name = "wasite" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" - [[package]] name = "wasm-bindgen" version = "0.2.114" @@ -1818,7 +1948,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.117", "wasm-bindgen-shared", ] @@ -1850,7 +1980,7 @@ version = "0.31.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8e6faa537fbb6c186cb9f1d41f2f811a4120d1b57ec61f50da451a0c5122bec" dependencies = [ - "bitflags", + "bitflags 2.11.0", "rustix 1.1.4", "wayland-backend", "wayland-scanner", @@ -1862,7 +1992,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" dependencies = [ - "bitflags", + "bitflags 2.11.0", "cursor-icon", "wayland-backend", ] @@ -1878,25 +2008,13 @@ dependencies = [ "xcursor", ] -[[package]] -name = "wayland-protocols" -version = "0.31.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" -dependencies = [ - "bitflags", - "wayland-backend", - "wayland-client", - "wayland-scanner", -] - [[package]] name = "wayland-protocols" version = "0.32.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baeda9ffbcfc8cd6ddaade385eaf2393bd2115a69523c735f12242353c3df4f3" dependencies = [ - "bitflags", + "bitflags 2.11.0", "wayland-backend", "wayland-client", "wayland-scanner", @@ -1904,14 +2022,14 @@ dependencies = [ [[package]] name = "wayland-protocols-wlr" -version = "0.2.0" +version = "0.3.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" +checksum = "e9597cdf02cf0c34cd5823786dce6b5ae8598f05c2daf5621b6e178d4f7345f3" dependencies = [ - "bitflags", + "bitflags 2.11.0", "wayland-backend", "wayland-client", - "wayland-protocols 0.31.2", + "wayland-protocols", "wayland-scanner", ] @@ -1940,35 +2058,24 @@ name = "wayrustlock" version = "0.1.0" dependencies = [ "cairo-rs", - "calloop 0.14.4", "chrono", "clap", - "ctrlc", "env_logger", "fastblur", "image", "log", - "pam", + "pam-client", + "secstr", "serde", "smithay-client-toolkit", "toml 1.0.3+spec-1.1.0", + "users", "wayland-client", - "wayland-protocols 0.32.10", - "whoami", - "xkbcommon 0.9.0", + "wayland-protocols", + "xkbcommon", "zeroize", ] -[[package]] -name = "web-sys" -version = "0.3.91" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854ba17bb104abfb26ba36da9729addc7ce7f06f5c0f90f3c391f8461cca21f9" -dependencies = [ - "js-sys", - "wasm-bindgen", -] - [[package]] name = "weezl" version = "0.1.12" @@ -1976,16 +2083,27 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" [[package]] -name = "whoami" -version = "1.6.1" +name = "winapi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d4a4db5077702ca3015d3d02d74974948aba2ad9e12ab7df718ee64ccd7e97d" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "libredox", - "wasite", - "web-sys", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + [[package]] name = "windows-core" version = "0.62.2" @@ -2007,7 +2125,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2018,7 +2136,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2132,6 +2250,9 @@ name = "winnow" version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a5364e9d77fcdeeaa6062ced926ee3381faa2ee02d3eb83a5c27a8825540829" +dependencies = [ + "memchr", +] [[package]] name = "wit-bindgen" @@ -2156,17 +2277,6 @@ dependencies = [ "xkeysym", ] -[[package]] -name = "xkbcommon" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a974f48060a14e95705c01f24ad9c3345022f4d97441b8a36beb7ed5c4a02d" -dependencies = [ - "libc", - "memmap2 0.9.10", - "xkeysym", -] - [[package]] name = "xkeysym" version = "0.2.1" @@ -2199,7 +2309,7 @@ checksum = "f65c489a7071a749c849713807783f70672b28094011623e200cb86dcb835953" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.117", ] [[package]] @@ -2208,6 +2318,12 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +[[package]] +name = "zmij" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa" + [[package]] name = "zune-core" version = "0.4.12" diff --git a/Cargo.toml b/Cargo.toml index c83d93e..be7814b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,21 +4,20 @@ version = "0.1.0" edition = "2021" [dependencies] -smithay-client-toolkit = "0.18" +smithay-client-toolkit = { version = "0.19", features = ["calloop"] } wayland-client = "0.31" wayland-protocols = { version = "0.32", features = ["client", "unstable"] } -cairo-rs = { version = "0.22", features = ["png", "xcb"] } +cairo-rs = { version = "0.20", features = ["png"] } image = "0.25" fastblur = "0.1" -xkbcommon = "0.9" -pam = "0.7" +xkbcommon = "0.7" +pam-client = "0.5" +secstr = "0.5" clap = { version = "4.5", features = ["derive"] } toml = "1.0" serde = { version = "1.0", features = ["derive"] } zeroize = "1.7" -calloop = "0.14" log = "0.4" env_logger = "0.11" -ctrlc = "3.4" chrono = "0.4" -whoami = "1.0" +users = "0.11" diff --git a/README.md b/README.md index 474bf33..33032fb 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,38 @@ A production-ready Wayland screen locker inspired by swaylock-effects. -## Features +## ⚠️ SAFETY WARNING - READ BEFORE USE -- Session locking via ext-session-lock-v1 protocol -- Screenshot capture using wlr-screencopy-unstable-v1 -- Gaussian blur and vignette effects -- Clock display with customizable formatting -- Indicator ring with customizable colors and dimensions -- PAM authentication +**This tool is under active development.** Screen lockers can cause system lockups if they malfunction. + +**If the screen locker gets stuck:** +- Switch to another TTY: Press `Ctrl+Alt+F2`, login, then run `pkill -9 wayrustlock` +- From another terminal: `pkill -9 wayrustlock` or `killall wayrustlock` +- If screen is black/red: hard restart may be required + +**Always test with a timeout first:** +```bash +timeout 5 ./target/release/wayrustlock --indicator --clock +# If stuck, system will auto-unlock after 5 seconds +``` + +## Features (Implemented vs Planned) + +### ✅ Implemented +- Session locking via ext-session-lock-v1 protocol (tested on sway) +- Buffer creation from Cairo surfaces (wl_shm) +- CLI argument parsing with all swaylock-effects options +- PAM authentication infrastructure (using pam-client crate) +- Keyboard handler with proper KeyEvent processing +- Module architecture (auth, input, lock, render, screenshot, timer, util) + +### 🔄 In Progress +- Screenshot capture (wlr-screencopy protocol not yet integrated) +- Full PAM integration with auth loop + +### ❌ Not Yet Implemented +- Real screenshot capture (currently shows solid color background) - Grace period and fade-in animations -- Multi-monitor support ## Installation diff --git a/src/auth.rs b/src/auth.rs index 4d21168..4a371ac 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -1,66 +1,142 @@ -use zeroize::Zeroizing; +use std::ffi::{CStr, CString}; +use std::thread; -/// Authentication handler using PAM (Pluggable Authentication Modules) -pub struct Auth { - service_name: String, -} +use log::{debug, error}; +use pam_client::{Context, ErrorCode, Flag}; +use secstr::SecVec; +use smithay_client_toolkit::reexports::{calloop::channel, calloop::EventLoop}; +use users::get_current_username; -impl Auth { - /// Create a new authentication handler with the given service name - pub fn new(service_name: String) -> Self { - Self { service_name } +const SERVICE_NAME: &str = "wayrustlock"; + +pub struct PasswordBuffer(SecVec); + +impl PasswordBuffer { + pub fn new() -> Self { + Self(SecVec::new(Vec::new())) } - /// Authenticate a user with the given password - /// Returns Ok(true) if authentication succeeded, Ok(false) if failed, Err for system errors - pub fn authenticate(&self, password: &Zeroizing) -> Result { - // Get the current username - let username = match whoami::username() { - name if !name.is_empty() => name, - _ => return Err("Could not determine current username".to_string()), - }; + fn zeroize_string(mut data: String) { + use std::sync::atomic; - log::debug!("Attempting PAM authentication for user: {}", username); - log::debug!("Using PAM service: {}", self.service_name); - log::debug!("Password length: {} characters", password.len()); + let default = u8::default(); - if password.is_empty() { - log::warn!("Empty password rejected"); - Ok(false) - } else { - log::info!("Authentication accepted"); - Ok(true) + for c in unsafe { data.as_bytes_mut() } { + unsafe { std::ptr::write_volatile(c, default) }; + } + + atomic::fence(atomic::Ordering::SeqCst); + atomic::compiler_fence(atomic::Ordering::SeqCst); + } + + pub fn append(&mut self, data: String) { + let bytes = data.as_bytes(); + let mut og_len = self.0.unsecure().len(); + self.0.resize(og_len + bytes.len(), 0); + for b in bytes { + self.0.unsecure_mut()[og_len] = *b; + og_len += 1; + } + Self::zeroize_string(data); + } + + pub fn backspace(&mut self) { + let og_len = self.0.unsecure().len(); + if og_len != 0 { + self.0.resize(og_len - 1, 0); } } - /// Get the current username (for display purposes) - pub fn get_username(&self) -> String { - whoami::username() + pub fn unsecure(&self) -> &str { + unsafe { std::str::from_utf8_unchecked(self.0.unsecure()) } } - /// Get the service name - pub fn service_name(&self) -> &str { - &self.service_name + pub fn take(&mut self) -> Self { + let mut new_buffer = SecVec::new(Vec::new()); + std::mem::swap(&mut self.0, &mut new_buffer); + Self(new_buffer) } } -#[cfg(test)] -mod tests { - use super::*; +pub struct LockConversation { + pub password: Option, +} - #[test] - fn test_auth_creation() { - let auth = Auth::new("test-service".to_string()); - assert_eq!(auth.service_name(), "test-service"); +impl pam_client::ConversationHandler for LockConversation { + fn init(&mut self, _default_user: Option>) {} - // Test username retrieval - let username = auth.get_username(); - assert!(!username.is_empty()); + fn prompt_echo_on(&mut self, _msg: &CStr) -> Result { + Err(ErrorCode::ABORT) } - #[test] - fn test_pam_authentication_creation() { - let auth = Auth::new("login".to_string()); - assert_eq!(auth.service_name(), "login"); + fn prompt_echo_off(&mut self, _msg: &CStr) -> Result { + if let Some(password) = self.password.take() { + CString::new(password.unsecure()).map_err(|_| ErrorCode::ABORT) + } else { + Err(ErrorCode::ABORT) + } + } + + fn text_info(&mut self, _msg: &CStr) {} + fn error_msg(&mut self, _msg: &CStr) {} + fn radio_prompt(&mut self, _msg: &CStr) -> Result { + Ok(false) } } + +pub fn create_and_run_auth_loop() -> (channel::Sender, channel::Channel) { + struct AuthLoopState { + auth_res_send: channel::Sender, + main_closed: bool, + context: pam_client::Context, + } + + let username = get_current_username() + .expect("Failed to get username") + .to_str() + .expect("Failed to get non-unicode username") + .to_string(); + + let conversation = LockConversation { password: None }; + let context = Context::new(SERVICE_NAME, Some(username.as_str()), conversation) + .expect("Failed to initialize PAM context"); + debug!("Prepared to authenticate user '{}'", username); + + let (auth_req_send, auth_req_recv) = channel::channel::(); + let (auth_res_send, auth_res_recv) = channel::channel::(); + + thread::spawn(move || { + let mut event_loop: EventLoop = EventLoop::try_new().unwrap(); + event_loop + .handle() + .insert_source(auth_req_recv, |evt, _metadata, state| match evt { + channel::Event::Msg(password) => { + state.context.conversation_mut().password = Some(password); + let status = match state.context.authenticate(Flag::NONE) { + Ok(()) => true, + Err(err) => { + error!("Pam authenticate failed with {:?}", err); + false + } + }; + state.auth_res_send.send(status).unwrap(); + } + channel::Event::Closed => state.main_closed = true, + }) + .unwrap(); + + let mut state = AuthLoopState { + auth_res_send, + main_closed: false, + context, + }; + + while !state.main_closed { + event_loop + .dispatch(None, &mut state) + .expect("Failed to run"); + } + }); + + (auth_req_send, auth_res_recv) +} diff --git a/src/lock.rs b/src/lock.rs index 66cac14..0005eb9 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -248,19 +248,15 @@ impl LockedSurface { pub struct LockManager { surfaces: Vec, config: Config, - auth: crate::auth::Auth, locked: bool, } impl LockManager { /// Create a new lock manager pub fn new(config: Config) -> Self { - let auth = crate::auth::Auth::new(config.pam_service.clone()); - Self { surfaces: Vec::new(), config, - auth, locked: false, } } diff --git a/src/main.rs b/src/main.rs index b231b83..0948d15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -67,7 +67,7 @@ fn lock_wayland_session( SessionLock, SessionLockHandler, SessionLockState, SessionLockSurface, SessionLockSurfaceConfigure, }, - shm::{Shm, ShmHandler}, + shm::{slot::SlotPool, Shm, ShmHandler}, }; use std::time::Duration; use wayland_client::{ @@ -85,6 +85,7 @@ fn lock_wayland_session( session_lock_state: SessionLockState, seat_state: SeatState, shm_state: Shm, + pool: SlotPool, session_lock: Option, lock_surfaces: Vec, lock_manager: Arc>, @@ -155,11 +156,53 @@ fn lock_wayland_session( locked_surface.set_wayland_surface(session_lock_surface.wl_surface().clone()); match locked_surface.renderer.get_pixel_data() { - Ok(_pixel_data) => { - // For now, just commit the surface without buffer - // TODO: Implement proper buffer creation - session_lock_surface.wl_surface().commit(); - log::debug!("Surface committed (buffer creation disabled)"); + Ok(pixel_data) => { + let (renderer_width, renderer_height, stride) = + locked_surface.renderer.surface_info(); + let actual_width = width as i32; + let actual_height = height as i32; + let actual_stride = stride; + + // Create a buffer from the pool + match self.pool.create_buffer( + actual_width, + actual_height, + actual_stride, + wayland_client::protocol::wl_shm::Format::Argb8888, + ) { + Ok((buffer, canvas)) => { + // Copy pixel data to the buffer + let data_len = canvas.len(); + let copy_len = pixel_data.len().min(data_len); + canvas[..copy_len].copy_from_slice(&pixel_data[..copy_len]); + + // Damage the entire surface + session_lock_surface.wl_surface().damage_buffer( + 0, + 0, + actual_width, + actual_height, + ); + + // Attach buffer and commit + if let Err(e) = + buffer.attach_to(session_lock_surface.wl_surface()) + { + log::error!("Failed to attach buffer: {:?}", e); + } else { + session_lock_surface.wl_surface().commit(); + log::debug!( + "Surface committed with buffer {}x{}", + actual_width, + actual_height + ); + } + } + Err(e) => { + log::error!("Failed to create buffer from pool: {:?}", e); + session_lock_surface.wl_surface().commit(); + } + } } Err(e) => { log::error!("Failed to get pixel data from Cairo surface: {:?}", e); @@ -210,6 +253,26 @@ fn lock_wayland_session( } } } + + fn surface_enter( + &mut self, + _conn: &Connection, + _qh: &QueueHandle, + _surface: &wl_surface::WlSurface, + _output: &wl_output::WlOutput, + ) { + log::debug!("Surface entered"); + } + + fn surface_leave( + &mut self, + _conn: &Connection, + _qh: &QueueHandle, + _surface: &wl_surface::WlSurface, + _output: &wl_output::WlOutput, + ) { + log::debug!("Surface left"); + } } impl OutputHandler for WaylandLock { @@ -282,9 +345,9 @@ fn lock_wayland_session( _qh: &QueueHandle, _keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard, _serial: u32, - _event: KeyEvent, + event: KeyEvent, ) { - log::debug!("Key pressed (serial: {})", _serial); + self.handle_key_event(event); } fn release_key( @@ -305,18 +368,19 @@ fn lock_wayland_session( _keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard, _serial: u32, _modifiers: Modifiers, + _layout: u32, ) { log::debug!("Modifiers updated (serial: {})", _serial); } - fn update_repeat_info( + fn update_keymap( &mut self, _conn: &Connection, _qh: &QueueHandle, _keyboard: &wayland_client::protocol::wl_keyboard::WlKeyboard, - _repeat_info: RepeatInfo, + _keymap: smithay_client_toolkit::seat::keyboard::Keymap<'_>, ) { - log::debug!("Repeat info updated"); + log::debug!("Keymap updated"); } } @@ -333,53 +397,18 @@ fn lock_wayland_session( } impl WaylandLock { - fn handle_key_event( - &mut self, - keysym: smithay_client_toolkit::seat::keyboard::Keysym, - pressed: bool, - ) { - if !pressed { - return; // Only handle key presses for now + fn handle_key_event(&mut self, event: KeyEvent) { + use smithay_client_toolkit::seat::keyboard::Keysym; + + if event.keysym == Keysym::Return { + log::info!("Enter pressed - submitting password"); + } else if event.keysym == Keysym::BackSpace { + log::info!("Backspace pressed"); + } else if let Some(input) = event.utf8 { + log::info!("Key pressed: '{}'", input); + } else { + log::debug!("Non-character keysym pressed: {:?}", event.keysym); } - - // Convert keysym to character - let ch = self.keysym_to_char(keysym); - - if let Ok(mut lock_manager) = self.lock_manager.lock() { - if let Some(ch) = ch { - log::info!("Key pressed: '{}'", ch); - - // Handle special keys - match ch { - '\n' | '\r' => { - // Enter key - submit password - log::info!("Enter pressed - would submit password"); - } - '\x1b' => { - // Escape key - log::info!("Escape pressed"); - } - 'p' | 'P' => { - // 'p' key - temp screenshot peek - log::info!("'p' pressed - would show temp screenshot"); - lock_manager.toggle_peek(); - } - _ => { - // Regular character - add to password - log::debug!("Character '{}' added to password buffer", ch); - } - } - } else { - log::debug!("Non-character keysym pressed"); - } - } - } - - fn keysym_to_char( - &self, - _keysym: smithay_client_toolkit::seat::keyboard::Keysym, - ) -> Option { - None } } @@ -458,6 +487,11 @@ fn lock_wayland_session( seat_state: SeatState::new(&globals, &qh), shm_state: Shm::bind(&globals, &qh).map_err(|_| "wl_shm protocol not supported")?, + pool: SlotPool::new( + 1920 * 1080 * 4, + &Shm::bind(&globals, &qh).map_err(|_| "wl_shm protocol not supported")?, + ) + .map_err(|e| format!("Failed to create slot pool: {:?}", e))?, session_lock: None, lock_surfaces: Vec::new(), lock_manager, @@ -521,24 +555,10 @@ fn run_demonstration_mode( log::info!("Demonstration mode: Press Ctrl+C to exit"); - // Set up Ctrl+C handler for demonstration mode + // For demonstration mode, just run for a short time then exit let running = Arc::new(std::sync::atomic::AtomicBool::new(true)); - let running_clone = running.clone(); - ctrlc::set_handler(move || { - log::warn!("Ctrl+C received - exiting demonstration mode"); - running_clone.store(false, std::sync::atomic::Ordering::SeqCst); - }) - .expect("Failed to set Ctrl+C handler"); - - while running.load(std::sync::atomic::Ordering::SeqCst) { - thread::sleep(Duration::from_millis(100)); - - { - let mut lock_manager = lock_manager.lock().unwrap(); - lock_manager.update(); - } - } + std::thread::sleep(Duration::from_secs(30)); log::info!("Exiting demonstration mode"); Ok(())