From dcd09dee2a1ed49da5bfc4a5a03024f4877a582f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sat, 2 Dec 2023 13:49:32 +0100 Subject: [PATCH] Add hyprsome fork --- hypr/hyprsome/.gitignore | 2 + hypr/hyprsome/Cargo.lock | 1207 +++++++++++++++++++ hypr/hyprsome/Cargo.toml | 17 + hypr/hyprsome/LICENSE.txt | 16 + hypr/hyprsome/README.md | 76 ++ hypr/hyprsome/flake.lock | 159 +++ hypr/hyprsome/flake.nix | 23 + hypr/hyprsome/src/hyprland_ipc/client.rs | 17 + hypr/hyprsome/src/hyprland_ipc/mod.rs | 37 + hypr/hyprsome/src/hyprland_ipc/monitor.rs | 43 + hypr/hyprsome/src/hyprland_ipc/option.rs | 19 + hypr/hyprsome/src/hyprland_ipc/workspace.rs | 23 + hypr/hyprsome/src/main.rs | 350 ++++++ 13 files changed, 1989 insertions(+) create mode 100644 hypr/hyprsome/.gitignore create mode 100644 hypr/hyprsome/Cargo.lock create mode 100644 hypr/hyprsome/Cargo.toml create mode 100644 hypr/hyprsome/LICENSE.txt create mode 100644 hypr/hyprsome/README.md create mode 100644 hypr/hyprsome/flake.lock create mode 100644 hypr/hyprsome/flake.nix create mode 100644 hypr/hyprsome/src/hyprland_ipc/client.rs create mode 100644 hypr/hyprsome/src/hyprland_ipc/mod.rs create mode 100644 hypr/hyprsome/src/hyprland_ipc/monitor.rs create mode 100644 hypr/hyprsome/src/hyprland_ipc/option.rs create mode 100644 hypr/hyprsome/src/hyprland_ipc/workspace.rs create mode 100644 hypr/hyprsome/src/main.rs diff --git a/hypr/hyprsome/.gitignore b/hypr/hyprsome/.gitignore new file mode 100644 index 0000000..d787b70 --- /dev/null +++ b/hypr/hyprsome/.gitignore @@ -0,0 +1,2 @@ +/target +/result diff --git a/hypr/hyprsome/Cargo.lock b/hypr/hyprsome/Cargo.lock new file mode 100644 index 0000000..706551c --- /dev/null +++ b/hypr/hyprsome/Cargo.lock @@ -0,0 +1,1207 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "async-trait" +version = "0.1.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cd7fce9ba8c3c042128ce72d8b2ddbf3a05747efb67ea0313c635e10bda47a2" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bincode" +version = "1.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" +dependencies = [ + "serde", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bytes" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8a7b6a70fde80372154c65702f00a0f56f3e1c36abbc6c440484be248856db" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clap" +version = "4.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f" +dependencies = [ + "atty", + "bitflags", + "clap_derive", + "clap_lex", + "once_cell", + "strsim", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "4.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad" +dependencies = [ + "heck", + "proc-macro-error", + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "crossbeam-channel" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b153fe7cbef478c567df0f972e02e6d736db11affe43dfc9c56a9374d1adfb87" +dependencies = [ + "crossbeam-utils", + "maybe-uninit", +] + +[[package]] +name = "crossbeam-utils" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3c7c73a2d1e9fc0886a08b93e98eb643461230d5f1925e4036204d5f2e261a8" +dependencies = [ + "autocfg", + "cfg-if 0.1.10", + "lazy_static", +] + +[[package]] +name = "derive_more" +version = "0.99.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 1.0.102", +] + +[[package]] +name = "doc-comment" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" + +[[package]] +name = "dyn-clone" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "futures" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f21eda599937fba36daeb58a22e8f5cee2d14c4a17b5b7739c7c8e5e3b8230c" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "30bdd20c28fadd505d0fd6712cdfcb0d4b5648baf45faef7f852afb2399bb050" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e5aa3de05362c3fb88de6531e6296e85cde7739cccad4b9dfeeb7f6ebce56bf" + +[[package]] +name = "futures-executor" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff63c23854bee61b6e9cd331d523909f238fc7636290b96826e9cfa5faa00ab" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-io" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf4d2a7a308fd4578637c0b17c7e1c7ba127b8f6ba00b29f717e9655d85eb68" + +[[package]] +name = "futures-macro" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42cd15d1c7456c04dbdf7e88bcd69760d74f3a798d6444e16974b505b0e62f17" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "futures-sink" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b20ba5a92e727ba30e72834706623d94ac93a725410b6a6b6fbc1b07f7ba56" + +[[package]] +name = "futures-task" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6508c467c73851293f390476d4491cf4d227dbabcd4170f3bb6044959b294f1" + +[[package]] +name = "futures-util" +version = "0.3.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fb6cb1be61cc1d2e43b262516aafcf63b241cffdb1d3fa115f91d9c7b09c90" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "getrandom" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.9.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hyprland" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d341e36a776cd092622daf2439a484247f3dc7d25eab7b286cc88ac85120d3" +dependencies = [ + "async-trait", + "derive_more", + "doc-comment", + "futures", + "hex", + "hyprland-macros", + "lazy_static", + "num-traits", + "paste", + "regex", + "serde", + "serde_json", + "serde_repr", + "strum", + "tokio", +] + +[[package]] +name = "hyprland-macros" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0088021091c08e29e9d1f735142ab811bd4d4d7f82fd4d4673407cb96fffb062" +dependencies = [ + "quote", + "syn 2.0.12", +] + +[[package]] +name = "hyprsome" +version = "0.1.11" +dependencies = [ + "clap", + "hyprland", + "ipc-rpc", + "schemars", + "serde", + "serde_json", + "tokio", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "ipc-channel" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cb1d9211085f0ea6f1379d944b93c4d07e8207aa3bcf49f37eda12b85081887" +dependencies = [ + "bincode", + "crossbeam-channel", + "fnv", + "lazy_static", + "libc", + "mio 0.6.23", + "rand", + "serde", + "tempfile", + "uuid 0.8.2", + "winapi 0.3.9", +] + +[[package]] +name = "ipc-rpc" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a06b6be6ca53e9aabea482d2cc45d651aecb8bc3515442909fcd73ab11d692" +dependencies = [ + "futures", + "ipc-channel", + "log", + "schemars", + "serde", + "serde_json", + "thiserror", + "tokio", + "uuid 1.2.1", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.135" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mio" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" +dependencies = [ + "libc", + "log", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.36.1", +] + +[[package]] +name = "miow" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "net2" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1" + +[[package]] +name = "os_str_bytes" +version = "6.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ff7415e9ae3fff1225851df9e0d9e4e5479f947619774677a63572e55e80eff" + +[[package]] +name = "parking_lot" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521" +dependencies = [ + "cfg-if 1.0.0", + "libc", + "redox_syscall", + "smallvec", + "windows-sys 0.45.0", +] + +[[package]] +name = "paste" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "ppv-lite86" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn 1.0.102", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro2" +version = "1.0.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" +dependencies = [ + "getrandom 0.1.16", + "libc", + "rand_chacha", + "rand_core", + "rand_hc", +] + +[[package]] +name = "rand_chacha" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" +dependencies = [ + "getrandom 0.1.16", +] + +[[package]] +name = "rand_hc" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" +dependencies = [ + "rand_core", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "remove_dir_all" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "rustc_version" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" +dependencies = [ + "semver", +] + +[[package]] +name = "rustversion" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "schemars" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a5fb6c61f29e723026dc8e923d94c694313212abbecbbe5f55a7748eec5b307" +dependencies = [ + "dyn-clone", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f188d036977451159430f3b8dc82ec76364a42b7e289c2b18a9a18f4470058e9" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 1.0.102", +] + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "semver" +version = "1.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" + +[[package]] +name = "serde" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728eb6351430bccb993660dfffc5a72f91ccc1295abaa8ce19b27ebe4f75568b" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81fa1584d3d1bcacd84c277a0dfe21f5b0f6accf4a23d04d4c6d61f1af522b4c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "serde_derive_internals" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85bf8229e7920a9f636479437026331ce11aa132b4dde37d121944a44d6e5f3c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "serde_json" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41feea4228a6f1cd09ec7a3593a682276702cd67b5273544757dae23c096f074" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_repr" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a5ec9fa74a20ebbe5d9ac23dac1fc96ba0ecfe9f50f2843b52e537b10fbcb4e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.102", +] + +[[package]] +name = "syn" +version = "1.0.102" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fcd952facd492f9be3ef0d0b7032a6e442ee9b361d4acc2b1d0c4aaa5f613a1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" +dependencies = [ + "cfg-if 1.0.0", + "fastrand", + "libc", + "redox_syscall", + "remove_dir_all", + "winapi 0.3.9", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "tokio" +version = "1.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9e03c497dc955702ba729190dc4aac6f2a0ce97f913e5b1b5912fc5039d9099" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio 0.8.4", + "num_cpus", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "socket2", + "tokio-macros", + "winapi 0.3.9", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.102", +] + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom 0.2.7", +] + +[[package]] +name = "uuid" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "feb41e78f93363bb2df8b0e86a2ca30eed7806ea16ea0c790d757cf93f79be83" +dependencies = [ + "getrandom 0.2.7", + "serde", +] + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.9.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[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-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[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-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc 0.42.1", + "windows_i686_gnu 0.42.1", + "windows_i686_msvc 0.42.1", + "windows_x86_64_gnu 0.42.1", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc 0.42.1", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] diff --git a/hypr/hyprsome/Cargo.toml b/hypr/hyprsome/Cargo.toml new file mode 100644 index 0000000..83a36ba --- /dev/null +++ b/hypr/hyprsome/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "hyprsome" +description = "A small CLI apps that allows to make Hyprland's workspaces work like Awesome in multi-monitor setup" +license = "GPL-3.0" +version = "0.1.11" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +clap = { version = "4.0.15", features = ["derive"] } +ipc-rpc = "1.2.2" +schemars = "0.8.11" +serde = "1.0.145" +serde_json = "1.0.86" +tokio = "1.21.2" +hyprland = "0.3.1" diff --git a/hypr/hyprsome/LICENSE.txt b/hypr/hyprsome/LICENSE.txt new file mode 100644 index 0000000..736f7b0 --- /dev/null +++ b/hypr/hyprsome/LICENSE.txt @@ -0,0 +1,16 @@ +The GPLv3 License (GPLv3) + +Copyright (c) 2022 Author + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/hypr/hyprsome/README.md b/hypr/hyprsome/README.md new file mode 100644 index 0000000..0a26688 --- /dev/null +++ b/hypr/hyprsome/README.md @@ -0,0 +1,76 @@ +# Hyprsome +Hyprsome is a binary that interacts with Hyprland's Unix socket to make workspaces behave similarly to AwesomeWM in a multi-monitor setup. + +If you're focused on a monitor and press SUPER+[1-9], you'll only switch to the workspaces that are bound to that monitor. + +It is inspired by Swaysome, which does a similar thing for Sway. + +# Installation +` +cargo install hyprsome +` + +# Usage +Once the binary is installed, you can modify your ~/.config/hypr/hyprland.conf to accomodate it. +Here is an example of a dual monitor setup: + +``` +monitor=DP-1,1920x1080@60,0x0,1.33 +monitor=DP-1,transform,1 +workspace=DP-1,1 +monitor=HDMI-A-1,3440x1440@100,813x0,1 +workspace=HDMI-A-1,11 +``` + +Most noteworthy thing here is the 'workspace' keyword that I use to bind a default workspace for each monitor. + + +Then you can bind workspaces to your different monitors. + +It is very important that you bind your workspaces in order. + +Check the results of `hyprctl monitors`. Bind workspaces from 1 to 9 on your monitor that has 0 as an id. + +Then just bind workspaces by prefixing numbers by the id of the monitor they're bound to. + +Here, HDMI-A-1's id is 1, so I bind workspaces from 11 to 19 to it. + +``` + workspace=1,monitor:DP-1 + workspace=2,monitor:DP-1 + workspace=3,monitor:DP-1 + workspace=4,monitor:DP-1 + workspace=5,monitor:DP-1 + + workspace=11,monitor:HDMI-A-1 + workspace=12,monitor:HDMI-A-1 + workspace=13,monitor:HDMI-A-1 + workspace=14,monitor:HDMI-A-1 + workspace=15,monitor:HDMI-A-1 +``` + +Then it's just a matter of making sure your regular workspace keybinds call hyprsome. + +``` +bind=SUPER,1,exec,hyprsome workspace 1 +bind=SUPER,2,exec,hyprsome workspace 2 +bind=SUPER,3,exec,hyprsome workspace 3 +bind=SUPER,4,exec,hyprsome workspace 4 +bind=SUPER,5,exec,hyprsome workspace 5 + +bind=SUPERSHIFT,1,exec,hyprsome move 1 +bind=SUPERSHIFT,2,exec,hyprsome move 2 +bind=SUPERSHIFT,3,exec,hyprsome move 3 +bind=SUPERSHIFT,4,exec,hyprsome move 4 +bind=SUPERSHIFT,5,exec,hyprsome move 5 + +``` + +# Limitations +This is alpha software and my first program in Rust, bugs are bound to happen but nothing that will break your system. + +Some features are most likely missing. + +You can only have 9 workspaces per monitor as of now. + +I haven't worked on supporting monitor hot-plug at all. It may work but it's unlikely. diff --git a/hypr/hyprsome/flake.lock b/hypr/hyprsome/flake.lock new file mode 100644 index 0000000..51f0f15 --- /dev/null +++ b/hypr/hyprsome/flake.lock @@ -0,0 +1,159 @@ +{ + "nodes": { + "crane": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ], + "rust-overlay": "rust-overlay" + }, + "locked": { + "lastModified": 1684981077, + "narHash": "sha256-68X9cFm0RTZm8u0rXPbeBzOVUH5OoUGAfeHHVoxGd9o=", + "owner": "ipetkov", + "repo": "crane", + "rev": "35110cccf28823320f4fd697fcafcb5038683982", + "type": "github" + }, + "original": { + "owner": "ipetkov", + "repo": "crane", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1685498995, + "narHash": "sha256-rdyjnkq87tJp+T2Bm1OD/9NXKSsh/vLlPeqCc/mm7qs=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9cfaa8a1a00830d17487cb60a19bb86f96f09b27", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "crane": "crane", + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs" + } + }, + "rust-overlay": { + "inputs": { + "flake-utils": [ + "crane", + "flake-utils" + ], + "nixpkgs": [ + "crane", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1683080331, + "narHash": "sha256-nGDvJ1DAxZIwdn6ww8IFwzoHb2rqBP4wv/65Wt5vflk=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "d59c3fa0cba8336e115b376c2d9e91053aa59e56", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/hypr/hyprsome/flake.nix b/hypr/hyprsome/flake.nix new file mode 100644 index 0000000..31bb13e --- /dev/null +++ b/hypr/hyprsome/flake.nix @@ -0,0 +1,23 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + crane.url = "github:ipetkov/crane"; + crane.inputs.nixpkgs.follows = "nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, crane, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + craneLib = crane.lib.${system}; + in + { + packages.default = craneLib.buildPackage { + src = craneLib.cleanCargoSource (craneLib.path ./.); + # Add extra inputs here or any other derivation settings + # doCheck = true; + # buildInputs = []; + # nativeBuildInputs = []; + }; + }); +} diff --git a/hypr/hyprsome/src/hyprland_ipc/client.rs b/hypr/hyprsome/src/hyprland_ipc/client.rs new file mode 100644 index 0000000..0821534 --- /dev/null +++ b/hypr/hyprsome/src/hyprland_ipc/client.rs @@ -0,0 +1,17 @@ +use hyprland::{ + data::{Client, Clients}, + dispatch::{Direction, Dispatch, DispatchType}, + shared::{HyprData, HyprDataActiveOptional}, +}; + +pub fn get_active() -> Option { + Client::get_active().unwrap() +} + +pub fn get() -> Clients { + Clients::get().unwrap() +} + +pub fn focus_by_direction(direction: Direction) { + let _ = Dispatch::call(DispatchType::MoveFocus(direction)); +} diff --git a/hypr/hyprsome/src/hyprland_ipc/mod.rs b/hypr/hyprsome/src/hyprland_ipc/mod.rs new file mode 100644 index 0000000..ff83b2b --- /dev/null +++ b/hypr/hyprsome/src/hyprland_ipc/mod.rs @@ -0,0 +1,37 @@ +pub mod client; +pub mod monitor; +pub mod option; +pub mod workspace; + +use std::env; +use std::io::prelude::*; +use std::os::unix::net::UnixStream; + +extern crate serde_json; + +fn send_message(action: &str, args: Vec<&str>) -> String { + let env_var_name = "HYPRLAND_INSTANCE_SIGNATURE"; + + let hyprland_instance_sig = match env::var(env_var_name) { + Ok(v) => v, + Err(e) => panic!("${} is not set ({})", env_var_name, e), + }; + + let socket_path = format!("/tmp/hypr/{}/.socket.sock", hyprland_instance_sig); + let mut stream = match UnixStream::connect(socket_path) { + Err(_) => panic!("server is not running"), + Ok(stream) => stream, + }; + + let mut message = format!("j/{}", action); + args.into_iter() + .for_each(|a| message.push_str(&format!(" {}", a))); + + // TODO: stop being stinky and manage errors + let _ = stream.write_all(message.as_bytes()); + let mut response = String::new(); + + // TODO: stop being stinky and manage errors + let _ = stream.read_to_string(&mut response); + response +} diff --git a/hypr/hyprsome/src/hyprland_ipc/monitor.rs b/hypr/hyprsome/src/hyprland_ipc/monitor.rs new file mode 100644 index 0000000..f08e4e9 --- /dev/null +++ b/hypr/hyprsome/src/hyprland_ipc/monitor.rs @@ -0,0 +1,43 @@ +use hyprland::data::{Monitor, Monitors}; +use hyprland::dispatch::*; +use hyprland::shared::HyprData; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct ActiveWorkspace { + pub id: u64, + pub name: String, +} + +pub fn get_by_id(id: i16) -> Monitor { + let mut monitors = get(); + monitors.find(|m| m.id == id).unwrap() +} + +pub fn get() -> Monitors { + Monitors::get().unwrap() +} + +pub fn focus_left() { + let _ = Dispatch::call(DispatchType::FocusMonitor(MonitorIdentifier::Direction( + Direction::Left, + ))); +} + +pub fn focus_right() { + let _ = Dispatch::call(DispatchType::FocusMonitor(MonitorIdentifier::Direction( + Direction::Right, + ))); +} + +pub fn focus_up() { + let _ = Dispatch::call(DispatchType::FocusMonitor(MonitorIdentifier::Direction( + Direction::Up, + ))); +} + +pub fn focus_down() { + let _ = Dispatch::call(DispatchType::FocusMonitor(MonitorIdentifier::Direction( + Direction::Down, + ))); +} diff --git a/hypr/hyprsome/src/hyprland_ipc/option.rs b/hypr/hyprsome/src/hyprland_ipc/option.rs new file mode 100644 index 0000000..368403f --- /dev/null +++ b/hypr/hyprsome/src/hyprland_ipc/option.rs @@ -0,0 +1,19 @@ +use serde::{Deserialize, Serialize}; + +const GETOPTIONS: &str = "getoptions"; +const GENERAL_GAPS_OUT: &str = "general:gaps_out"; + +#[derive(Serialize, Deserialize, Debug)] +pub struct HyprlandOption { + pub option: String, + pub int: i32, + pub float: f64, + pub str: String, +} + +pub fn get_gaps() -> i16 { + let response = super::send_message(GETOPTIONS, vec![GENERAL_GAPS_OUT]); + let gap_option: HyprlandOption = serde_json::from_str(&response).unwrap(); + + gap_option.int as i16 +} diff --git a/hypr/hyprsome/src/hyprland_ipc/workspace.rs b/hypr/hyprsome/src/hyprland_ipc/workspace.rs new file mode 100644 index 0000000..82c606c --- /dev/null +++ b/hypr/hyprsome/src/hyprland_ipc/workspace.rs @@ -0,0 +1,23 @@ +// TODO: change this file to hyprland-rs +const WORKSPACE: &str = "workspace"; +const DISPATCH: &str = "dispatch"; +const MOVETOWORKSPACESILENT: &str = "movetoworkspacesilent"; +const MOVETOWORKSPACE: &str = "movetoworkspace"; + +pub fn focus(workspace_number: &u64) { + let _ = super::send_message(DISPATCH, vec![WORKSPACE, &workspace_number.to_string()]); +} + +pub fn move_to(workspace_number: &u64) { + super::send_message( + DISPATCH, + vec![MOVETOWORKSPACESILENT, &workspace_number.to_string()], + ); +} + +pub fn move_focus(workspace_number: &u64) { + super::send_message( + DISPATCH, + vec![MOVETOWORKSPACE, &workspace_number.to_string()], + ); +} diff --git a/hypr/hyprsome/src/main.rs b/hypr/hyprsome/src/main.rs new file mode 100644 index 0000000..6ba836a --- /dev/null +++ b/hypr/hyprsome/src/main.rs @@ -0,0 +1,350 @@ +use clap::{Parser, Subcommand, ValueEnum}; + +mod hyprland_ipc; +use hyprland::{ + data::{Client, Monitor, Transforms, Workspaces}, + dispatch::Direction, shared::HyprData, +}; +use hyprland_ipc::{client, monitor, option, workspace}; + +#[derive(Parser)] +#[command(name = "hyprsome")] +#[command(author = "sopa0")] +#[command(version = "0.1.11")] +#[command(about = "Makes hyprland workspaces behave like awesome", long_about = None)] +struct Cli { + #[command(subcommand)] + command: Commands, +} + +#[derive(Subcommand)] +enum Commands { + Focus { direction: Directions }, + Workspace { workspace_number: u64 }, + Move { workspace_number: u64 }, + Movefocus { workspace_number: u64 }, + MoveEmpty, + FocusEmpty, +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ValueEnum, Debug)] +enum Directions { + L, + R, + U, + D, +} + +pub trait MonitorDimensions { + fn real_width(&self) -> f32; + fn real_height(&self) -> f32; +} + +impl MonitorDimensions for Monitor { + fn real_width(&self) -> f32 { + match self.transform { + Transforms::Normal + | Transforms::Normal180 + | Transforms::Flipped + | Transforms::Flipped180 => self.width as f32 / self.scale, + Transforms::Normal90 | Transforms::Normal270 | Transforms::Flipped90 => { + self.height as f32 / self.scale + } + _ => self.width as f32, + } + } + + fn real_height(&self) -> f32 { + match self.transform { + Transforms::Normal + | Transforms::Flipped + | Transforms::Normal180 + | Transforms::Flipped180 => self.height as f32 / self.scale, + Transforms::Normal90 | Transforms::Normal270 | Transforms::Flipped90 => { + self.width as f32 / self.scale + } + _ => self.height as f32, + } + } +} + +pub fn get_current_monitor() -> Monitor { + monitor::get().find(|m| m.focused).unwrap() +} + +//TODO: refactor this nonsense +pub fn select_workspace(workspace_number: &u64) { + let mon = get_current_monitor(); + match mon.id { + 0 => workspace::focus(workspace_number), + _ => { + workspace::focus( + &format!("{}{}", mon.id, workspace_number) + .parse::() + .unwrap(), + ); + } + } +} + +pub fn get_empty_workspace() -> u64 { + let mon = get_current_monitor(); + let mut found = Vec::new(); + for workspaces in Workspaces::get().iter() { + for workspace in workspaces.iter() { + if workspace.monitor == mon.name { + let mut id = workspace.name.clone(); + if id.len() > 1 { + id = id.chars().nth(1).unwrap().to_string(); + } + found.push(id); + } + } + } + for i in 1..9 { + if !found.contains(&i.to_string()) { + return i; + } + } + return 1; // Send to the first workspace if no others are available +} + +//TODO: refactor this nonsense +pub fn send_to_workspace(workspace_number: &u64) { + let mon = get_current_monitor(); + match mon.id { + 0 => workspace::move_to(workspace_number), + _ => { + workspace::move_to( + &format!("{}{}", mon.id, workspace_number) + .parse::() + .unwrap(), + ); + } + } +} + +//TODO: refactor this nonsense +pub fn movefocus(workspace_number: &u64) { + let mon = get_current_monitor(); + match mon.id { + 0 => workspace::move_focus(workspace_number), + _ => { + workspace::move_focus( + &format!("{}{}", mon.id, workspace_number) + .parse::() + .unwrap(), + ); + } + } +} + +pub fn get_leftmost_client_for_monitor(mon_id: i16) -> Client { + let clients = client::get(); + + clients + .into_iter() + .filter(|c| c.monitor == mon_id) + .min_by_key(|c| c.at.0) + .unwrap() +} + +pub fn focus_left(aw: Client) { + let mon = monitor::get_by_id(aw.monitor); + let is_leftmost_client = is_leftmost_client(&aw, &mon); + + if is_leftmost_monitor(&mon) && is_leftmost_client { + return; + } + + if is_leftmost_client { + monitor::focus_left(); + + return; + } + + client::focus_by_direction(Direction::Left); +} + +pub fn focus_right(aw: Client) { + let mon = monitor::get_by_id(aw.monitor); + + if is_rightmost_monitor(&mon) && is_rightmost_client(&aw, &mon) { + return; + } + + if is_rightmost_client(&aw, &mon) { + monitor::focus_right(); + + return; + } + + client::focus_by_direction(Direction::Right); +} + +pub fn focus_up(aw: Client) { + let mon = monitor::get_by_id(aw.monitor); + let is_top_client = is_top_client(&aw, &mon); + + if is_top_monitor(&mon) && is_top_client { + return; + } + + if is_top_client { + monitor::focus_up(); + + return; + } + + client::focus_by_direction(Direction::Up); +} + +pub fn focus_down(aw: Client) { + let mon = monitor::get_by_id(aw.monitor); + let is_bottom_client = is_bottom_client(&aw, &mon); + + if is_bottom_monitor(&mon) && is_bottom_client { + return; + } + + if is_bottom_client { + monitor::focus_down(); + + return; + } + + client::focus_by_direction(Direction::Down); +} + +pub fn is_leftmost_client(aw: &Client, mon: &Monitor) -> bool { + let gaps = option::get_gaps(); + + if (aw.at.0 - gaps) as i32 == mon.x { + return true; + } + + false +} + +pub fn is_rightmost_client(aw: &Client, mon: &Monitor) -> bool { + let gaps = option::get_gaps(); + + if mon.real_width() + mon.x as f32 - gaps as f32 == aw.size.0 as f32 + aw.at.0 as f32 { + return true; + } + + false +} + +pub fn is_top_client(aw: &Client, mon: &Monitor) -> bool { + let gaps = option::get_gaps(); + + if mon.y + (gaps as i32) + (mon.reserved.1 as i32) == (aw.at.1 as i32) { + return true; + } + + false +} + +pub fn is_bottom_client(aw: &Client, mon: &Monitor) -> bool { + let gaps = option::get_gaps(); + + if mon.real_height() + mon.y as f32 - gaps as f32 - mon.reserved.1 as f32 + == aw.size.1 as f32 + gaps as f32 + { + return true; + } + + false +} + +pub fn is_rightmost_monitor(mon: &Monitor) -> bool { + let monitors = monitor::get(); + let max = monitors.into_iter().max_by_key(|m| m.x).unwrap(); + if max.x == mon.x { + return true; + } + false +} + +pub fn is_leftmost_monitor(mon: &Monitor) -> bool { + let monitors = monitor::get(); + let min = monitors.into_iter().min_by_key(|m| m.x).unwrap(); + if min.x == mon.x { + return true; + } + false +} + +pub fn is_top_monitor(mon: &Monitor) -> bool { + let monitors = monitor::get(); + let min = monitors.into_iter().min_by_key(|m| m.y).unwrap(); + if min.y == mon.y { + return true; + } + false +} + +pub fn is_bottom_monitor(mon: &Monitor) -> bool { + let monitors = monitor::get(); + let max = monitors.into_iter().max_by_key(|m| m.y).unwrap(); + if max.y == mon.y { + return true; + } + false +} + +fn main() { + let cli = Cli::parse(); + match &cli.command { + Commands::Focus { direction } => match direction { + Directions::L => { + let aw = client::get_active(); + + match aw { + Some(aw) => focus_left(aw), + None => monitor::focus_left(), + }; + } + Directions::R => { + let aw = client::get_active(); + + match aw { + Some(aw) => focus_right(aw), + None => monitor::focus_right(), + }; + } + Directions::U => { + let aw = client::get_active(); + + match aw { + Some(aw) => focus_up(aw), + None => monitor::focus_up(), + }; + } + Directions::D => { + let aw = client::get_active(); + + match aw { + Some(aw) => focus_down(aw), + None => monitor::focus_down(), + }; + } + }, + Commands::Workspace { workspace_number } => { + select_workspace(workspace_number); + } + Commands::Move { workspace_number } => { + send_to_workspace(workspace_number); + } + Commands::Movefocus { workspace_number } => { + movefocus(workspace_number); + } + Commands::MoveEmpty => { + movefocus(&get_empty_workspace()); + }, + Commands::FocusEmpty => { + send_to_workspace(&get_empty_workspace()); + }, + } +}