diff --git a/Cargo.lock b/Cargo.lock index 70f1852..675f718 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -617,6 +617,16 @@ dependencies = [ "libc", ] +[[package]] +name = "core-foundation" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b55271e5c8c478ad3f38ad24ef34923091e0548492a266d19b3c0b4d82574c63" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "core-foundation-sys" version = "0.8.7" @@ -625,27 +635,27 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "core-graphics" -version = "0.22.3" +version = "0.23.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" dependencies = [ "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.3.2", + "core-foundation 0.9.4", + "core-graphics-types 0.1.3", + "foreign-types", "libc", ] [[package]] name = "core-graphics" -version = "0.23.2" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +checksum = "fa95a34622365fa5bbf40b20b75dba8dfa8c94c734aea8ac9a5ca38af14316f1" dependencies = [ - "bitflags 1.3.2", - "core-foundation", - "core-graphics-types", - "foreign-types 0.5.0", + "bitflags 2.6.0", + "core-foundation 0.10.0", + "core-graphics-types 0.2.0", + "foreign-types", "libc", ] @@ -656,7 +666,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" dependencies = [ "bitflags 1.3.2", - "core-foundation", + "core-foundation 0.9.4", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d44a101f213f6c4cdc1853d4b78aef6db6bdfa3468798cc1d9912f4735013eb" +dependencies = [ + "bitflags 2.6.0", + "core-foundation 0.10.0", "libc", ] @@ -666,9 +687,9 @@ version = "20.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9d2790b5c08465d49f8dc05c8bcae9fea467855947db39b0f8145c091aaced5" dependencies = [ - "core-foundation", + "core-foundation 0.9.4", "core-graphics 0.23.2", - "foreign-types 0.5.0", + "foreign-types", "libc", ] @@ -823,20 +844,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "display-info" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ba4b5ddb26d674c9cd40b7a747e42658ffe1289843615b838532f660e0e3dd0" -dependencies = [ - "anyhow", - "core-graphics 0.23.2", - "fxhash", - "widestring", - "windows 0.52.0", - "xcb", -] - [[package]] name = "dlib" version = "0.5.2" @@ -1026,7 +1033,7 @@ checksum = "b64b34f4efd515f905952d91bc185039863705592c0c53ae6d979805dd154520" dependencies = [ "bitflags 2.6.0", "byteorder", - "core-foundation", + "core-foundation 0.9.4", "core-graphics 0.23.2", "core-text", "dirs", @@ -1043,15 +1050,6 @@ dependencies = [ "yeslogic-fontconfig-sys", ] -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared 0.1.1", -] - [[package]] name = "foreign-types" version = "0.5.0" @@ -1059,7 +1057,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" dependencies = [ "foreign-types-macros", - "foreign-types-shared 0.3.1", + "foreign-types-shared", ] [[package]] @@ -1073,12 +1071,6 @@ dependencies = [ "syn", ] -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "foreign-types-shared" version = "0.3.1" @@ -1158,15 +1150,6 @@ dependencies = [ "slab", ] -[[package]] -name = "fxhash" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" -dependencies = [ - "byteorder", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1238,12 +1221,6 @@ 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 = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - [[package]] name = "hermit-abi" version = "0.4.0" @@ -1284,13 +1261,7 @@ dependencies = [ "bytemuck", "byteorder", "color_quant", - "exr", - "gif", - "jpeg-decoder", "num-traits", - "png", - "qoi", - "tiff", ] [[package]] @@ -1377,17 +1348,6 @@ dependencies = [ "syn", ] -[[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.1" @@ -1423,9 +1383,6 @@ name = "jpeg-decoder" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" -dependencies = [ - "rayon", -] [[package]] name = "js-sys" @@ -1501,22 +1458,6 @@ dependencies = [ "libc", ] -[[package]] -name = "libwayshot" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "896d0e594158b7f5188034836a6c4886492078352c39760786e54f1b796caaea" -dependencies = [ - "image 0.24.9", - "log", - "memmap2 0.7.1", - "nix 0.26.4", - "thiserror", - "wayland-client 0.30.2", - "wayland-protocols 0.30.1", - "wayland-protocols-wlr 0.1.0", -] - [[package]] name = "libwayshot" version = "0.3.0" @@ -1525,12 +1466,12 @@ checksum = "a2efa01ecfd021b1e7db27f21f4e79b35b048081c9cae9d2f898eddc98444d69" dependencies = [ "image 0.24.9", "log", - "memmap2 0.9.4", + "memmap2", "nix 0.27.1", "thiserror", - "wayland-client 0.31.5", - "wayland-protocols 0.31.2", - "wayland-protocols-wlr 0.2.0", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", ] [[package]] @@ -1649,15 +1590,6 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" -[[package]] -name = "memmap2" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f49388d20533534cd19360ad3d6a7dadc885944aa802ba3995040c5ec11288c6" -dependencies = [ - "libc", -] - [[package]] name = "memmap2" version = "0.9.4" @@ -1667,15 +1599,6 @@ dependencies = [ "libc", ] -[[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" @@ -1763,19 +1686,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" -[[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", - "pin-utils", -] - [[package]] name = "nix" version = "0.27.1" @@ -1809,7 +1719,7 @@ dependencies = [ "cfg-if", "cfg_aliases 0.2.1", "libc", - "memoffset 0.9.1", + "memoffset", ] [[package]] @@ -1843,6 +1753,15 @@ dependencies = [ "zbus", ] +[[package]] +name = "ntapi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a3895c6391c39d7fe7ebc444a87eb2991b2a0bc718fdabd071eec617fc68e4" +dependencies = [ + "winapi", +] + [[package]] name = "nu-ansi-term" version = "0.46.0" @@ -2289,7 +2208,7 @@ checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", - "hermit-abi 0.4.0", + "hermit-abi", "pin-project-lite", "rustix", "tracing", @@ -2374,15 +2293,6 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" -[[package]] -name = "quick-xml" -version = "0.28.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce5e73202a820a31f8a0ee32ada5e21029c81fd9e3ebf668a40832e4219d9d1" -dependencies = [ - "memchr", -] - [[package]] name = "quick-xml" version = "0.30.0" @@ -2680,25 +2590,6 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "screenshots" -version = "0.8.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038df8746dbf7d8b70715d638470db956794e0f3d08608e4197f4053c2da1620" -dependencies = [ - "anyhow", - "core-graphics 0.22.3", - "dbus", - "display-info", - "fxhash", - "image 0.24.9", - "libwayshot 0.2.0", - "percent-encoding", - "widestring", - "windows 0.51.1", - "xcb", -] - [[package]] name = "semver" version = "1.0.23" @@ -2851,16 +2742,16 @@ dependencies = [ "clap", "color-eyre", "directories", - "libwayshot 0.3.0", + "libwayshot", "merge2", "mouse_position", - "screenshots", "serde", "sss_lib", "thiserror", "toml", "tracing", "tracing-subscriber", + "xcap", ] [[package]] @@ -2944,6 +2835,20 @@ dependencies = [ "yaml-rust", ] +[[package]] +name = "sysinfo" +version = "0.31.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be" +dependencies = [ + "core-foundation-sys", + "libc", + "memchr", + "ntapi", + "rayon", + "windows 0.56.0", +] + [[package]] name = "system-deps" version = "6.2.2" @@ -3221,7 +3126,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ - "memoffset 0.9.1", + "memoffset", "tempfile", "winapi", ] @@ -3364,21 +3269,6 @@ version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" -[[package]] -name = "wayland-backend" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41b48e27457e8da3b2260ac60d0a94512f5cba36448679f3747c0865b7893ed8" -dependencies = [ - "cc", - "downcast-rs", - "io-lifetimes", - "nix 0.26.4", - "scoped-tls", - "smallvec", - "wayland-sys 0.30.1", -] - [[package]] name = "wayland-backend" version = "0.3.6" @@ -3390,19 +3280,7 @@ dependencies = [ "rustix", "scoped-tls", "smallvec", - "wayland-sys 0.31.4", -] - -[[package]] -name = "wayland-client" -version = "0.30.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "489c9654770f674fc7e266b3c579f4053d7551df0ceb392f153adb1f9ed06ac8" -dependencies = [ - "bitflags 1.3.2", - "nix 0.26.4", - "wayland-backend 0.1.2", - "wayland-scanner 0.30.1", + "wayland-sys", ] [[package]] @@ -3413,20 +3291,8 @@ checksum = "7e321577a0a165911bdcfb39cf029302479d7527b517ee58ab0f6ad09edf0943" dependencies = [ "bitflags 2.6.0", "rustix", - "wayland-backend 0.3.6", - "wayland-scanner 0.31.4", -] - -[[package]] -name = "wayland-protocols" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b28101e5ca94f70461a6c2d610f76d85ad223d042dd76585ab23d3422dd9b4d" -dependencies = [ - "bitflags 1.3.2", - "wayland-backend 0.1.2", - "wayland-client 0.30.2", - "wayland-scanner 0.30.1", + "wayland-backend", + "wayland-scanner", ] [[package]] @@ -3436,22 +3302,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" dependencies = [ "bitflags 2.6.0", - "wayland-backend 0.3.6", - "wayland-client 0.31.5", - "wayland-scanner 0.31.4", -] - -[[package]] -name = "wayland-protocols-wlr" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fce991093320e4a6a525876e6b629ab24da25f9baef0c2e0080ad173ec89588a" -dependencies = [ - "bitflags 1.3.2", - "wayland-backend 0.1.2", - "wayland-client 0.30.2", - "wayland-protocols 0.30.1", - "wayland-scanner 0.30.1", + "wayland-backend", + "wayland-client", + "wayland-scanner", ] [[package]] @@ -3461,21 +3314,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" dependencies = [ "bitflags 2.6.0", - "wayland-backend 0.3.6", - "wayland-client 0.31.5", - "wayland-protocols 0.31.2", - "wayland-scanner 0.31.4", -] - -[[package]] -name = "wayland-scanner" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9b873b257fbc32ec909c0eb80dea312076a67014e65e245f5eb69a6b8ab330e" -dependencies = [ - "proc-macro2", - "quick-xml 0.28.2", - "quote", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", ] [[package]] @@ -3489,17 +3331,6 @@ dependencies = [ "quote", ] -[[package]] -name = "wayland-sys" -version = "0.30.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06" -dependencies = [ - "dlib", - "log", - "pkg-config", -] - [[package]] name = "wayland-sys" version = "0.31.4" @@ -3527,12 +3358,6 @@ dependencies = [ "safe_arch", ] -[[package]] -name = "widestring" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" - [[package]] name = "winapi" version = "0.3.9" @@ -3566,69 +3391,76 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" -version = "0.51.1" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca229916c5ee38c2f2bc1e9d8f04df975b4bd93f9955dc69fabb5d91270045c9" +checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" dependencies = [ - "windows-core 0.51.1", - "windows-targets 0.48.5", + "windows-core 0.56.0", + "windows-targets 0.52.6", ] [[package]] name = "windows" -version = "0.52.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" +checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6" dependencies = [ - "windows-core 0.52.0", + "windows-core 0.58.0", "windows-targets 0.52.6", ] [[package]] -name = "windows" +name = "windows-core" version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" +checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" dependencies = [ - "windows-core 0.56.0", + "windows-implement 0.56.0", + "windows-interface 0.56.0", + "windows-result 0.1.2", "windows-targets 0.52.6", ] [[package]] name = "windows-core" -version = "0.51.1" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" +checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99" dependencies = [ - "windows-targets 0.48.5", + "windows-implement 0.58.0", + "windows-interface 0.58.0", + "windows-result 0.2.0", + "windows-strings", + "windows-targets 0.52.6", ] [[package]] -name = "windows-core" -version = "0.52.0" +name = "windows-implement" +version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ - "windows-targets 0.52.6", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "windows-core" -version = "0.56.0" +name = "windows-implement" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4698e52ed2d08f8658ab0c39512a7c00ee5fe2688c65f8c0a4f06750d729f2a6" +checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b" dependencies = [ - "windows-implement", - "windows-interface", - "windows-result", - "windows-targets 0.52.6", + "proc-macro2", + "quote", + "syn", ] [[package]] -name = "windows-implement" +name = "windows-interface" version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" +checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ "proc-macro2", "quote", @@ -3637,9 +3469,9 @@ dependencies = [ [[package]] name = "windows-interface" -version = "0.56.0" +version = "0.58.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" +checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515" dependencies = [ "proc-macro2", "quote", @@ -3655,6 +3487,25 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result 0.2.0", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -3844,10 +3695,10 @@ dependencies = [ "tempfile", "thiserror", "tree_magic_mini", - "wayland-backend 0.3.6", - "wayland-client 0.31.5", - "wayland-protocols 0.31.2", - "wayland-protocols-wlr 0.2.0", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", ] [[package]] @@ -3878,6 +3729,24 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec107c4503ea0b4a98ef47356329af139c0a4f7750e621cf2973cd3385ebcb3d" +[[package]] +name = "xcap" +version = "0.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a584e18d74df1db4bd35947d61e70c25c81a73db48add6eb4e00ad2227a51258" +dependencies = [ + "core-foundation 0.10.0", + "core-graphics 0.24.0", + "dbus", + "image 0.25.2", + "log", + "percent-encoding", + "sysinfo", + "thiserror", + "windows 0.58.0", + "xcb", +] + [[package]] name = "xcb" version = "1.4.0" diff --git a/crates/sss_cli/Cargo.toml b/crates/sss_cli/Cargo.toml index 7ab35b1..e1de9e3 100644 --- a/crates/sss_cli/Cargo.toml +++ b/crates/sss_cli/Cargo.toml @@ -34,7 +34,7 @@ tracing.workspace = true color-eyre.workspace = true tracing-subscriber.workspace = true mouse_position = "0.1.3" -screenshots = "0.8.10" +xcap = "0.0.13" sss_lib = { path = "../sss_lib" } [target.x86_64-unknown-linux-gnu.dependencies] diff --git a/crates/sss_cli/src/img.rs b/crates/sss_cli/src/img.rs index 65b5fc6..fa1bbac 100644 --- a/crates/sss_cli/src/img.rs +++ b/crates/sss_cli/src/img.rs @@ -23,18 +23,18 @@ impl DynImageContent for Screenshot { ImagenGenerationError::Custom(format!("Cannot get mouse position: {e:?}")) })?; - shot.screen(Some((x, y)), None, None, self.config.show_cursor) + shot.screen(Some((x, y)), None, None) } else if let Some(area) = self.config.area { tracing::trace!("Capture area"); - shot.capture_area(area, self.config.show_cursor) + shot.capture_area(area) } else if let Some(id) = self.config.screen_id.as_ref() { let name = Some(id.clone()); let id = id.parse::().ok(); tracing::trace!("Capture specific screen: {{ name: {name:?}, id: {id:?} }}"); - shot.screen(None, id, name, self.config.show_cursor) + shot.screen(None, id, name) } else { tracing::trace!("Capture all screens"); - shot.all(self.config.show_cursor) + shot.all() } } } diff --git a/crates/sss_cli/src/shot.rs b/crates/sss_cli/src/shot.rs index 31c9123..93a19c8 100644 --- a/crates/sss_cli/src/shot.rs +++ b/crates/sss_cli/src/shot.rs @@ -1,27 +1,18 @@ use std::env::var_os; -#[cfg(target_os = "linux")] -use libwayshot::output::OutputPositioning; -#[cfg(target_os = "linux")] -use libwayshot::reexport::Transform; -#[cfg(target_os = "linux")] -use libwayshot::{CaptureRegion, WayshotConnection}; -use screenshots::display_info::DisplayInfo; -use screenshots::image::imageops::overlay; -#[cfg(target_os = "linux")] -use screenshots::image::imageops::{rotate180, rotate270, rotate90}; -use screenshots::image::{Rgba, RgbaImage}; -use screenshots::Screen; use sss_lib::error::ImagenGeneration; +use xcap::image::imageops::overlay; +#[cfg(target_os = "linux")] +use xcap::image::imageops::{rotate180, rotate270, rotate90}; +use xcap::image::{Rgba, RgbaImage}; +use xcap::Monitor; use crate::error::SSScreenshot; use crate::Area; -#[cfg(target_os = "linux")] -type ScreenImage = ((Area, Transform), RgbaImage); -#[cfg(not(target_os = "linux"))] -type ScreenImage = ((Area, ()), RgbaImage); +type ScreenImage = ((Area, f32), RgbaImage); +#[allow(unused)] fn wayland_detect() -> bool { let xdg_session_type = var_os("XDG_SESSION_TYPE") .unwrap_or_default() @@ -39,11 +30,11 @@ fn wayland_detect() -> bool { } #[cfg(target_os = "linux")] -fn rotate(screen: &RgbaImage, t: Transform) -> RgbaImage { +fn rotate(screen: &RgbaImage, t: f32) -> RgbaImage { match t { - Transform::_90 => rotate90(screen), - Transform::_180 => rotate180(screen), - Transform::_270 => rotate270(screen), + 90.0 => rotate90(screen), + 180.0 => rotate180(screen), + 270.0 => rotate270(screen), _ => screen.clone(), } } @@ -67,110 +58,45 @@ fn make_all_screens(screens: &[ScreenImage]) -> RgbaImage { } pub struct ShotImpl { - xorg: Option>, - #[cfg(target_os = "linux")] - wayland: Option, - #[cfg(not(target_os = "linux"))] - wayland: Option<()>, + monitors: Vec, } impl ShotImpl { pub fn new() -> Result { Ok(Self { - xorg: (!wayland_detect()) - .then_some(Screen::all().map_err(|e| SSScreenshot::Custom(e.to_string()))?), - #[cfg(target_os = "linux")] - wayland: wayland_detect().then_some(WayshotConnection::new()?), - #[cfg(not(target_os = "linux"))] - wayland: None, + monitors: Monitor::all().map_err(|e| SSScreenshot::Custom(e.to_string()))?, }) } - pub fn all(&self, mouse: bool) -> Result { - if let Some(screens) = self.xorg.as_ref() { - return Ok(make_all_screens( - &screens - .iter() - .map(|s| { - let DisplayInfo { - x, - y, - width, - height, - .. - } = s.display_info; - s.capture() - .map(|c| { + pub fn all(&self) -> Result { + return Ok(make_all_screens( + &self + .monitors + .iter() + .map(|s| { + let x = s.x(); + let y = s.y(); + let width = s.width(); + let height = s.height(); + s.capture_image() + .map(|c| { + ( ( - #[cfg(target_os = "linux")] - ( - Area { - x, - y, - width, - height, - }, - Transform::Normal, - ), - #[cfg(not(target_os = "linux"))] - ( - Area { - x, - y, - width, - height, - }, - (), - ), - c, - ) - }) - .map_err(|e| ImagenGeneration::Custom(e.to_string())) - }) - .collect::, ImagenGeneration>>()?, - )); - } - - #[cfg(not(target_os = "linux"))] - return Err(ImagenGeneration::Custom("No Context loaded".to_string())); - - #[cfg(target_os = "linux")] - self.wayland - .as_ref() - .ok_or(ImagenGeneration::Custom("No Context loaded".to_owned())) - .map(|wayshot| { - let outputs = wayshot.get_all_outputs(); - Ok(make_all_screens( - &outputs - .iter() - .map(|o| { - let OutputPositioning { - x, - y, - width, - height, - } = o.dimensions; - wayshot - .screenshot_single_output(o, mouse) - .map_err(|e| ImagenGeneration::Custom(e.to_string())) - .map(|c| { - ( - ( - Area { - x, - y, - width: width as u32, - height: height as u32, - }, - o.transform, - ), - c, - ) - }) + Area { + x, + y, + width, + height, + }, + s.rotation(), + ), + c, + ) }) - .collect::, ImagenGeneration>>()?, - )) - })? + .map_err(|e| ImagenGeneration::Custom(e.to_string())) + }) + .collect::, ImagenGeneration>>()?, + )); } pub fn capture_area( @@ -181,57 +107,37 @@ impl ShotImpl { width: w, height: h, }: Area, - mouse: bool, ) -> Result { if w <= 1 || h <= 1 { return Err(ImagenGeneration::Custom( "The area size is invalid".to_owned(), )); } - if let Some(screens) = self.xorg.as_ref() { - let screen = screens - .iter() - .find(|s| { - x >= s.display_info.x - && (x as i32) - < s.display_info.x + s.display_info.width as i32 - && y >= s.display_info.y - && (y as i32) - < s.display_info.y + s.display_info.height as i32 - }) - .ok_or(ImagenGeneration::Custom(format!( - "Screen not found in area: {x},{y} {w}x{h}" - )))?; - return screen - .capture_area( - x - screen.display_info.x, - y - screen.display_info.y, + let screen = self + .monitors + .iter() + .find(|s| { + x >= s.x() + && (x as i32) < s.x() + s.width() as i32 + && y >= s.y() + && (y as i32) < s.y() + s.height() as i32 + }) + .ok_or(ImagenGeneration::Custom(format!( + "Screen not found in area: {x},{y} {w}x{h}" + )))?; + return screen + .capture_image() + .map(|i| { + xcap::image::imageops::crop_imm( + &i, + (x - screen.x()) as u32, + (y - screen.y()) as u32, w, h, ) - .map_err(|e| ImagenGeneration::Custom(e.to_string())); - } - - #[cfg(not(target_os = "linux"))] - return Err(ImagenGeneration::Custom("No Context loaded".to_string())); - - #[cfg(target_os = "linux")] - self.wayland - .as_ref() - .ok_or(ImagenGeneration::Custom("No Context loaded".to_string())) - .map(|wayshot| { - wayshot - .screenshot( - CaptureRegion { - x_coordinate: x, - y_coordinate: y, - width: w as i32, - height: h as i32, - }, - mouse, - ) - .map_err(|e| ImagenGeneration::Custom(e.to_string())) - })? + .to_image() + }) + .map_err(|e| ImagenGeneration::Custom(e.to_string())); } pub fn screen( @@ -239,63 +145,24 @@ impl ShotImpl { mouse_position: Option<(i32, i32)>, id: Option, name: Option, - mouse: bool, ) -> Result { - let pos = mouse_position.or(id.map(|i| (i, i))).unwrap_or_default(); + let (x, y) = mouse_position.unwrap_or_default(); - if let Some(screens) = self.xorg.as_ref() { - let (x, y) = pos; - let screen = screens + let screen = self.monitors .iter() .find(|s| { - s.display_info.id == pos.0 as u32 - || x >= s.display_info.x - && (x - s.display_info.width as i32) - < s.display_info.x + s.display_info.width as i32 - && y >= s.display_info.y - && (y - s.display_info.height as i32) - < s.display_info.y + s.display_info.height as i32 + id.map(|i| i as u32).is_some_and(|id| id == s.id()) + || x >= s.x() + && (x - s.width() as i32) + < s.x() + s.width() as i32 + && y >= s.y() + && (y - s.height() as i32) + < s.y() + s.height() as i32 }).ok_or(ImagenGeneration::Custom(format!( "Screen not found in mouse position {mouse_position:?} or with id: {id:?} or with name: {name:?}" )))?; - return screen - .capture() - .map_err(|e| ImagenGeneration::Custom(e.to_string())); - } - - #[cfg(not(target_os = "linux"))] - return Err(ImagenGeneration::Custom("No Context loaded".to_string())); - - let screen_name = name.unwrap_or_default(); - - #[cfg(target_os = "linux")] - self.wayland - .as_ref() - .ok_or(ImagenGeneration::Custom("No Context loaded".to_string())) - .map(|wayshot| { - let outputs = wayshot.get_all_outputs(); - let screen = outputs - .iter() - .find(|o| { - let OutputPositioning { - x, - y, - width, - height, - } = o.dimensions; - o.name == screen_name.trim() - || pos.0 >= x - && (pos.0 - width) < x + width - && pos.1 >= y - && (pos.1 - height) < y + height - }).ok_or(ImagenGeneration::Custom(format!( - "Screen not found in mouse position {mouse_position:?} or with id: {id:?} or with name: {screen_name:?}" - )))?; - let img = wayshot - .screenshot_single_output(screen, mouse) - .map_err(|e| ImagenGeneration::Custom(e.to_string()))?; - #[cfg(target_os = "linux")] - Ok(rotate(&img, screen.transform)) - })? + return screen + .capture_image() + .map_err(|e| ImagenGeneration::Custom(e.to_string())); } }