pax_global_header00006660000000000000000000000064146703720040014515gustar00rootroot0000000000000052 comment=dbb8b721fe43d2feca8a22cfac9a387a6c38a180 SwayOSD-0.1.0/000077500000000000000000000000001467037200400130045ustar00rootroot00000000000000SwayOSD-0.1.0/.github/000077500000000000000000000000001467037200400143445ustar00rootroot00000000000000SwayOSD-0.1.0/.github/workflows/000077500000000000000000000000001467037200400164015ustar00rootroot00000000000000SwayOSD-0.1.0/.github/workflows/rust-format.yml000066400000000000000000000013141467037200400214060ustar00rootroot00000000000000# This is a basic workflow to help you get started with Actions name: Rust Format # Controls when the workflow will run on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ main ] pull_request: branches: [ main ] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: jobs: formatting: name: cargo fmt runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 # Ensure rustfmt is installed and setup problem matcher - uses: actions-rust-lang/setup-rust-toolchain@v1 with: components: rustfmt - name: Rustfmt Check uses: actions-rust-lang/rustfmt@v1 SwayOSD-0.1.0/.gitignore000066400000000000000000000001411467037200400147700ustar00rootroot00000000000000# Binaries /target /build *.gresource # These are backup files generated by rustfmt **/*.rs.bk SwayOSD-0.1.0/Cargo.lock000066400000000000000000001531211467037200400147140ustar00rootroot00000000000000# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "anyhow" version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "async-broadcast" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "20cd0e2e25ea8e5f7e9df04578dc6cf5c83577fd09b1a46aaf5c85e1c33f2a7e" dependencies = [ "event-listener 5.3.1", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-channel" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81953c529336010edd6d8e358f886d9581267795c61b19475b71314bffa46d35" dependencies = [ "concurrent-queue", "event-listener 2.5.3", "futures-core", ] [[package]] name = "async-channel" version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89b47800b0be77592da0afd425cc03468052844aff33b84e33cc696f64e77b6a" dependencies = [ "concurrent-queue", "event-listener-strategy", "futures-core", "pin-project-lite", ] [[package]] name = "async-executor" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7ebdfa2ebdab6b1760375fa7d6f382b9f486eac35fc994625a00e89280bdbb7" dependencies = [ "async-task", "concurrent-queue", "fastrand 2.1.1", "futures-lite 2.3.0", "slab", ] [[package]] name = "async-fs" version = "2.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ebcd09b382f40fcd159c2d695175b2ae620ffa5f3bd6f664131efff4e8b9e04a" dependencies = [ "async-lock 3.4.0", "blocking", "futures-lite 2.3.0", ] [[package]] name = "async-global-executor" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05b1b633a2115cd122d73b955eadd9916c18c8f510ec9cd1686404c60ad1c29c" dependencies = [ "async-channel 2.3.1", "async-executor", "async-io 2.3.4", "async-lock 3.4.0", "blocking", "futures-lite 2.3.0", "once_cell", ] [[package]] name = "async-io" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fc5b45d93ef0529756f812ca52e44c221b35341892d3dcc34132ac02f3dd2af" dependencies = [ "async-lock 2.8.0", "autocfg", "cfg-if", "concurrent-queue", "futures-lite 1.13.0", "log", "parking", "polling 2.8.0", "rustix 0.37.27", "slab", "socket2", "waker-fn", ] [[package]] name = "async-io" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "444b0228950ee6501b3568d3c93bf1176a1fdbc3b758dcd9475046d30f4dc7e8" dependencies = [ "async-lock 3.4.0", "cfg-if", "concurrent-queue", "futures-io", "futures-lite 2.3.0", "parking", "polling 3.7.3", "rustix 0.38.35", "slab", "tracing", "windows-sys 0.59.0", ] [[package]] name = "async-lock" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "287272293e9d8c41773cec55e365490fe034813a2f172f502d6ddcf75b2f582b" dependencies = [ "event-listener 2.5.3", ] [[package]] name = "async-lock" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff6e472cdea888a4bd64f342f09b3f50e1886d32afe8df3d663c01140b811b18" dependencies = [ "event-listener 5.3.1", "event-listener-strategy", "pin-project-lite", ] [[package]] name = "async-process" version = "2.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8a07789659a4d385b79b18b9127fc27e1a59e1e89117c78c5ea3b806f016374" dependencies = [ "async-channel 2.3.1", "async-io 2.3.4", "async-lock 3.4.0", "async-signal", "async-task", "blocking", "cfg-if", "event-listener 5.3.1", "futures-lite 2.3.0", "rustix 0.38.35", "tracing", "windows-sys 0.59.0", ] [[package]] name = "async-recursion" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "async-signal" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "637e00349800c0bdf8bfc21ebbc0b6524abea702b0da4168ac00d070d0c0b9f3" dependencies = [ "async-io 2.3.4", "async-lock 3.4.0", "atomic-waker", "cfg-if", "futures-core", "futures-io", "rustix 0.38.35", "signal-hook-registry", "slab", "windows-sys 0.59.0", ] [[package]] name = "async-std" version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" dependencies = [ "async-channel 1.9.0", "async-global-executor", "async-io 1.13.0", "async-lock 2.8.0", "crossbeam-utils", "futures-channel", "futures-core", "futures-io", "futures-lite 1.13.0", "gloo-timers", "kv-log-macro", "log", "memchr", "once_cell", "pin-project-lite", "pin-utils", "slab", "wasm-bindgen-futures", ] [[package]] name = "async-task" version = "4.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b75356056920673b02621b35afd0f7dda9306d03c79a30f5c56c44cf256e3de" [[package]] name = "async-trait" version = "0.1.81" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "atk" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ba16453d10c712284061a05f6510f75abeb92b56ba88dfeb48c74775020cc22" dependencies = [ "atk-sys", "bitflags 1.3.2", "glib", "libc", ] [[package]] name = "atk-sys" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf0a7ca572fbd5762fd8f8cd65a581e06767bc1234913fe1f43e370cff6e90" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "atomic-waker" version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "blight" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a3cd2618fe019418182fbee988b6668c61067f986833e98e9e3ff9fd22a6472" dependencies = [ "colored", "fs4", ] [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array", ] [[package]] name = "blocking" version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "703f41c54fc768e63e091340b424302bb1c29ef4aa0c7f10fe849dfb114d29ea" dependencies = [ "async-channel 2.3.1", "async-task", "futures-io", "futures-lite 2.3.0", "piper", ] [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cairo-rs" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a" dependencies = [ "bitflags 1.3.2", "cairo-sys-rs", "glib", "libc", "once_cell", "thiserror", ] [[package]] name = "cairo-sys-rs" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "691d0c66b1fb4881be80a760cb8fe76ea97218312f9dfe2c9cc0f496ca279cb1" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "cascade" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d499b43edbf784dd81e16f0395f5b4350a35b477da8a074251087adefc11cb52" [[package]] name = "cc" version = "1.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" dependencies = [ "shlex", ] [[package]] name = "cfg-expr" version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" dependencies = [ "smallvec", "target-lexicon", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" [[package]] name = "colored" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" dependencies = [ "lazy_static", "windows-sys 0.48.0", ] [[package]] name = "concurrent-queue" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" dependencies = [ "crossbeam-utils", ] [[package]] name = "cpufeatures" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51e852e6dc9a5bed1fae92dd2375037bf2b768725bf3be87811edee3249d09ad" dependencies = [ "libc", ] [[package]] name = "crossbeam-utils" version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crypto-common" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" dependencies = [ "generic-array", "typenum", ] [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", ] [[package]] name = "either" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "endi" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf" [[package]] name = "enumflags2" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d232db7f5956f3f14313dc2f87985c58bd2c695ce124c8cdd984e08e15ac133d" dependencies = [ "enumflags2_derive", "serde", ] [[package]] name = "enumflags2_derive" version = "0.7.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0d48a183585823424a4ce1aa132d174a6a81bd540895822eb4c8373a8e49e8" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" dependencies = [ "libc", "windows-sys 0.52.0", ] [[package]] name = "evdev-rs" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9812d5790fb6fcce449333eb6713dad335e8c979225ed98755c84a3987e06dba" dependencies = [ "bitflags 1.3.2", "evdev-sys", "libc", "log", ] [[package]] name = "evdev-sys" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14ead42b547b15d47089c1243d907bcf0eb94e457046d3b315a26ac9c9e9ea6d" dependencies = [ "cc", "libc", "pkg-config", ] [[package]] name = "event-listener" version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "event-listener" version = "5.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6032be9bd27023a771701cc49f9f053c751055f71efb2e0ae5c15809093675ba" dependencies = [ "concurrent-queue", "parking", "pin-project-lite", ] [[package]] name = "event-listener-strategy" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f214dc438f977e6d4e3500aaa277f5ad94ca83fbbd9b1a15713ce2344ccc5a1" dependencies = [ "event-listener 5.3.1", "pin-project-lite", ] [[package]] name = "fastrand" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" dependencies = [ "instant", ] [[package]] name = "fastrand" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" [[package]] name = "field-offset" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ "memoffset 0.9.1", "rustc_version", ] [[package]] name = "fs4" version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2eeb4ed9e12f43b7fa0baae3f9cdda28352770132ef2e09a23760c29cae8bd47" dependencies = [ "rustix 0.38.35", "windows-sys 0.48.0", ] [[package]] name = "futures-channel" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" dependencies = [ "futures-core", ] [[package]] name = "futures-core" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" [[package]] name = "futures-executor" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" dependencies = [ "futures-core", "futures-task", "futures-util", ] [[package]] name = "futures-io" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" [[package]] name = "futures-lite" version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49a9d51ce47660b1e808d3c990b4709f2f415d928835a17dfd16991515c46bce" dependencies = [ "fastrand 1.9.0", "futures-core", "futures-io", "memchr", "parking", "pin-project-lite", "waker-fn", ] [[package]] name = "futures-lite" version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52527eb5074e35e9339c6b4e8d12600c7128b68fb25dcb9fa9dec18f7c25f3a5" dependencies = [ "fastrand 2.1.1", "futures-core", "futures-io", "parking", "pin-project-lite", ] [[package]] name = "futures-macro" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "futures-sink" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" [[package]] name = "futures-task" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" [[package]] name = "futures-util" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" dependencies = [ "futures-core", "futures-io", "futures-macro", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "gdk" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be1df5ea52cccd7e3a0897338b5564968274b52f5fd12601e0afa44f454c74d3" dependencies = [ "bitflags 1.3.2", "cairo-rs", "gdk-pixbuf", "gdk-sys", "gio", "glib", "libc", "pango", ] [[package]] name = "gdk-pixbuf" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "695d6bc846438c5708b07007537b9274d883373dd30858ca881d7d71b5540717" dependencies = [ "bitflags 1.3.2", "gdk-pixbuf-sys", "gio", "glib", "libc", "once_cell", ] [[package]] name = "gdk-pixbuf-sys" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9285ec3c113c66d7d0ab5676599176f1f42f4944ca1b581852215bf5694870cb" dependencies = [ "gio-sys", "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "gdk-sys" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2152de9d38bc67a17b3fe49dc0823af5bf874df59ea088c5f28f31cf103de703" dependencies = [ "cairo-sys-rs", "gdk-pixbuf-sys", "gio-sys", "glib-sys", "gobject-sys", "libc", "pango-sys", "pkg-config", "system-deps", ] [[package]] name = "generic-array" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", "version_check", ] [[package]] name = "getrandom" version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "libc", "wasi", ] [[package]] name = "gio" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a6973e92937cf98689b6a054a9e56c657ed4ff76de925e36fc331a15f0c5d30a" dependencies = [ "bitflags 1.3.2", "futures-channel", "futures-core", "futures-io", "futures-util", "gio-sys", "glib", "libc", "once_cell", "pin-project-lite", "smallvec", "thiserror", ] [[package]] name = "gio-sys" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ccf87c30a12c469b6d958950f6a9c09f2be20b7773f7e70d20b867fdf2628c3" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", "winapi", ] [[package]] name = "glib" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b" dependencies = [ "bitflags 1.3.2", "futures-channel", "futures-core", "futures-executor", "futures-task", "futures-util", "gio-sys", "glib-macros", "glib-sys", "gobject-sys", "libc", "memchr", "once_cell", "smallvec", "thiserror", ] [[package]] name = "glib-macros" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26" dependencies = [ "anyhow", "heck 0.4.1", "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", "syn 1.0.109", ] [[package]] name = "glib-sys" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0" dependencies = [ "libc", "system-deps", ] [[package]] name = "gloo-timers" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" dependencies = [ "futures-channel", "futures-core", "js-sys", "wasm-bindgen", ] [[package]] name = "gobject-sys" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062" dependencies = [ "glib-sys", "libc", "system-deps", ] [[package]] name = "gtk" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c4222ab92b08d4d0bab90ddb6185b4e575ceeea8b8cdf00b938d7b6661d966" dependencies = [ "atk", "bitflags 1.3.2", "cairo-rs", "field-offset", "futures-channel", "gdk", "gdk-pixbuf", "gio", "glib", "gtk-sys", "gtk3-macros", "libc", "once_cell", "pango", "pkg-config", ] [[package]] name = "gtk-layer-shell" version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "992f5fedb31835424a5280acd162bf348995f617d26969fde8d3dfd389b3ff5f" dependencies = [ "bitflags 2.6.0", "gdk", "glib", "glib-sys", "gtk", "gtk-layer-shell-sys", "libc", ] [[package]] name = "gtk-layer-shell-sys" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5754bcfaadfc3529116af6ae93559b267d88647f965382153a4b8ea9372be75a" dependencies = [ "gdk-sys", "glib-sys", "gtk-sys", "libc", "system-deps", ] [[package]] name = "gtk-sys" version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d8eb6a4b93e5a7e6980f7348d08c1cd93d31fae07cf97f20678c5ec41de3d7e" dependencies = [ "atk-sys", "cairo-sys-rs", "gdk-pixbuf-sys", "gdk-sys", "gio-sys", "glib-sys", "gobject-sys", "libc", "pango-sys", "system-deps", ] [[package]] name = "gtk3-macros" version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3efb84d682c9a39c10bd9f24f5a4b9c15cc8c7edc45c19cb2ca2c4fc38b2d95e" dependencies = [ "anyhow", "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", "syn 1.0.109", ] [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" [[package]] name = "heck" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "heck" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" [[package]] name = "hermit-abi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hermit-abi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc" [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "indexmap" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" dependencies = [ "equivalent", "hashbrown", ] [[package]] name = "input" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6e74cd82cedcd66db78742a8337bdc48f188c4d2c12742cbc5cd85113f0b059" dependencies = [ "bitflags 1.3.2", "input-sys", "io-lifetimes", "libc", "log", "udev", ] [[package]] name = "input-sys" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd4f5b4d1c00331c5245163aacfe5f20be75b564c7112d45893d4ae038119eb0" [[package]] name = "instant" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] [[package]] name = "io-lifetimes" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" dependencies = [ "hermit-abi 0.3.9", "libc", "windows-sys 0.48.0", ] [[package]] name = "itertools" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" dependencies = [ "either", ] [[package]] name = "js-sys" version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" dependencies = [ "wasm-bindgen", ] [[package]] name = "kv-log-macro" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" dependencies = [ "log", ] [[package]] name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" [[package]] name = "libc" version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" [[package]] name = "libpulse-binding" version = "2.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed3557a2dfc380c8f061189a01c6ae7348354e0c9886038dc6c171219c08eaff" dependencies = [ "bitflags 1.3.2", "libc", "libpulse-sys", "num-derive", "num-traits", "winapi", ] [[package]] name = "libpulse-sys" version = "1.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc19e110fbf42c17260d30f6d3dc545f58491c7830d38ecb9aaca96e26067a9b" dependencies = [ "libc", "num-derive", "num-traits", "pkg-config", "winapi", ] [[package]] name = "libudev-sys" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c8469b4a23b962c1396b9b451dda50ef5b283e8dd309d69033475fa9b334324" dependencies = [ "libc", "pkg-config", ] [[package]] name = "linux-raw-sys" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "linux-raw-sys" version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" [[package]] name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" dependencies = [ "value-bag", ] [[package]] name = "memchr" version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" [[package]] name = "memoffset" version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" dependencies = [ "autocfg", ] [[package]] name = "memoffset" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" dependencies = [ "autocfg", ] [[package]] name = "nix" version = "0.26.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" dependencies = [ "bitflags 1.3.2", "cfg-if", "libc", "memoffset 0.7.1", "pin-utils", ] [[package]] name = "nix" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.6.0", "cfg-if", "cfg_aliases", "libc", "memoffset 0.9.1", ] [[package]] name = "num-derive" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", "syn 1.0.109", ] [[package]] name = "num-traits" version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] [[package]] name = "once_cell" version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "ordered-stream" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9aa2b01e1d916879f73a53d01d1d6cee68adbb31d6d9177a8cfce093cced1d50" dependencies = [ "futures-core", "pin-project-lite", ] [[package]] name = "pango" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35be456fc620e61f62dff7ff70fbd54dcbaf0a4b920c0f16de1107c47d921d48" dependencies = [ "bitflags 1.3.2", "gio", "glib", "libc", "once_cell", "pango-sys", ] [[package]] name = "pango-sys" version = "0.17.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3da69f9f3850b0d8990d462f8c709561975e95f689c1cdf0fecdebde78b35195" dependencies = [ "glib-sys", "gobject-sys", "libc", "system-deps", ] [[package]] name = "parking" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb813b8af86854136c6922af0598d719255ecb2179515e6e7730d468f05c9cae" [[package]] name = "pin-project-lite" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "piper" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96c8c490f422ef9a4efd2cb5b42b76c8613d7e7dfc1caf667b8a3350a5acc066" dependencies = [ "atomic-waker", "fastrand 2.1.1", "futures-io", ] [[package]] name = "pkg-config" version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" [[package]] name = "polling" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b2d323e8ca7996b3e23126511a523f7e62924d93ecd5ae73b333815b0eb3dce" dependencies = [ "autocfg", "bitflags 1.3.2", "cfg-if", "concurrent-queue", "libc", "log", "pin-project-lite", "windows-sys 0.48.0", ] [[package]] name = "polling" version = "3.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511" dependencies = [ "cfg-if", "concurrent-queue", "hermit-abi 0.4.0", "pin-project-lite", "rustix 0.38.35", "tracing", "windows-sys 0.59.0", ] [[package]] name = "ppv-lite86" version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" dependencies = [ "zerocopy", ] [[package]] name = "proc-macro-crate" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", "toml_edit 0.19.15", ] [[package]] name = "proc-macro-crate" version = "3.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8ecf48c7ca261d60b74ab1a7b20da18bede46776b2e55535cb958eb595c5fa7b" dependencies = [ "toml_edit 0.22.20", ] [[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.109", "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.86" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] [[package]] name = "pulsectl-rs" version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06a988bceed1981b2c5fc4a3da0e4e073fdaff8e6bd022b089f54bc573dc3cfc" dependencies = [ "libpulse-binding", ] [[package]] name = "quote" version = "1.0.37" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha", "rand_core", ] [[package]] name = "rand_chacha" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom", ] [[package]] name = "rustc_version" version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" dependencies = [ "semver", ] [[package]] name = "rustix" version = "0.37.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea8ca367a3a01fe35e6943c400addf443c0f57670e6ec51196f71a4b8762dd2" dependencies = [ "bitflags 1.3.2", "errno", "io-lifetimes", "libc", "linux-raw-sys 0.3.8", "windows-sys 0.48.0", ] [[package]] name = "rustix" version = "0.38.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" dependencies = [ "bitflags 2.6.0", "errno", "libc", "linux-raw-sys 0.4.14", "windows-sys 0.52.0", ] [[package]] name = "semver" version = "1.0.23" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" [[package]] name = "serde" version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99fce0ffe7310761ca6bf9faf5115afbc19688edd00171d81b1bb1b116c63e09" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" version = "1.0.209" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a5831b979fd7b5439637af1752d535ff49f4860c0f341d1baeb6faf0f4242170" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "serde_repr" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c64451ba24fc7a6a2d60fc75dd9c83c90903b19028d4eff35e88fc1e86564e9" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "serde_spanned" version = "0.6.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb5b1b31579f3811bf615c144393417496f152e12ac8b7663bf664f4a815306d" dependencies = [ "serde", ] [[package]] name = "sha1" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba" dependencies = [ "cfg-if", "cpufeatures", "digest", ] [[package]] name = "shlex" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "shrinkwraprs" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e63e6744142336dfb606fe2b068afa2e1cca1ee6a5d8377277a92945d81fa331" dependencies = [ "bitflags 1.3.2", "itertools", "proc-macro2", "quote", "syn 1.0.109", ] [[package]] name = "signal-hook-registry" version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1" dependencies = [ "libc", ] [[package]] name = "slab" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" dependencies = [ "autocfg", ] [[package]] name = "smallvec" version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "socket2" version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7916fc008ca5542385b89a3d3ce689953c143e9304a9bf8beec1de48994c0d" dependencies = [ "libc", "winapi", ] [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "substring" version = "1.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ee6433ecef213b2e72f587ef64a2f5943e7cd16fbd82dbe8bc07486c534c86" dependencies = [ "autocfg", ] [[package]] name = "swayosd" version = "0.1.0" dependencies = [ "anyhow", "async-std", "blight", "cascade", "evdev-rs", "gtk", "gtk-layer-shell", "input", "lazy_static", "libc", "libpulse-binding", "nix 0.26.4", "pulsectl-rs", "serde", "serde_derive", "shrinkwraprs", "substring", "thiserror", "toml", "zbus", ] [[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.77" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "system-deps" version = "6.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" dependencies = [ "cfg-expr", "heck 0.5.0", "pkg-config", "toml", "version-compare", ] [[package]] name = "target-lexicon" version = "0.12.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" version = "3.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" dependencies = [ "cfg-if", "fastrand 2.1.1", "once_cell", "rustix 0.38.35", "windows-sys 0.59.0", ] [[package]] name = "thiserror" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "toml" version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ "serde", "serde_spanned", "toml_datetime", "toml_edit 0.22.20", ] [[package]] name = "toml_datetime" version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" dependencies = [ "serde", ] [[package]] name = "toml_edit" version = "0.19.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" dependencies = [ "indexmap", "toml_datetime", "winnow 0.5.40", ] [[package]] name = "toml_edit" version = "0.22.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "583c44c02ad26b0c3f3066fe629275e50627026c51ac2e595cca4c230ce1ce1d" dependencies = [ "indexmap", "serde", "serde_spanned", "toml_datetime", "winnow 0.6.18", ] [[package]] name = "tracing" version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ "pin-project-lite", "tracing-attributes", "tracing-core", ] [[package]] name = "tracing-attributes" version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "udev" version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebdbbd670373442a12fe9ef7aeb53aec4147a5a27a00bbc3ab639f08f48191a" dependencies = [ "libc", "libudev-sys", "pkg-config", ] [[package]] name = "uds_windows" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89daebc3e6fd160ac4aa9fc8b3bf71e1f74fbf92367ae71fb83a037e8bf164b9" dependencies = [ "memoffset 0.9.1", "tempfile", "winapi", ] [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "value-bag" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" [[package]] name = "version-compare" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" [[package]] name = "version_check" version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] name = "waker-fn" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "317211a0dc0ceedd78fb2ca9a44aed3d7b9b26f81870d485c07122b4350673b7" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" dependencies = [ "cfg-if", "once_cell", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn 2.0.77", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.43" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" dependencies = [ "cfg-if", "js-sys", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.93" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" [[package]] name = "web-sys" version = "0.3.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" dependencies = [ "js-sys", "wasm-bindgen", ] [[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-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-sys" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets 0.48.5", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-sys" version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ "windows-targets 0.52.6", ] [[package]] name = "windows-targets" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ "windows_aarch64_gnullvm 0.48.5", "windows_aarch64_msvc 0.48.5", "windows_i686_gnu 0.48.5", "windows_i686_msvc 0.48.5", "windows_x86_64_gnu 0.48.5", "windows_x86_64_gnullvm 0.48.5", "windows_x86_64_msvc 0.48.5", ] [[package]] name = "windows-targets" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ "windows_aarch64_gnullvm 0.52.6", "windows_aarch64_msvc 0.52.6", "windows_i686_gnu 0.52.6", "windows_i686_gnullvm", "windows_i686_msvc 0.52.6", "windows_x86_64_gnu 0.52.6", "windows_x86_64_gnullvm 0.52.6", "windows_x86_64_msvc 0.52.6", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" [[package]] name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] [[package]] name = "winnow" version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" dependencies = [ "memchr", ] [[package]] name = "xdg-home" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec1cdab258fb55c0da61328dc52c8764709b249011b2cad0454c72f0bf10a1f6" dependencies = [ "libc", "windows-sys 0.59.0", ] [[package]] name = "zbus" version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb97012beadd29e654708a0fdb4c84bc046f537aecfde2c3ee0a9e4b4d48c725" dependencies = [ "async-broadcast", "async-executor", "async-fs", "async-io 2.3.4", "async-lock 3.4.0", "async-process", "async-recursion", "async-task", "async-trait", "blocking", "enumflags2", "event-listener 5.3.1", "futures-core", "futures-sink", "futures-util", "hex", "nix 0.29.0", "ordered-stream", "rand", "serde", "serde_repr", "sha1", "static_assertions", "tracing", "uds_windows", "windows-sys 0.52.0", "xdg-home", "zbus_macros", "zbus_names", "zvariant", ] [[package]] name = "zbus_macros" version = "4.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "267db9407081e90bbfa46d841d3cbc60f59c0351838c4bc65199ecd79ab1983e" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 2.0.77", "zvariant_utils", ] [[package]] name = "zbus_names" version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b9b1fef7d021261cc16cba64c351d291b715febe0fa10dc3a443ac5a5022e6c" dependencies = [ "serde", "static_assertions", "zvariant", ] [[package]] name = "zerocopy" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" dependencies = [ "byteorder", "zerocopy-derive", ] [[package]] name = "zerocopy-derive" version = "0.7.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] [[package]] name = "zvariant" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2084290ab9a1c471c38fc524945837734fbf124487e105daec2bb57fd48c81fe" dependencies = [ "endi", "enumflags2", "serde", "static_assertions", "zvariant_derive", ] [[package]] name = "zvariant_derive" version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73e2ba546bda683a90652bac4a279bc146adad1386f25379cf73200d2002c449" dependencies = [ "proc-macro-crate 3.2.0", "proc-macro2", "quote", "syn 2.0.77", "zvariant_utils", ] [[package]] name = "zvariant_utils" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c51bcff7cc3dbb5055396bcf774748c3dab426b4b8659046963523cee4808340" dependencies = [ "proc-macro2", "quote", "syn 2.0.77", ] SwayOSD-0.1.0/Cargo.toml000066400000000000000000000015141467037200400147350ustar00rootroot00000000000000[package] name = "swayosd" version = "0.1.0" edition = "2021" [[bin]] name = "swayosd-server" path = "src/server/main.rs" [[bin]] name = "swayosd-client" path = "src/client/main.rs" [[bin]] name = "swayosd-libinput-backend" path = "src/input-backend/main.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] # Config dependencies toml = "0.8" serde = "1" serde_derive = "1" # GUI Dependencies gtk = "0.17.1" gtk-layer-shell = "0.6.1" shrinkwraprs = "0.3.0" cascade = "1.0.1" pulse = { version = "2.26.0", package = "libpulse-binding" } pulsectl-rs = "0.3.2" substring = "1.4.5" lazy_static = "1.4.0" zbus = "4" # Backend Dependencies input = "0.8" libc = "0.2.147" evdev-rs = "0.6.1" async-std = "1.12.0" nix = "0.26.2" blight = "0.7.0" anyhow = "1.0.75" thiserror = "1.0.49" SwayOSD-0.1.0/LICENSE000066400000000000000000001045151467037200400140170ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 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 . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . SwayOSD-0.1.0/README.md000066400000000000000000000100731467037200400142640ustar00rootroot00000000000000# SwayOSD A OSD window for common actions like volume and capslock. This is my first time coding in Rust so fixes and improvements are appreciated :) ## Features: - LibInput listener Backend for these keys: - Caps Lock - Num Lock - Scroll Lock - Input and output volume change indicator - Input and output mute change indicator - Customizable maximum Volume - Capslock change (Note: doesn't change the caps lock state) - Brightness change indicator ## Images ![image](https://user-images.githubusercontent.com/35975961/200685357-fb9697ae-a32d-4c60-a2ae-7791e70097b9.png) ![image](https://user-images.githubusercontent.com/35975961/200685469-96c3398f-0169-4d13-8df0-90951e30ff33.png) ## Install: There's a new LibInput watcher binary shipped with SwayOSD (`swayosd-libinput-backend`) which can automatically detect key presses, so no need for binding key combos. The supported keys are listed above in [Features](#features) ### Through Meson ```zsh # Please note that the command below might require `--prefix /usr` on some systems meson setup build ninja -C build meson install -C build ``` ### AUR Available on the AUR thanks to @jgmdev! (Don't open a issue here about AUR package) - [swayosd-git](https://aur.archlinux.org/packages/swayosd-git) ## Usage: ### SwayOSD LibInput Backend Using Systemd: `sudo systemctl enable --now swayosd-libinput-backend.service` Other users can run: `pkexec swayosd-libinput-backend` ### SwayOSD Frontend #### Sway examples ##### Start Server ```zsh # OSD server exec swayosd-server ``` ##### Add Client bindings ```zsh # Sink volume raise optionally with --device bindsym XF86AudioRaiseVolume exec swayosd-client --output-volume raise # Sink volume lower optionally with --device bindsym XF86AudioLowerVolume exec swayosd-client --output-volume lower --device alsa_output.pci-0000_11_00.4.analog-stereo.monitor # Sink volume toggle mute bindsym XF86AudioMute exec swayosd-client --output-volume mute-toggle # Source volume toggle mute bindsym XF86AudioMicMute exec swayosd-client --input-volume mute-toggle # Volume raise with custom value bindsym XF86AudioRaiseVolume exec swayosd-client --output-volume 15 # Volume lower with custom value bindsym XF86AudioLowerVolume exec swayosd-client --output-volume -15 # Volume raise with max value bindsym XF86AudioRaiseVolume exec swayosd-client --output-volume raise --max-volume 120 # Volume lower with max value bindsym XF86AudioLowerVolume exec swayosd-client --output-volume lower --max-volume 120 # Sink volume raise with custom value optionally with --device bindsym XF86AudioRaiseVolume exec swayosd-client --output-volume +10 --device alsa_output.pci-0000_11_00.4.analog-stereo.monitor # Sink volume lower with custom value optionally with --device bindsym XF86AudioLowerVolume exec swayosd-client --output-volume -10 --device alsa_output.pci-0000_11_00.4.analog-stereo.monitor # Capslock (If you don't want to use the backend) bindsym --release Caps_Lock exec swayosd-client --caps-lock # Capslock but specific LED name (/sys/class/leds/) bindsym --release Caps_Lock exec swayosd-client --caps-lock-led input19::capslock # Brightness raise bindsym XF86MonBrightnessUp exec swayosd-client --brightness raise # Brightness lower bindsym XF86MonBrightnessDown exec swayosd-client --brightness lower # Brightness raise with custom value('+' sign needed) bindsym XF86MonBrightnessUp exec swayosd-client --brightness +10 # Brightness lower with custom value('-' sign needed) bindsym XF86MonBrightnessDown exec swayosd-client --brightness -10 ``` ### Notes on using `--device`: - It is for audio devices only. - If it is omitted the default audio device is used. - It only changes the target device for the current action that changes the volume. - You can list your input audio devices using `pactl list short sources`, for outputs replace `sources` with `sinks`. ## Brightness Control Some devices may not have permission to write `/sys/class/backlight/*/brightness`. So using the provided packaged `udev` rules + adding the user to `video` group by running `sudo usermod -a -G video $USER`, everything should work as expected. SwayOSD-0.1.0/build.rs000066400000000000000000000005211467037200400144470ustar00rootroot00000000000000use std::{env, process::Command}; fn main() { let output = Command::new("glib-compile-resources") .args(&["./data/swayosd.gresource.xml", "--sourcedir=./data"]) .arg(&format!( "--target={}/swayosd.gresource", env::var("OUT_DIR").unwrap() )) .status() .expect("failed to execute process"); assert!(output.success()); } SwayOSD-0.1.0/data/000077500000000000000000000000001467037200400137155ustar00rootroot00000000000000SwayOSD-0.1.0/data/dbus/000077500000000000000000000000001467037200400146525ustar00rootroot00000000000000SwayOSD-0.1.0/data/dbus/org.erikreider.swayosd.conf000066400000000000000000000015421467037200400221260ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/000077500000000000000000000000001467037200400150305ustar00rootroot00000000000000SwayOSD-0.1.0/data/icons/scalable/000077500000000000000000000000001467037200400165765ustar00rootroot00000000000000SwayOSD-0.1.0/data/icons/scalable/status/000077500000000000000000000000001467037200400201215ustar00rootroot00000000000000SwayOSD-0.1.0/data/icons/scalable/status/caps-lock-symbolic.svg000066400000000000000000000027531467037200400243440ustar00rootroot00000000000000 image/svg+xml SwayOSD-0.1.0/data/icons/scalable/status/display-brightness-symbolic.svg000066400000000000000000000041551467037200400263010ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/missing-symbolic.svg000066400000000000000000000015141467037200400241330ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/num-lock-symbolic.svg000066400000000000000000000020321467037200400242030ustar00rootroot00000000000000 image/svg+xml SwayOSD-0.1.0/data/icons/scalable/status/scroll-lock-symbolic.svg000066400000000000000000000015521467037200400247100ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/sink-volume-high-symbolic.svg000066400000000000000000000026501467037200400256520ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/sink-volume-low-symbolic.svg000066400000000000000000000016161467037200400255350ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/sink-volume-medium-symbolic.svg000066400000000000000000000027611467037200400262160ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/sink-volume-muted-symbolic.svg000066400000000000000000000021251467037200400260460ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/sink-volume-overamplified-symbolic.svg000066400000000000000000000012451467037200400275600ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/source-volume-high-symbolic.svg000066400000000000000000000010421467037200400262000ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/source-volume-low-symbolic.svg000066400000000000000000000012711467037200400260660ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/source-volume-medium-symbolic.svg000066400000000000000000000012721467037200400265460ustar00rootroot00000000000000 SwayOSD-0.1.0/data/icons/scalable/status/source-volume-muted-symbolic.svg000066400000000000000000000040521467037200400264030ustar00rootroot00000000000000 SwayOSD-0.1.0/data/meson.build000066400000000000000000000036021467037200400160600ustar00rootroot00000000000000datadir = get_option('datadir') libdir = get_option('libdir') # LICENSE install_data( '../LICENSE', install_dir: join_paths(datadir, 'licenses', meson.project_name()) ) # udev rules install_data( join_paths('udev', '99-swayosd.rules'), install_dir: join_paths(libdir, 'udev', 'rules.d') ) # Dbus conf install_data( join_paths('dbus', 'org.erikreider.swayosd.conf'), install_dir: join_paths(datadir, 'dbus-1', 'system.d') ) # Polkit rule install_data( join_paths('polkit', 'rules', 'org.erikreider.swayosd.rules'), install_dir: join_paths(datadir, 'polkit-1', 'rules.d') ) # Polkit policy conf_data = configuration_data() conf_data.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) configure_file( input: join_paths('polkit', 'actions', 'org.erikreider.swayosd.policy.in'), output: 'org.erikreider.swayosd.policy', configuration: conf_data, install: true, install_dir: join_paths(datadir, 'polkit-1', 'actions') ) # Dbus service configure_file( configuration: conf_data, input: join_paths('services', 'dbus', 'org.erikreider.swayosd.service.in'), output: '@BASENAME@', install_dir: datadir + '/dbus-1/system-services' ) # Systemd service unit systemd = dependency('systemd', required: false) if systemd.found() systemd_service_install_dir = systemd.get_variable(pkgconfig :'systemdsystemunitdir') else systemd_service_install_dir = join_paths(libdir, 'systemd', 'system') endif configure_file( configuration: conf_data, input: join_paths('services', 'systemd', 'swayosd-libinput-backend.service.in'), output: '@BASENAME@', install_dir: systemd_service_install_dir ) # SCSS Compilation style_css = custom_target( 'SCSS Compilation', build_by_default: true, input : 'style/style.scss', output : 'style.css', install: true, install_dir: config_path, command : [ sassc, '@INPUT@', '@OUTPUT@' ], ) message(style_css.full_path()) SwayOSD-0.1.0/data/polkit/000077500000000000000000000000001467037200400152175ustar00rootroot00000000000000SwayOSD-0.1.0/data/polkit/actions/000077500000000000000000000000001467037200400166575ustar00rootroot00000000000000SwayOSD-0.1.0/data/polkit/actions/org.erikreider.swayosd.policy.in000066400000000000000000000015511467037200400251120ustar00rootroot00000000000000 Run the backend as root to read input devices through libinput. pkexec @bindir@/swayosd-libinput-backend auth_admin auth_admin auth_admin_keep @bindir@/swayosd-libinput-backend false SwayOSD-0.1.0/data/polkit/rules/000077500000000000000000000000001467037200400163515ustar00rootroot00000000000000SwayOSD-0.1.0/data/polkit/rules/org.erikreider.swayosd.rules000066400000000000000000000003751467037200400240350ustar00rootroot00000000000000// vim: ft=javascript // Allow "wheel" group users to run the swayosd backend polkit.addRule(function(action, subject) { if (action.id == "org.erikreider.swayosd-libinput-backend" && subject.isInGroup("wheel")) { return polkit.Result.YES; } }); SwayOSD-0.1.0/data/services/000077500000000000000000000000001467037200400155405ustar00rootroot00000000000000SwayOSD-0.1.0/data/services/dbus/000077500000000000000000000000001467037200400164755ustar00rootroot00000000000000SwayOSD-0.1.0/data/services/dbus/org.erikreider.swayosd.service.in000066400000000000000000000001661467037200400250720ustar00rootroot00000000000000[D-BUS Service] Name=org.erikreider.swayosd Exec=/bin/false User=root SystemdService=swayosd-libinput-backend.service SwayOSD-0.1.0/data/services/systemd/000077500000000000000000000000001467037200400172305ustar00rootroot00000000000000SwayOSD-0.1.0/data/services/systemd/swayosd-libinput-backend.service.in000066400000000000000000000005611467037200400261230ustar00rootroot00000000000000[Unit] Description=SwayOSD LibInput backend for listening to certain keys like CapsLock, ScrollLock, VolumeUp, etc... Documentation=https://github.com/ErikReider/SwayOSD PartOf=graphical.target After=graphical.target [Service] Type=dbus BusName=org.erikreider.swayosd ExecStart=@bindir@/swayosd-libinput-backend Restart=on-failure [Install] WantedBy=graphical.target SwayOSD-0.1.0/data/style/000077500000000000000000000000001467037200400150555ustar00rootroot00000000000000SwayOSD-0.1.0/data/style/style.scss000066400000000000000000000012271467037200400171140ustar00rootroot00000000000000window#osd { padding: 12px 20px; border-radius: 999px; border: none; background: #{"alpha(@theme_bg_color, 0.8)"}; #container { margin: 16px; } image, label { color: #{"@theme_fg_color"}; } progressbar:disabled, image:disabled { opacity: 0.5; } progressbar { min-height: 6px; border-radius: 999px; background: transparent; border: none; } trough { min-height: inherit; border-radius: inherit; border: none; background: #{"alpha(@theme_fg_color, 0.5)"}; } progress { min-height: inherit; border-radius: inherit; border: none; background: #{"@theme_fg_color"}; } } SwayOSD-0.1.0/data/swayosd.gresource.xml000066400000000000000000000021031467037200400201210ustar00rootroot00000000000000 icons/scalable/status/missing-symbolic.svg icons/scalable/status/caps-lock-symbolic.svg icons/scalable/status/num-lock-symbolic.svg icons/scalable/status/scroll-lock-symbolic.svg icons/scalable/status/display-brightness-symbolic.svg icons/scalable/status/sink-volume-overamplified-symbolic.svg icons/scalable/status/sink-volume-high-symbolic.svg icons/scalable/status/sink-volume-medium-symbolic.svg icons/scalable/status/sink-volume-low-symbolic.svg icons/scalable/status/sink-volume-muted-symbolic.svg icons/scalable/status/source-volume-high-symbolic.svg icons/scalable/status/source-volume-medium-symbolic.svg icons/scalable/status/source-volume-low-symbolic.svg icons/scalable/status/source-volume-muted-symbolic.svg SwayOSD-0.1.0/data/udev/000077500000000000000000000000001467037200400146605ustar00rootroot00000000000000SwayOSD-0.1.0/data/udev/99-swayosd.rules000066400000000000000000000003021467037200400176570ustar00rootroot00000000000000ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chgrp video /sys/class/backlight/%k/brightness" ACTION=="add", SUBSYSTEM=="backlight", RUN+="/bin/chmod g+w /sys/class/backlight/%k/brightness" SwayOSD-0.1.0/meson.build000066400000000000000000000006341467037200400151510ustar00rootroot00000000000000project('swayosd', 'rust', version: '0.1.0', meson_version: '>= 0.62.0', default_options: [ 'warning_level=2', 'werror=false', ], ) config_path = join_paths(get_option('sysconfdir'), 'xdg', 'swayosd') # glib-compile-resources Dependency assert(find_program('glib-compile-resources').found()) # SCSS Dependency sassc = find_program('sassc') assert(sassc.found()) subdir('data') subdir('src') SwayOSD-0.1.0/rust-toolchain000066400000000000000000000000101467037200400156710ustar00rootroot00000000000000nightly SwayOSD-0.1.0/rustfmt.toml000066400000000000000000000037051467037200400154120ustar00rootroot00000000000000max_width = 100 hard_tabs = true tab_spaces = 4 newline_style = "Auto" indent_style = "Block" use_small_heuristics = "Default" fn_call_width = 60 attr_fn_like_width = 70 struct_lit_width = 18 struct_variant_width = 35 array_width = 60 chain_width = 60 single_line_if_else_max_width = 50 wrap_comments = false format_code_in_doc_comments = false doc_comment_code_block_width = 100 comment_width = 80 normalize_comments = false normalize_doc_attributes = false format_strings = false format_macro_matchers = false format_macro_bodies = true hex_literal_case = "Preserve" empty_item_single_line = true struct_lit_single_line = true fn_single_line = false where_single_line = false imports_indent = "Block" imports_layout = "Mixed" imports_granularity = "Preserve" group_imports = "Preserve" reorder_imports = true reorder_modules = true reorder_impl_items = false type_punctuation_density = "Wide" space_before_colon = false space_after_colon = true spaces_around_ranges = false binop_separator = "Front" remove_nested_parens = true combine_control_expr = true short_array_element_width_threshold = 10 overflow_delimited_expr = false struct_field_align_threshold = 0 enum_discrim_align_threshold = 0 match_arm_blocks = true match_arm_leading_pipes = "Never" force_multiline_blocks = false fn_params_layout = "Tall" brace_style = "SameLineWhere" control_brace_style = "AlwaysSameLine" trailing_semicolon = true trailing_comma = "Vertical" match_block_trailing_comma = false blank_lines_upper_bound = 1 blank_lines_lower_bound = 0 edition = "2015" version = "One" inline_attribute_width = 0 format_generated_files = true merge_derives = true use_try_shorthand = false use_field_init_shorthand = false force_explicit_abi = true condense_wildcard_suffixes = false color = "Auto" unstable_features = false disable_all_formatting = false skip_children = false hide_parse_errors = false error_on_line_overflow = false error_on_unformatted = false ignore = [] emit_mode = "Files" make_backup = false SwayOSD-0.1.0/src/000077500000000000000000000000001467037200400135735ustar00rootroot00000000000000SwayOSD-0.1.0/src/argtypes.rs000066400000000000000000000051711467037200400160030ustar00rootroot00000000000000use std::fmt; use std::str::{self}; #[derive(Clone, Debug, PartialEq, PartialOrd)] pub enum ArgTypes { // should always be first to set a global variable before executing related functions DeviceName = isize::MIN, TopMargin = isize::MIN + 1, MaxVolume = isize::MIN + 2, CustomIcon = isize::MIN + 3, // Other None = 0, CapsLock = 1, SinkVolumeRaise = 2, SinkVolumeLower = 3, SinkVolumeMuteToggle = 4, SourceVolumeRaise = 5, SourceVolumeLower = 6, SourceVolumeMuteToggle = 7, BrightnessRaise = 8, BrightnessLower = 9, BrightnessSet = 12, NumLock = 10, ScrollLock = 11, CustomMessage = 13, } impl fmt::Display for ArgTypes { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let string = match self { ArgTypes::None => "NONE", ArgTypes::CapsLock => "CAPSLOCK", ArgTypes::MaxVolume => "MAX-VOLUME", ArgTypes::SinkVolumeRaise => "SINK-VOLUME-RAISE", ArgTypes::SinkVolumeLower => "SINK-VOLUME-LOWER", ArgTypes::SinkVolumeMuteToggle => "SINK-VOLUME-MUTE-TOGGLE", ArgTypes::SourceVolumeRaise => "SOURCE-VOLUME-RAISE", ArgTypes::SourceVolumeLower => "SOURCE-VOLUME-LOWER", ArgTypes::SourceVolumeMuteToggle => "SOURCE-VOLUME-MUTE-TOGGLE", ArgTypes::BrightnessRaise => "BRIGHTNESS-RAISE", ArgTypes::BrightnessLower => "BRIGHTNESS-LOWER", ArgTypes::BrightnessSet => "BRIGHTNESS-SET", ArgTypes::NumLock => "NUM-LOCK", ArgTypes::ScrollLock => "SCROLL-LOCK", ArgTypes::DeviceName => "DEVICE-NAME", ArgTypes::TopMargin => "TOP-MARGIN", ArgTypes::CustomMessage => "CUSTOM-MESSAGE", ArgTypes::CustomIcon => "CUSTOM-ICON", }; return write!(f, "{}", string); } } impl str::FromStr for ArgTypes { type Err = String; fn from_str(input: &str) -> Result { let result = match input { "CAPSLOCK" => ArgTypes::CapsLock, "SINK-VOLUME-RAISE" => ArgTypes::SinkVolumeRaise, "SINK-VOLUME-LOWER" => ArgTypes::SinkVolumeLower, "SINK-VOLUME-MUTE-TOGGLE" => ArgTypes::SinkVolumeMuteToggle, "SOURCE-VOLUME-RAISE" => ArgTypes::SourceVolumeRaise, "SOURCE-VOLUME-LOWER" => ArgTypes::SourceVolumeLower, "SOURCE-VOLUME-MUTE-TOGGLE" => ArgTypes::SourceVolumeMuteToggle, "BRIGHTNESS-RAISE" => ArgTypes::BrightnessRaise, "BRIGHTNESS-LOWER" => ArgTypes::BrightnessLower, "BRIGHTNESS-SET" => ArgTypes::BrightnessSet, "MAX-VOLUME" => ArgTypes::MaxVolume, "NUM-LOCK" => ArgTypes::NumLock, "SCROLL-LOCK" => ArgTypes::ScrollLock, "DEVICE-NAME" => ArgTypes::DeviceName, "TOP-MARGIN" => ArgTypes::TopMargin, "CUSTOM-MESSAGE" => ArgTypes::CustomMessage, "CUSTOM-ICON" => ArgTypes::CustomIcon, other_type => return Err(other_type.to_owned()), }; Ok(result) } } SwayOSD-0.1.0/src/brightness_backend/000077500000000000000000000000001467037200400174125ustar00rootroot00000000000000SwayOSD-0.1.0/src/brightness_backend/blight.rs000066400000000000000000000016311467037200400212320ustar00rootroot00000000000000use blight::{Device, Direction}; use super::{BrightnessBackend, BrightnessBackendConstructor}; pub(super) struct Blight { device: Device, } impl BrightnessBackendConstructor for Blight { fn try_new(device_name: Option) -> anyhow::Result { Ok(Self { device: Device::new(device_name.map(Into::into))?, }) } } impl BrightnessBackend for Blight { fn get_current(&mut self) -> u32 { self.device.reload(); self.device.current() } fn get_max(&mut self) -> u32 { self.device.max() } fn lower(&mut self, by: u32) -> anyhow::Result<()> { let val = self.device.calculate_change(by, Direction::Dec); Ok(self.device.write_value(val)?) } fn raise(&mut self, by: u32) -> anyhow::Result<()> { let val = self.device.calculate_change(by, Direction::Inc); Ok(self.device.write_value(val)?) } fn set(&mut self, val: u32) -> anyhow::Result<()> { Ok(self.device.write_value(val)?) } } SwayOSD-0.1.0/src/brightness_backend/brightnessctl.rs000066400000000000000000000065421467037200400226420ustar00rootroot00000000000000use super::{BrightnessBackend, BrightnessBackendConstructor}; const EXPECT_STR: &str = "VirtualDevice didn't test the command during initialization"; use anyhow::bail; use std::{error::Error, process::Command, str::FromStr}; use thiserror::Error; enum CliArg<'arg> { Simple(&'arg str), KeyValue { key: &'arg str, value: &'arg str }, } impl<'arg> From<&'arg str> for CliArg<'arg> { fn from(value: &'arg str) -> Self { CliArg::Simple(value) } } impl<'arg> From<(&'arg str, &'arg str)> for CliArg<'arg> { fn from((key, value): (&'arg str, &'arg str)) -> Self { CliArg::KeyValue { key, value } } } #[derive(Default)] struct VirtualDevice { name: Option, current: Option, max: Option, } pub(super) struct BrightnessCtl { device: VirtualDevice, } #[derive(Error, Debug)] #[error("Requested device '{device_name}' does not exist ")] pub struct DeviceDoesntExistError { device_name: String, } impl VirtualDevice { fn try_new(device_name: Option) -> anyhow::Result { let s = Self { name: device_name.clone(), ..Default::default() }; // Check if the command is available to us before running it in other occasions let exit_code = s.command(CliArg::Simple("info")).output()?.status; if exit_code.success() { Ok(s) } else { bail!(DeviceDoesntExistError { device_name: device_name.unwrap() }) } } fn command(&self, arg: CliArg) -> Command { let mut cmd = Command::new("brightnessctl"); if let Some(name) = &self.name { cmd.arg("--device").arg(name); } match arg { CliArg::Simple(arg) => cmd.arg(arg), CliArg::KeyValue { key, value } => cmd.arg(key).arg(value), }; cmd } fn run<'arg, T: FromStr, A: Into>>(&self, arg: A) -> anyhow::Result where ::Err: Error + Send + Sync + 'static, { let cmd_output = self.command(arg.into()).output()?.stdout; let cmd_output = String::from_utf8_lossy(&cmd_output); Ok(cmd_output.trim().parse()?) } fn get_current(&mut self) -> u32 { match self.current { Some(val) => val, None => { let val = self.run("get").expect(EXPECT_STR); self.current = Some(val); val } } } fn get_max(&mut self) -> u32 { match self.max { Some(val) => val, None => { let val = self.run("max").expect(EXPECT_STR); self.max = Some(val); val } } } fn set_percent(&mut self, mut val: u32) -> anyhow::Result<()> { val = val.clamp(0, 100); self.current = self.max.map(|max| val * max / 100); let _: String = self.run(("set", &*format!("{val}%")))?; Ok(()) } } impl BrightnessBackendConstructor for BrightnessCtl { fn try_new(device_name: Option) -> anyhow::Result { Ok(Self { device: VirtualDevice::try_new(device_name)?, }) } } impl BrightnessBackend for BrightnessCtl { fn get_current(&mut self) -> u32 { self.device.get_current() } fn get_max(&mut self) -> u32 { self.device.get_max() } fn lower(&mut self, by: u32) -> anyhow::Result<()> { let curr = self.get_current(); let max = self.get_max(); let curr = curr * 100 / max; self.device.set_percent(curr.saturating_sub(by)) } fn raise(&mut self, by: u32) -> anyhow::Result<()> { let curr = self.get_current(); let max = self.get_max(); let curr = curr * 100 / max; self.device.set_percent(curr + by) } fn set(&mut self, val: u32) -> anyhow::Result<()> { self.device.set_percent(val) } } SwayOSD-0.1.0/src/brightness_backend/mod.rs000066400000000000000000000021171467037200400205400ustar00rootroot00000000000000use self::{blight::Blight, brightnessctl::BrightnessCtl}; mod blight; mod brightnessctl; pub type BrightnessBackendResult = anyhow::Result>; pub trait BrightnessBackendConstructor: BrightnessBackend + Sized + 'static { fn try_new(device_name: Option) -> anyhow::Result; fn try_new_boxed(device_name: Option) -> BrightnessBackendResult { let backend = Self::try_new(device_name); match backend { Ok(backend) => Ok(Box::new(backend)), Err(e) => Err(e), } } } pub trait BrightnessBackend { fn get_current(&mut self) -> u32; fn get_max(&mut self) -> u32; fn lower(&mut self, by: u32) -> anyhow::Result<()>; fn raise(&mut self, by: u32) -> anyhow::Result<()>; fn set(&mut self, val: u32) -> anyhow::Result<()>; } #[allow(dead_code)] pub fn get_preferred_backend(device_name: Option) -> BrightnessBackendResult { println!("Trying BrightnessCtl Backend..."); BrightnessCtl::try_new_boxed(device_name.clone()).or_else(|_| { println!("...Command failed! Falling back to Blight"); Blight::try_new_boxed(device_name) }) } SwayOSD-0.1.0/src/client/000077500000000000000000000000001467037200400150515ustar00rootroot00000000000000SwayOSD-0.1.0/src/client/main.rs000066400000000000000000000133051467037200400163450ustar00rootroot00000000000000#[path = "../argtypes.rs"] mod argtypes; #[path = "../config.rs"] mod config; #[path = "../global_utils.rs"] mod global_utils; #[path = "../brightness_backend/mod.rs"] mod brightness_backend; use config::APPLICATION_NAME; use global_utils::{handle_application_args, HandleLocalStatus}; use gtk::glib::{OptionArg, OptionFlags}; use gtk::{gio::ApplicationFlags, Application}; use gtk::{glib, prelude::*}; use std::env::args_os; use std::path::PathBuf; use zbus::{blocking::Connection, dbus_proxy}; #[dbus_proxy( interface = "org.erikreider.swayosd", default_service = "org.erikreider.swayosd-server", default_path = "/org/erikreider/swayosd" )] trait Server { async fn handle_action(&self, arg_type: String, data: String) -> zbus::Result; } pub fn get_proxy() -> zbus::Result> { let connection = Connection::session()?; Ok(ServerProxyBlocking::new(&connection)?) } fn main() -> Result<(), glib::Error> { // Get config path from command line let mut config_path: Option = None; let mut args = args_os().into_iter(); while let Some(arg) = args.next() { match arg.to_str() { Some("--config") => { if let Some(path) = args.next() { config_path = Some(path.into()); } } _ => (), } } // Parse Config let _client_config = config::user::read_user_config(config_path.as_deref()) .expect("Failed to parse config file") .client; // Make sure that the server is running let proxy = match get_proxy() { Ok(proxy) => match proxy.0.introspect() { Ok(_) => proxy, Err(err) => { eprintln!("Could not connect to SwayOSD Server with error: {}", err); std::process::exit(1); } }, Err(err) => { eprintln!("Dbus error: {}", err); std::process::exit(1); } }; let app = Application::new(Some(APPLICATION_NAME), ApplicationFlags::FLAGS_NONE); // Config cmdline arg for documentation app.add_main_option( "config", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Use a custom config file instead of looking for one.", Some(""), ); // Capslock cmdline arg app.add_main_option( "caps-lock", glib::Char::from(0), OptionFlags::NONE, OptionArg::None, "Shows capslock osd. Note: Doesn't toggle CapsLock, just displays the status", None, ); app.add_main_option( "num-lock", glib::Char::from(0), OptionFlags::NONE, OptionArg::None, "Shows numlock osd. Note: Doesn't toggle NumLock, just displays the status", None, ); app.add_main_option( "scroll-lock", glib::Char::from(0), OptionFlags::NONE, OptionArg::None, "Shows scrolllock osd. Note: Doesn't toggle ScrollLock, just displays the status", None, ); // Capslock with specific LED cmdline arg app.add_main_option( "caps-lock-led", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows capslock osd. Uses LED class name. Note: Doesn't toggle CapsLock, just displays the status", Some("LED class name (/sys/class/leds/NAME)"), ); app.add_main_option( "num-lock-led", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows numlock osd. Uses LED class name. Note: Doesn't toggle NumLock, just displays the status", Some("LED class name (/sys/class/leds/NAME)"), ); app.add_main_option( "scroll-lock-led", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows scrolllock osd. Uses LED class name. Note: Doesn't toggle ScrollLock, just displays the status", Some("LED class name (/sys/class/leds/NAME)"), ); // Sink volume cmdline arg app.add_main_option( "output-volume", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows volume osd and raises, loweres or mutes default sink volume", Some("raise|lower|mute-toggle|(±)number"), ); // Source volume cmdline arg app.add_main_option( "input-volume", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows volume osd and raises, loweres or mutes default source volume", Some("raise|lower|mute-toggle|(±)number"), ); // Sink brightness cmdline arg app.add_main_option( "brightness", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Shows brightness osd and raises or loweres all available sources of brightness device", Some("raise|lower|(±)number"), ); app.add_main_option( "max-volume", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Sets the maximum Volume", Some("(+)number"), ); app.add_main_option( "device", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "For which device to increase/decrease audio", Some("Pulseaudio device name (pactl list short sinks|sources)"), ); app.add_main_option( "custom-message", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Message to display", Some("text"), ); app.add_main_option( "custom-icon", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Icon to display when using custom-message. Icon name is from Freedesktop specification (https://specifications.freedesktop.org/icon-naming-spec/latest/)", Some("Icon name"), ); // Parse args app.connect_handle_local_options(move |_app, args| { let variant = args.to_variant(); if variant.n_children() == 0 { eprintln!("No args provided..."); return HandleLocalStatus::FAILURE as i32; } let actions = match handle_application_args(variant) { (HandleLocalStatus::SUCCESS, actions) => actions, (status @ HandleLocalStatus::FAILURE, _) => return status as i32, (status @ HandleLocalStatus::CONTINUE, _) => return status as i32, }; // execute the sorted actions for (arg_type, data) in actions { let _ = proxy.handle_action(arg_type.to_string(), data.unwrap_or(String::new())); } HandleLocalStatus::SUCCESS as i32 }); std::process::exit(app.run().into()); } SwayOSD-0.1.0/src/config.rs000066400000000000000000000005461467037200400154130ustar00rootroot00000000000000#![allow(dead_code)] #[path = "config/backend.rs"] pub mod backend; #[path = "config/user.rs"] pub mod user; pub const DBUS_PATH: &str = "/org/erikreider/swayosd"; pub const DBUS_BACKEND_NAME: &str = "org.erikreider.swayosd"; pub const DBUS_SERVER_NAME: &str = "org.erikreider.swayosd-server"; pub const APPLICATION_NAME: &str = "org.erikreider.swayosd"; SwayOSD-0.1.0/src/config/000077500000000000000000000000001467037200400150405ustar00rootroot00000000000000SwayOSD-0.1.0/src/config/backend.rs000066400000000000000000000015501467037200400167760ustar00rootroot00000000000000use gtk::glib::system_config_dirs; use serde_derive::Deserialize; use std::error::Error; use std::path::PathBuf; #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct InputBackendConfig {} #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct BackendConfig { #[serde(default)] pub input: InputBackendConfig, } fn find_backend_config() -> Option { for path in system_config_dirs() { let path = path.join("swayosd").join("backend.toml"); if path.exists() { return Some(path); } } None } pub fn read_backend_config() -> Result> { let path = match find_backend_config() { Some(path) => path, None => return Ok(Default::default()), }; let config_file = std::fs::read_to_string(path)?; let config: BackendConfig = toml::from_str(&config_file)?; Ok(config) } SwayOSD-0.1.0/src/config/user.rs000066400000000000000000000024561467037200400163730ustar00rootroot00000000000000use gtk::glib::system_config_dirs; use gtk::glib::user_config_dir; use serde_derive::Deserialize; use std::error::Error; use std::path::Path; use std::path::PathBuf; #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct ClientConfig {} #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct ServerConfig { pub style: Option, pub top_margin: Option, pub max_volume: Option, pub show_percentage: Option, } #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] pub struct UserConfig { #[serde(default)] pub server: ServerConfig, #[serde(default)] pub client: ClientConfig, } fn find_user_config() -> Option { let path = user_config_dir().join("swayosd").join("config.toml"); if path.exists() { return Some(path); } for path in system_config_dirs() { let path = path.join("swayosd").join("config.toml"); if path.exists() { return Some(path); } } None } pub fn read_user_config(path: Option<&Path>) -> Result> { let path = match path.map(Path::to_owned).or_else(find_user_config) { Some(path) => path, None => return Ok(Default::default()), }; let config_file = std::fs::read_to_string(path)?; let config: UserConfig = toml::from_str(&config_file)?; Ok(config) } SwayOSD-0.1.0/src/global_utils.rs000066400000000000000000000132141467037200400166220ustar00rootroot00000000000000use gtk::glib::{variant::DictEntry, Variant}; use crate::argtypes::ArgTypes; pub enum HandleLocalStatus { FAILURE = 1, SUCCESS = 0, CONTINUE = -1, } pub(crate) fn handle_application_args( variant: Variant, ) -> (HandleLocalStatus, Vec<(ArgTypes, Option)>) { let mut actions: Vec<(ArgTypes, Option)> = Vec::new(); if variant.n_children() == 0 { return (HandleLocalStatus::CONTINUE, actions); } if !variant.is_container() { eprintln!("VariantDict isn't a container!..."); return (HandleLocalStatus::FAILURE, actions); } for i in 0..variant.n_children() { let child: DictEntry = variant.child_get(i); let (option, value): (ArgTypes, Option) = match child.key().as_str() { "caps-lock" => (ArgTypes::CapsLock, None), "num-lock" => (ArgTypes::NumLock, None), "scroll-lock" => (ArgTypes::ScrollLock, None), "caps-lock-led" => match child.value().str() { Some(led) => (ArgTypes::CapsLock, Some(led.to_owned())), None => { eprintln!("Value for caps-lock-led isn't a string!..."); return (HandleLocalStatus::FAILURE, actions); } }, "num-lock-led" => match child.value().str() { Some(led) => (ArgTypes::NumLock, Some(led.to_owned())), None => { eprintln!("Value for num-lock-led isn't a string!..."); return (HandleLocalStatus::FAILURE, actions); } }, "scroll-lock-led" => match child.value().str() { Some(led) => (ArgTypes::ScrollLock, Some(led.to_owned())), None => { eprintln!("Value for scroll-lock-led isn't a string!..."); return (HandleLocalStatus::FAILURE, actions); } }, "output-volume" => { let value = child.value().str().unwrap_or(""); let parsed = volume_parser(false, value); match parsed { Ok(p) => p, Err(_) => return (HandleLocalStatus::FAILURE, actions), } } "input-volume" => { let value = child.value().str().unwrap_or(""); let parsed = volume_parser(true, value); match parsed { Ok(p) => p, Err(_) => return (HandleLocalStatus::FAILURE, actions), } } "brightness" => { let value = child.value().str().unwrap_or(""); match (value, value.parse::()) { // Parse custom step values (_, Ok(num)) => match value.get(..1) { Some("+") => (ArgTypes::BrightnessRaise, Some(num.to_string())), Some("-") => (ArgTypes::BrightnessLower, Some(num.abs().to_string())), _ => (ArgTypes::BrightnessSet, Some(num.to_string())), }, ("raise", _) => (ArgTypes::BrightnessRaise, None), ("lower", _) => (ArgTypes::BrightnessLower, None), (e, _) => { eprintln!("Unknown brightness mode: \"{}\"!...", e); return (HandleLocalStatus::FAILURE, actions); } } } "max-volume" => { let value = child.value().str().unwrap_or("").trim(); match value.parse::() { Ok(_) => (ArgTypes::MaxVolume, Some(value.to_string())), Err(_) => { eprintln!("{} is not a number between 0 and {}!", value, u8::MAX); return (HandleLocalStatus::FAILURE, actions); } } } "device" => { let value = match child.value().str() { Some(v) => v.to_string(), None => { eprintln!("--device found but no name given"); return (HandleLocalStatus::FAILURE, actions); } }; (ArgTypes::DeviceName, Some(value)) } "custom-message" => { let value = match child.value().str() { Some(v) => v.to_string(), None => { eprintln!("--custom-message found but no message given"); return (HandleLocalStatus::FAILURE, actions); } }; (ArgTypes::CustomMessage, Some(value)) } "custom-icon" => { let value = match child.value().str() { Some(v) => v.to_string(), None => { eprintln!("--custom-icon found but no icon given"); return (HandleLocalStatus::FAILURE, actions); } }; (ArgTypes::CustomIcon, Some(value)) } "top-margin" => { let value = child.value().str().unwrap_or("").trim(); match value.parse::() { Ok(top_margin) if (0.0f32..=1.0f32).contains(&top_margin) => { (ArgTypes::TopMargin, Some(value.to_string())) } _ => { eprintln!("{} is not a number between 0.0 and 1.0!", value); return (HandleLocalStatus::FAILURE, actions); } } } "style" => continue, "config" => continue, e => { eprintln!("Unknown Variant Key: \"{}\"!...", e); return (HandleLocalStatus::FAILURE, actions); } }; if option != ArgTypes::None { actions.push((option, value)); } } // sort actions so that they always get executed in the correct order if actions.len() > 0 { for i in 0..actions.len() - 1 { for j in i + 1..actions.len() { if actions[i].0 > actions[j].0 { let temp = actions[i].clone(); actions[i] = actions[j].clone(); actions[j] = temp; } } } } (HandleLocalStatus::SUCCESS, actions) } fn volume_parser(is_sink: bool, value: &str) -> Result<(ArgTypes, Option), i32> { let mut v = match (value, value.parse::()) { // Parse custom step values (_, Ok(num)) => ( if num.is_positive() { ArgTypes::SinkVolumeRaise } else { ArgTypes::SinkVolumeLower }, Some(num.abs().to_string()), ), ("raise", _) => (ArgTypes::SinkVolumeRaise, None), ("lower", _) => (ArgTypes::SinkVolumeLower, None), ("mute-toggle", _) => (ArgTypes::SinkVolumeMuteToggle, None), (e, _) => { eprintln!("Unknown output volume mode: \"{}\"!...", e); return Err(1); } }; if is_sink { if v.0 == ArgTypes::SinkVolumeRaise { v.0 = ArgTypes::SourceVolumeRaise; } else if v.0 == ArgTypes::SinkVolumeLower { v.0 = ArgTypes::SourceVolumeLower; } else { v.0 = ArgTypes::SourceVolumeMuteToggle; } } Ok(v) } SwayOSD-0.1.0/src/input-backend/000077500000000000000000000000001467037200400163175ustar00rootroot00000000000000SwayOSD-0.1.0/src/input-backend/dbus_server.rs000066400000000000000000000014261467037200400212130ustar00rootroot00000000000000use zbus::{dbus_interface, Connection, ConnectionBuilder, SignalContext}; use crate::config::{DBUS_BACKEND_NAME, DBUS_PATH}; pub struct DbusServer; #[dbus_interface(name = "org.erikreider.swayosd")] impl DbusServer { #[dbus_interface(signal)] pub async fn key_pressed( signal_ctxt: &SignalContext<'_>, key_code: u16, state: i32, ) -> zbus::Result<()>; } impl DbusServer { async fn get_connection(&self) -> zbus::Result { let conn = ConnectionBuilder::system()? .name(DBUS_BACKEND_NAME)? .serve_at(DBUS_PATH, DbusServer)? .build() .await?; Ok(conn) } pub async fn init(&self) -> Connection { match self.get_connection().await { Ok(conn) => conn, Err(error) => { eprintln!("Error: {}", error); std::process::exit(1) } } } } SwayOSD-0.1.0/src/input-backend/main.rs000066400000000000000000000110001467037200400176010ustar00rootroot00000000000000use async_std::task::{self, sleep}; use config::DBUS_PATH; use dbus_server::DbusServer; use evdev_rs::enums::{int_to_ev_key, EventCode, EV_KEY, EV_LED}; use evdev_rs::DeviceWrapper; use input::event::keyboard::KeyboardEventTrait; use input::event::tablet_pad::KeyState; use input::event::{EventTrait, KeyboardEvent}; use input::{Event, Libinput, LibinputInterface}; use libc::{O_RDONLY, O_RDWR}; use nix::poll::{poll, PollFd, PollFlags}; use std::fs::{File, OpenOptions}; use std::os::fd::AsRawFd; use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd}; use std::path::Path; use std::time::Duration; use zbus::InterfaceRef; #[path = "../config.rs"] mod config; mod dbus_server; struct EventInfo { device_path: String, ev_key: EV_KEY, } struct Interface; impl LibinputInterface for Interface { fn open_restricted(&mut self, path: &Path, flags: i32) -> Result { OpenOptions::new() .custom_flags(flags) .read((flags & O_RDONLY != 0) | (flags & O_RDWR != 0)) .open(path) .map(|file| file.into()) .map_err(|err| err.raw_os_error().unwrap()) } fn close_restricted(&mut self, fd: OwnedFd) { drop(File::from(fd)); } } fn main() -> Result<(), zbus::Error> { // Parse Config let _input_config = config::backend::read_backend_config() .expect("Failed to parse config file") .input; // Create DBUS server let connection = task::block_on(DbusServer.init()); let object_server = connection.object_server(); let iface_ref = task::block_on(object_server.interface::<_, DbusServer>(DBUS_PATH))?; // Init libinput let mut input = Libinput::new_with_udev(Interface); input .udev_assign_seat("seat0") .expect("Could not assign seat0"); let pollfd = PollFd::new(input.as_raw_fd(), PollFlags::POLLIN); while poll(&mut [pollfd], -1).is_ok() { event(&mut input, &iface_ref); } Ok(()) } fn event(input: &mut Libinput, iface_ref: &InterfaceRef) { input.dispatch().unwrap(); for event in input.into_iter() { if let Event::Keyboard(KeyboardEvent::Key(event)) = event { if event.key_state() == KeyState::Pressed { continue; } let device = match unsafe { event.device().udev_device() } { Some(device) => device, None => continue, }; let ev_key = match int_to_ev_key(event.key()) { // Basic Lock keys Some(key @ EV_KEY::KEY_CAPSLOCK) | Some(key @ EV_KEY::KEY_NUMLOCK) | Some(key @ EV_KEY::KEY_SCROLLLOCK) | // Display Brightness Some(key @ EV_KEY::KEY_BRIGHTNESSUP) | Some(key @ EV_KEY::KEY_BRIGHTNESSDOWN) | Some(key @ EV_KEY::KEY_BRIGHTNESS_MIN) | Some(key @ EV_KEY::KEY_BRIGHTNESS_MAX) | Some(key @ EV_KEY::KEY_BRIGHTNESS_AUTO) | Some(key @ EV_KEY::KEY_BRIGHTNESS_CYCLE) | // Keyboard Illumination Some(key @ EV_KEY::KEY_KBDILLUMUP) | Some(key @ EV_KEY::KEY_KBDILLUMDOWN) | Some(key @ EV_KEY::KEY_KBDILLUMTOGGLE) => key, // Keyboard Layout Some(key @ EV_KEY::KEY_KBD_LAYOUT_NEXT) => key, // Audio Keys Some(key @ EV_KEY::KEY_VOLUMEUP) | Some(key @ EV_KEY::KEY_VOLUMEDOWN) | Some(key @ EV_KEY::KEY_MUTE) | Some(key @ EV_KEY::KEY_UNMUTE) | Some(key @ EV_KEY::KEY_MICMUTE) => key, // Touchpad Some(key @ EV_KEY::KEY_TOUCHPAD_ON) | Some(key @ EV_KEY::KEY_TOUCHPAD_OFF) | Some(key @ EV_KEY::KEY_TOUCHPAD_TOGGLE) | // Media Keys Some(key @ EV_KEY::KEY_PREVIOUSSONG) | Some(key @ EV_KEY::KEY_PLAYPAUSE) | Some(key @ EV_KEY::KEY_PLAY) | Some(key @ EV_KEY::KEY_PAUSE) | Some(key @ EV_KEY::KEY_NEXTSONG) => key, _ => continue, }; if let Some(path) = device.devnode() { if let Some(path) = path.to_str() { let event_info = EventInfo { device_path: path.to_owned(), ev_key, }; task::spawn(call(event_info, iface_ref.clone())); } } } } } async fn call(event_info: EventInfo, iface_ref: InterfaceRef) { // Wait for the LED value to change sleep(Duration::from_millis(50)).await; let Ok(device) = evdev_rs::Device::new_from_path(event_info.device_path) else { return; }; let lock_state = match event_info.ev_key { EV_KEY::KEY_CAPSLOCK => device.event_value(&EventCode::EV_LED(EV_LED::LED_CAPSL)), EV_KEY::KEY_NUMLOCK => device.event_value(&EventCode::EV_LED(EV_LED::LED_NUML)), EV_KEY::KEY_SCROLLLOCK => device.event_value(&EventCode::EV_LED(EV_LED::LED_SCROLLL)), _ => None, }; // Send signal let signal_result = DbusServer::key_pressed( iface_ref.signal_context(), event_info.ev_key as u16, lock_state.unwrap_or(-1), ) .await; if let Err(error) = signal_result { eprintln!("Signal Error: {}", error) } } SwayOSD-0.1.0/src/meson.build000066400000000000000000000020311467037200400157310ustar00rootroot00000000000000pkgdatadir = join_paths(get_option('prefix'), get_option('datadir'), meson.project_name()) cargo_bin = find_program('cargo') assert(cargo_bin.found()) cargo_opt = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] cargo_opt += [ '--target-dir', meson.project_build_root() / 'src' ] cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] if get_option('buildtype') == 'release' cargo_opt += [ '--release' ] rust_target = 'release' else rust_target = 'debug' endif binaries = [ 'swayosd-server', 'swayosd-client', 'swayosd-libinput-backend' ] binaries_path = [] foreach prog : binaries binaries_path += '@OUTDIR@/@0@/@1@'.format(rust_target, prog) endforeach custom_target( 'Cargo Build', build_by_default: true, build_always_stale: true, output: binaries, console: true, install: true, install_dir: join_paths(get_option('prefix'), get_option('bindir')), command: [ 'env', cargo_env, cargo_bin, 'build', cargo_opt, '&&', 'cp', '-f', binaries_path, '@OUTDIR@' ] ) SwayOSD-0.1.0/src/server/000077500000000000000000000000001467037200400151015ustar00rootroot00000000000000SwayOSD-0.1.0/src/server/application.rs000066400000000000000000000311221467037200400177510ustar00rootroot00000000000000use crate::argtypes::ArgTypes; use crate::config::{self, APPLICATION_NAME, DBUS_BACKEND_NAME}; use crate::global_utils::{handle_application_args, HandleLocalStatus}; use crate::osd_window::SwayosdWindow; use crate::utils::{self, *}; use gtk::gio::SignalSubscriptionId; use gtk::gio::{ApplicationFlags, BusNameWatcherFlags, BusType}; use gtk::glib::{clone, MainContext, OptionArg, OptionFlags, Priority, Receiver}; use gtk::prelude::*; use gtk::*; use pulsectl::controllers::{SinkController, SourceController}; use std::cell::RefCell; use std::rc::Rc; use std::sync::{Arc, Mutex}; use super::config::user::ServerConfig; #[derive(Clone, Shrinkwrap)] pub struct SwayOSDApplication { #[shrinkwrap(main_field)] app: gtk::Application, windows: Rc>>, } impl SwayOSDApplication { pub fn new(server_config: ServerConfig, action_receiver: Receiver<(ArgTypes, String)>) -> Self { let app = Application::new(Some(APPLICATION_NAME), ApplicationFlags::FLAGS_NONE); app.add_main_option( "config", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, "Use a custom config file instead of looking for one.", Some(""), ); app.add_main_option( "style", glib::Char::from('s' as u8), OptionFlags::NONE, OptionArg::String, "Use a custom Stylesheet file instead of looking for one", Some(""), ); app.add_main_option( "top-margin", glib::Char::from(0), OptionFlags::NONE, OptionArg::String, &format!( "OSD margin from top edge (0.5 would be screen center). Default is {}", *utils::TOP_MARGIN_DEFAULT ), Some(""), ); let osd_app = SwayOSDApplication { app: app.clone(), windows: Rc::new(RefCell::new(Vec::new())), }; // Apply Server Config if let Some(margin) = server_config.top_margin { if (0_f32..1_f32).contains(&margin) { set_top_margin(margin); } } if let Some(max_volume) = server_config.max_volume { set_default_max_volume(max_volume); } if let Some(show) = server_config.show_percentage { set_show_percentage(show); } // Parse args app.connect_handle_local_options(clone!(@strong osd_app => move |_app, args| { let actions = match handle_application_args(args.to_variant()) { (HandleLocalStatus::SUCCESS | HandleLocalStatus::CONTINUE, actions) => actions, (status @ HandleLocalStatus::FAILURE, _) => return status as i32, }; for (arg_type, data) in actions { match (arg_type, data) { (ArgTypes::TopMargin, margin) => { let margin: Option = margin .and_then(|margin| margin.parse().ok()) .and_then(|margin| (0_f32..1_f32).contains(&margin).then_some(margin)); if let Some(margin) = margin { set_top_margin(margin) } }, (ArgTypes::MaxVolume, max) => { let max: Option = max .and_then(|max| max.parse().ok()); if let Some(max) = max { set_default_max_volume(max); } }, (arg_type, data) => Self::action_activated(&osd_app, arg_type, data), } } HandleLocalStatus::CONTINUE as i32 })); // Listen to any Client actions action_receiver.attach( None, clone!(@strong osd_app => @default-return Continue(false), move |(arg_type, data)| { Self::action_activated(&osd_app, arg_type, (!data.is_empty()).then_some(data)); Continue(true) }), ); // Listen to the LibInput Backend and activate the Application action let (sender, receiver) = MainContext::channel::<(u16, i32)>(Priority::default()); receiver.attach( None, clone!(@strong osd_app => @default-return Continue(false), move |(key_code, state)| { let (arg_type, data): (ArgTypes, Option) = match evdev_rs::enums::int_to_ev_key(key_code as u32) { Some(evdev_rs::enums::EV_KEY::KEY_CAPSLOCK) => { (ArgTypes::CapsLock, Some(state.to_string())) } Some(evdev_rs::enums::EV_KEY::KEY_NUMLOCK) => { (ArgTypes::NumLock, Some(state.to_string())) } Some(evdev_rs::enums::EV_KEY::KEY_SCROLLLOCK) => { (ArgTypes::ScrollLock, Some(state.to_string())) } _ => return Continue(true), }; Self::action_activated(&osd_app, arg_type, data); Continue(true) }), ); // Start watching for the LibInput Backend let signal_id: Arc>> = Arc::new(Mutex::new(None)); gio::bus_watch_name( BusType::System, DBUS_BACKEND_NAME, BusNameWatcherFlags::NONE, clone!(@strong sender, @strong signal_id => move |connection, _, _| { println!("Connecting to the SwayOSD LibInput Backend"); let mut mutex = match signal_id.lock() { Ok(mut mutex) => match mutex.as_mut() { Some(_) => return, None => mutex, }, Err(error) => return println!("Mutex lock Error: {}", error), }; mutex.replace(connection.signal_subscribe( Some(config::DBUS_BACKEND_NAME), Some(config::DBUS_BACKEND_NAME), Some("KeyPressed"), Some(config::DBUS_PATH), None, gio::DBusSignalFlags::NONE, clone!(@strong sender => move |_, _, _, _, _, variant| { let key_code = variant.try_child_get::(0); let state = variant.try_child_get::(1); match (key_code, state) { (Ok(Some(key_code)), Ok(Some(state))) => { if let Err(error) = sender.send((key_code, state)) { eprintln!("Channel Send error: {}", error); } }, variables => return eprintln!("Variables don't match: {:?}", variables), }; }), )); }), clone!(@strong signal_id => move|connection, _| { eprintln!("SwayOSD LibInput Backend isn't available, waiting..."); match signal_id.lock() { Ok(mut mutex) => if let Some(sig_id) = mutex.take() { connection.signal_unsubscribe(sig_id); }, Err(error) => println!("Mutex lock Error: {}", error), } }), ); return osd_app; } pub fn start(&self) -> i32 { let s = self.clone(); self.app.connect_activate(move |_| { s.initialize(); }); let _ = self.app.register(gio::Cancellable::NONE); self.app.run().into() } fn action_activated(osd_app: &SwayOSDApplication, arg_type: ArgTypes, value: Option) { match (arg_type, value) { (ArgTypes::SinkVolumeRaise, step) => { let mut device_type = VolumeDeviceType::Sink(SinkController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::Raise, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } (ArgTypes::SinkVolumeLower, step) => { let mut device_type = VolumeDeviceType::Sink(SinkController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::Lower, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } (ArgTypes::SinkVolumeMuteToggle, _) => { let mut device_type = VolumeDeviceType::Sink(SinkController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::MuteToggle, None) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } (ArgTypes::SourceVolumeRaise, step) => { let mut device_type = VolumeDeviceType::Source(SourceController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::Raise, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } (ArgTypes::SourceVolumeLower, step) => { let mut device_type = VolumeDeviceType::Source(SourceController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::Lower, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } (ArgTypes::SourceVolumeMuteToggle, _) => { let mut device_type = VolumeDeviceType::Source(SourceController::create().unwrap()); if let Some(device) = change_device_volume(&mut device_type, VolumeChangeType::MuteToggle, None) { for window in osd_app.windows.borrow().to_owned() { window.changed_volume(&device, &device_type); } } reset_max_volume(); reset_device_name(); } // TODO: Brightness (ArgTypes::BrightnessRaise, step) => { if let Ok(mut brightness_backend) = change_brightness(BrightnessChangeType::Raise, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_brightness(brightness_backend.as_mut()); } } } (ArgTypes::BrightnessLower, step) => { if let Ok(mut brightness_backend) = change_brightness(BrightnessChangeType::Lower, step) { for window in osd_app.windows.borrow().to_owned() { window.changed_brightness(brightness_backend.as_mut()); } } } (ArgTypes::BrightnessSet, value) => { if let Ok(mut brightness_backend) = change_brightness(BrightnessChangeType::Set, value) { for window in osd_app.windows.borrow().to_owned() { window.changed_brightness(brightness_backend.as_mut()); } } } (ArgTypes::CapsLock, value) => { let i32_value = value.clone().unwrap_or("-1".to_owned()); let state = match i32_value.parse::() { Ok(value) if value >= 0 && value <= 1 => value == 1, _ => get_key_lock_state(KeysLocks::CapsLock, value), }; for window in osd_app.windows.borrow().to_owned() { window.changed_keylock(KeysLocks::CapsLock, state) } } (ArgTypes::NumLock, value) => { let i32_value = value.clone().unwrap_or("-1".to_owned()); let state = match i32_value.parse::() { Ok(value) if value >= 0 && value <= 1 => value == 1, _ => get_key_lock_state(KeysLocks::NumLock, value), }; for window in osd_app.windows.borrow().to_owned() { window.changed_keylock(KeysLocks::NumLock, state) } } (ArgTypes::ScrollLock, value) => { let i32_value = value.clone().unwrap_or("-1".to_owned()); let state = match i32_value.parse::() { Ok(value) if value >= 0 && value <= 1 => value == 1, _ => get_key_lock_state(KeysLocks::ScrollLock, value), }; for window in osd_app.windows.borrow().to_owned() { window.changed_keylock(KeysLocks::ScrollLock, state) } } (ArgTypes::MaxVolume, max) => { let volume: u8 = match max { Some(max) => match max.parse() { Ok(max) => max, _ => get_default_max_volume(), }, _ => get_default_max_volume(), }; set_max_volume(volume) } (ArgTypes::DeviceName, name) => { set_device_name(name.unwrap_or(DEVICE_NAME_DEFAULT.to_string())) } (ArgTypes::CustomMessage, message) => { if let Some(message) = message { for window in osd_app.windows.borrow().to_owned() { window.custom_message(message.as_str(), get_icon_name().as_deref()); } } reset_icon_name(); } (ArgTypes::CustomIcon, icon) => { set_icon_name(icon.unwrap_or(ICON_NAME_DEFAULT.to_string())) } (arg_type, data) => { eprintln!( "Failed to parse command... Type: {:?}, Data: {:?}", arg_type, data ) } }; } fn initialize(&self) { let display: gdk::Display = match gdk::Display::default() { Some(x) => x, _ => return, }; self.init_windows(&display); let _self = self; display.connect_opened(clone!(@strong _self => move |d| { _self.init_windows(d); })); display.connect_closed(clone!(@strong _self => move |_d, is_error| { if is_error { eprintln!("Display closed due to errors..."); } _self.close_all_windows(); })); display.connect_monitor_added(clone!(@strong _self => move |d, mon| { _self.add_window(d, mon); })); display.connect_monitor_removed(clone!(@strong _self => move |d, _mon| { _self.init_windows(d); })); } fn add_window(&self, display: &gdk::Display, monitor: &gdk::Monitor) { let win = SwayosdWindow::new(&self.app, display, monitor); self.windows.borrow_mut().push(win); } fn init_windows(&self, display: &gdk::Display) { self.close_all_windows(); for i in 0..display.n_monitors() { let monitor: gdk::Monitor = match display.monitor(i) { Some(x) => x, _ => continue, }; self.add_window(display, &monitor); } } fn close_all_windows(&self) { self.windows.borrow_mut().retain(|window| { window.close(); false }); } } SwayOSD-0.1.0/src/server/main.rs000066400000000000000000000103571467037200400164010ustar00rootroot00000000000000mod application; mod osd_window; mod utils; #[path = "../argtypes.rs"] mod argtypes; #[path = "../config.rs"] mod config; #[path = "../global_utils.rs"] mod global_utils; #[path = "../brightness_backend/mod.rs"] mod brightness_backend; #[macro_use] extern crate shrinkwraprs; #[macro_use] extern crate cascade; use application::SwayOSDApplication; use argtypes::ArgTypes; use config::{DBUS_PATH, DBUS_SERVER_NAME}; use gtk::glib::{MainContext, Priority, Sender}; use gtk::prelude::*; use gtk::{ gdk::Screen, gio::{self, Resource}, glib::Bytes, traits::IconThemeExt, CssProvider, IconTheme, StyleContext, }; use std::env::args_os; use std::future::pending; use std::path::PathBuf; use std::str::FromStr; use utils::{get_system_css_path, user_style_path}; use zbus::{dbus_interface, ConnectionBuilder}; struct DbusServer { sender: Sender<(ArgTypes, String)>, } #[dbus_interface(name = "org.erikreider.swayosd")] impl DbusServer { pub fn handle_action(&self, arg_type: String, data: String) -> bool { let arg_type = match ArgTypes::from_str(&arg_type) { Ok(arg_type) => arg_type, Err(other_type) => { eprintln!("Unknown action in Dbus handle_action: {:?}", other_type); return false; } }; if let Err(error) = self.sender.send((arg_type, data)) { eprintln!("Channel Send error: {}", error); return false; } true } } impl DbusServer { async fn new(sender: Sender<(ArgTypes, String)>) -> zbus::Result<()> { let _connection = ConnectionBuilder::session()? .name(DBUS_SERVER_NAME)? .serve_at(DBUS_PATH, DbusServer { sender })? .build() .await?; pending::<()>().await; Ok(()) } } const GRESOURCE_BASE_PATH: &str = "/org/erikreider/swayosd"; fn main() { if gtk::init().is_err() { eprintln!("failed to initialize GTK Application"); std::process::exit(1); } // Load the compiled resource bundle let resources_bytes = include_bytes!(concat!(env!("OUT_DIR"), "/swayosd.gresource")); let resource_data = Bytes::from(&resources_bytes[..]); let res = Resource::from_data(&resource_data).unwrap(); gio::resources_register(&res); // Load the icon theme let theme = IconTheme::default().expect("Could not get IconTheme"); theme.add_resource_path(&format!("{}/icons", GRESOURCE_BASE_PATH)); // Load the CSS themes let screen = Screen::default().expect("Failed getting the default screen"); // Load the provided default CSS theme let provider = CssProvider::new(); match get_system_css_path() { Some(path) => match provider.load_from_path(path.to_str().unwrap()) { Ok(_) => StyleContext::add_provider_for_screen( &screen, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION as u32, ), Err(error) => eprintln!("Could not load default CSS stylesheet: {}", error), }, None => eprintln!("Could not find the system CSS file..."), } // Get config path and CSS theme path from command line let mut config_path: Option = None; let mut custom_user_css: Option = None; let mut args = args_os().into_iter(); while let Some(arg) = args.next() { match arg.to_str() { Some("--config") => { if let Some(path) = args.next() { config_path = Some(path.into()); } } Some("-s") | Some("--style") => { if let Some(path) = args.next() { custom_user_css = Some(path.into()); } } _ => (), } } // Parse Config let server_config = config::user::read_user_config(config_path.as_deref()) .expect("Failed to parse config file") .server; // Load style path from config if none is given on CLI if custom_user_css.is_none() { custom_user_css = server_config.style.clone(); } // Try loading the users CSS theme if let Some(user_config_path) = user_style_path(custom_user_css) { let user_provider = CssProvider::new(); user_provider .load_from_path(&user_config_path) .expect("Failed loading user defined style.css"); StyleContext::add_provider_for_screen( &screen, &user_provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION as u32, ); println!("Loaded user defined CSS file"); } let (sender, receiver) = MainContext::channel::<(ArgTypes, String)>(Priority::default()); // Start the DBus Server async_std::task::spawn(DbusServer::new(sender)); // Start the GTK Application std::process::exit(SwayOSDApplication::new(server_config, receiver).start()); } SwayOSD-0.1.0/src/server/osd_window.rs000066400000000000000000000147771467037200400176430ustar00rootroot00000000000000use std::cell::RefCell; use std::rc::Rc; use std::time::Duration; use gtk::{ gdk, glib::{self, clone}, prelude::*, }; use pulsectl::controllers::types::DeviceInfo; use crate::{ brightness_backend::BrightnessBackend, utils::{ get_max_volume, get_show_percentage, get_top_margin, volume_to_f64, KeysLocks, VolumeDeviceType, }, }; const ICON_SIZE: i32 = 32; /// A window that our application can open that contains the main project view. #[derive(Clone, Debug)] pub struct SwayosdWindow { pub window: gtk::ApplicationWindow, pub display: gdk::Display, pub monitor: gdk::Monitor, container: gtk::Box, timeout_id: Rc>>, } impl SwayosdWindow { /// Create a new window and assign it to the given application. pub fn new(app: >k::Application, display: &gdk::Display, monitor: &gdk::Monitor) -> Self { let window = gtk::ApplicationWindow::new(app); window.set_widget_name("osd"); window .style_context() .add_class(>k::STYLE_CLASS_OSD.to_string()); gtk_layer_shell::init_for_window(&window); gtk_layer_shell::set_monitor(&window, monitor); gtk_layer_shell::set_namespace(&window, "swayosd"); gtk_layer_shell::set_exclusive_zone(&window, -1); gtk_layer_shell::set_layer(&window, gtk_layer_shell::Layer::Overlay); gtk_layer_shell::set_anchor(&window, gtk_layer_shell::Edge::Top, true); // Set up the widgets window.set_width_request(250); let container = cascade! { gtk::Box::new(gtk::Orientation::Horizontal, 12); ..set_widget_name("container"); }; window.add(&container); // Set the window margin window.connect_map(clone!(@strong monitor => move |win| { let bottom = monitor.workarea().height() - win.allocated_height(); let margin = (bottom as f32 * get_top_margin()).round() as i32; gtk_layer_shell::set_margin(win, gtk_layer_shell::Edge::Top, margin); })); Self { window, container, display: display.clone(), monitor: monitor.clone(), timeout_id: Rc::new(RefCell::new(None)), } } pub fn close(&self) { self.window.close(); } pub fn changed_volume(&self, device: &DeviceInfo, device_type: &VolumeDeviceType) { self.clear_osd(); let volume = volume_to_f64(&device.volume.avg()); let icon_prefix = match device_type { VolumeDeviceType::Sink(_) => "sink", VolumeDeviceType::Source(_) => "source", }; let icon_state = &match (device.mute, volume) { (true, _) => "muted", (_, x) if x == 0.0 => "muted", (false, x) if x > 0.0 && x <= 33.0 => "low", (false, x) if x > 33.0 && x <= 66.0 => "medium", (false, x) if x > 66.0 && x <= 100.0 => "high", (false, x) if x > 100.0 => match device_type { VolumeDeviceType::Sink(_) => "high", VolumeDeviceType::Source(_) => "overamplified", }, (_, _) => "high", }; let icon_name = &format!("{}-volume-{}-symbolic", icon_prefix, icon_state); let max_volume: f64 = get_max_volume().into(); let icon = self.build_icon_widget(icon_name); let progress = self.build_progress_widget(volume / max_volume); let label = self.build_text_widget(Some(&format!("{}%", volume))); progress.set_sensitive(!device.mute); self.container.add(&icon); self.container.add(&progress); if get_show_percentage() { self.container.add(&label); } self.run_timeout(); } pub fn changed_brightness(&self, brightness_backend: &mut dyn BrightnessBackend) { self.clear_osd(); let icon_name = "display-brightness-symbolic"; let icon = self.build_icon_widget(icon_name); let brightness = brightness_backend.get_current() as f64; let max = brightness_backend.get_max() as f64; let progress = self.build_progress_widget(brightness / max); let label = self.build_text_widget(Some(&format!("{}%", (brightness / max * 100.) as i32))); self.container.add(&icon); self.container.add(&progress); if get_show_percentage() { self.container.add(&label); } self.run_timeout(); } pub fn changed_keylock(&self, key: KeysLocks, state: bool) { self.clear_osd(); let label = self.build_text_widget(None); let on_off_text = match state { true => "On", false => "Off", }; let (label_text, symbol) = match key { KeysLocks::CapsLock => { let symbol = "caps-lock-symbolic"; let text = "Caps Lock ".to_string() + on_off_text; (text, symbol) } KeysLocks::NumLock => { let symbol = "num-lock-symbolic"; let text = "Num Lock ".to_string() + on_off_text; (text, symbol) } KeysLocks::ScrollLock => { let symbol = "scroll-lock-symbolic"; let text = "Scroll Lock ".to_string() + on_off_text; (text, symbol) } }; label.set_text(&label_text); let icon = self.build_icon_widget(symbol); icon.set_sensitive(state); self.container.add(&icon); self.container.add(&label); self.run_timeout(); } pub fn custom_message(&self, message: &str, icon_name: Option<&str>) { self.clear_osd(); let label = self.build_text_widget(Some(message)); if let Some(icon_name) = icon_name { let icon = self.build_icon_widget(icon_name); self.container.add(&icon); self.container.add(&label); let box_spacing = self.container.spacing(); icon.connect_size_allocate(move |icon, allocate| { label.set_margin_end( allocate.width() + icon.margin_start() + icon.margin_end() + box_spacing, ); }); } else { self.container.add(&label); } self.run_timeout(); } /// Clear all container children fn clear_osd(&self) { for widget in self.container.children() { self.container.remove(&widget); } } fn run_timeout(&self) { // Hide window after timeout if let Some(timeout_id) = self.timeout_id.take() { timeout_id.remove() } let s = self.clone(); self.timeout_id.replace(Some(glib::timeout_add_local_once( Duration::from_millis(1000), move || { s.window.hide(); s.timeout_id.replace(None); }, ))); self.window.show_all(); } fn build_icon_widget(&self, icon_name: &str) -> gtk::Image { let icon_name = match gtk::IconTheme::default() { Some(theme) if theme.has_icon(icon_name) => icon_name, _ => "missing-symbolic", }; cascade! { gtk::Image::from_icon_name(Some(icon_name), gtk::IconSize::Invalid); ..set_pixel_size(ICON_SIZE); } } fn build_text_widget(&self, text: Option<&str>) -> gtk::Label { cascade! { gtk::Label::new(text); ..set_halign(gtk::Align::Center); ..set_hexpand(true); ..style_context().add_class("title-4"); } } fn build_progress_widget(&self, fraction: f64) -> gtk::ProgressBar { cascade! { gtk::ProgressBar::new(); ..set_fraction(fraction); ..set_valign(gtk::Align::Center); ..set_expand(true); } } } SwayOSD-0.1.0/src/server/utils.rs000066400000000000000000000253351467037200400166170ustar00rootroot00000000000000use gtk::glib::{system_config_dirs, user_config_dir}; use lazy_static::lazy_static; use substring::Substring; use std::{ fs::{self, File}, io::{prelude::*, BufReader}, path::{Path, PathBuf}, sync::Mutex, }; use pulse::volume::Volume; use pulsectl::controllers::{types::DeviceInfo, DeviceControl, SinkController, SourceController}; use crate::brightness_backend; static PRIV_MAX_VOLUME_DEFAULT: u8 = 100_u8; lazy_static! { static ref MAX_VOLUME_DEFAULT: Mutex = Mutex::new(PRIV_MAX_VOLUME_DEFAULT); static ref MAX_VOLUME: Mutex = Mutex::new(PRIV_MAX_VOLUME_DEFAULT); pub static ref DEVICE_NAME_DEFAULT: &'static str = "default"; static ref DEVICE_NAME: Mutex> = Mutex::new(None); pub static ref ICON_NAME_DEFAULT: &'static str = "text-x-generic"; static ref ICON_NAME: Mutex> = Mutex::new(None); pub static ref TOP_MARGIN_DEFAULT: f32 = 0.85_f32; static ref TOP_MARGIN: Mutex = Mutex::new(*TOP_MARGIN_DEFAULT); pub static ref SHOW_PERCENTAGE: Mutex = Mutex::new(false); } pub enum KeysLocks { CapsLock, NumLock, ScrollLock, } pub fn get_default_max_volume() -> u8 { *MAX_VOLUME_DEFAULT.lock().unwrap() } pub fn set_default_max_volume(volume: u8) { let mut vol = MAX_VOLUME_DEFAULT.lock().unwrap(); *vol = volume; } pub fn get_max_volume() -> u8 { *MAX_VOLUME.lock().unwrap() } pub fn set_max_volume(volume: u8) { let mut vol = MAX_VOLUME.lock().unwrap(); *vol = volume; } pub fn reset_max_volume() { let mut vol = MAX_VOLUME.lock().unwrap(); *vol = *MAX_VOLUME_DEFAULT.lock().unwrap(); } pub fn get_top_margin() -> f32 { *TOP_MARGIN.lock().unwrap() } pub fn set_top_margin(margin: f32) { let mut margin_mut = TOP_MARGIN.lock().unwrap(); *margin_mut = margin; } pub fn get_show_percentage() -> bool { *SHOW_PERCENTAGE.lock().unwrap() } pub fn set_show_percentage(show: bool) { let mut show_mut = SHOW_PERCENTAGE.lock().unwrap(); *show_mut = show; } pub fn get_device_name() -> Option { (*DEVICE_NAME.lock().unwrap()).clone() } pub fn set_device_name(name: String) { let mut global_name = DEVICE_NAME.lock().unwrap(); *global_name = Some(name); } pub fn reset_device_name() { let mut global_name = DEVICE_NAME.lock().unwrap(); *global_name = None; } pub fn get_icon_name() -> Option { (*ICON_NAME.lock().unwrap()).clone() } pub fn set_icon_name(name: String) { let mut icon_name = ICON_NAME.lock().unwrap(); *icon_name = Some(name); } pub fn reset_icon_name() { let mut icon_name = ICON_NAME.lock().unwrap(); *icon_name = None; } pub fn get_key_lock_state(key: KeysLocks, led: Option) -> bool { const BASE_PATH: &str = "/sys/class/leds"; match fs::read_dir(BASE_PATH) { Ok(paths) => { let mut paths: Vec = paths .map_while(|path| { path.map_or_else(|_| None, |p| Some(p.path().display().to_string())) }) .collect(); if let Some(led) = led { let led = format!("{}/{}", BASE_PATH, led); if paths.contains(&led) { paths.insert(0, led); } else { eprintln!("LED device {led} does not exist!... Trying other LEDs"); } } let key_name = match key { KeysLocks::CapsLock => "capslock", KeysLocks::NumLock => "numlock", KeysLocks::ScrollLock => "scrolllock", }; for path in paths { if !path.contains(key_name) { continue; } if let Ok(content) = read_file(path + "/brightness") { if content.trim().eq("1") { return true; } } } false } Err(_) => { eprintln!("No LEDS found!..."); false } } } fn read_file(path: String) -> std::io::Result { let file = File::open(path)?; let mut buf_reader = BufReader::new(file); let mut contents = String::new(); buf_reader.read_to_string(&mut contents)?; Ok(contents) } pub enum VolumeChangeType { Raise, Lower, MuteToggle, } pub enum VolumeDeviceType { Sink(SinkController), Source(SourceController), } pub enum BrightnessChangeType { Raise, Lower, Set, } pub fn change_device_volume( device_type: &mut VolumeDeviceType, change_type: VolumeChangeType, step: Option, ) -> Option { let (device, device_name): (DeviceInfo, String) = match device_type { VolumeDeviceType::Sink(controller) => { let server_info = controller.get_server_info(); let global_name = get_device_name(); let device_name: String = if global_name.is_none() { match server_info { Ok(info) => info.default_sink_name.unwrap_or("".to_string()), Err(e) => { eprintln!("Error getting default_sink: {}", e); return None; } } } else { set_device_name(DEVICE_NAME_DEFAULT.to_string()); get_device_name().unwrap() }; match controller.get_device_by_name(&device_name) { Ok(device) => (device, device_name.clone()), Err(_) => { eprintln!("No device with name: '{}' found!", device_name); return None; } } } VolumeDeviceType::Source(controller) => { let server_info = controller.get_server_info(); let global_name = get_device_name(); let device_name: String = if global_name.is_none() { match server_info { Ok(info) => info.default_source_name.unwrap_or("".to_string()), Err(e) => { eprintln!("Error getting default_source: {}", e); return None; } } } else { set_device_name(DEVICE_NAME_DEFAULT.to_string()); get_device_name().unwrap() }; match controller.get_device_by_name(&device_name) { Ok(device) => (device, device_name.clone()), Err(_) => { eprintln!("No device with name: '{}' found!", device_name); return None; } } } }; const VOLUME_CHANGE_DELTA: u8 = 5; let volume_delta = step .clone() .unwrap_or_default() .parse::() .unwrap_or(VOLUME_CHANGE_DELTA) as f64 * 0.01; match change_type { VolumeChangeType::Raise => { let max_volume = get_max_volume(); // if we are already exactly at or over the max volume let mut at_max_volume = false; // if we are under the next volume but increasing by the given amount would be over the max let mut over_max_volume = false; let mut volume_percent = max_volume; // iterate through all devices in the volume group for v in device.volume.get() { // the string looks like this: ' NUMBER% ' let volume_string = v.to_string(); // trim it to remove the empty space 'NUMBER%' let mut volume_string = volume_string.trim(); // remove the '%' volume_string = volume_string.substring(0, volume_string.len() - 1); // parse the string to a u8, we do it this convoluted to get the % and I haven't found another way volume_percent = volume_string.parse::().unwrap(); if volume_percent >= max_volume { at_max_volume = true; break; } if volume_percent + VOLUME_CHANGE_DELTA > max_volume { over_max_volume = true; break; } } // if we are exactle at max volume if at_max_volume { // only show the OSD match device_type { VolumeDeviceType::Sink(controller) => { controller.increase_device_volume_by_percent(device.index, 0.0) } VolumeDeviceType::Source(controller) => { controller.increase_device_volume_by_percent(device.index, 0.0) } } } // if we would increase over the max step exactly to the max else if over_max_volume { let delta_to_max = max_volume - volume_percent; let volume_delta = step .unwrap_or_default() .parse::() .unwrap_or(delta_to_max) as f64 * 0.01; match device_type { VolumeDeviceType::Sink(controller) => { controller.increase_device_volume_by_percent(device.index, volume_delta) } VolumeDeviceType::Source(controller) => { controller.increase_device_volume_by_percent(device.index, volume_delta) } } } // if neither of the above are true increase normally else { match device_type { VolumeDeviceType::Sink(controller) => { controller.increase_device_volume_by_percent(device.index, volume_delta) } VolumeDeviceType::Source(controller) => { controller.increase_device_volume_by_percent(device.index, volume_delta) } } } } VolumeChangeType::Lower => match device_type { VolumeDeviceType::Sink(controller) => { controller.decrease_device_volume_by_percent(device.index, volume_delta) } VolumeDeviceType::Source(controller) => { controller.decrease_device_volume_by_percent(device.index, volume_delta) } }, VolumeChangeType::MuteToggle => match device_type { VolumeDeviceType::Sink(controller) => { let op = controller.handler.introspect.set_sink_mute_by_index( device.index, !device.mute, None, ); controller.handler.wait_for_operation(op).ok(); } VolumeDeviceType::Source(controller) => { let op = controller.handler.introspect.set_source_mute_by_index( device.index, !device.mute, None, ); controller.handler.wait_for_operation(op).ok(); } }, } match device_type { VolumeDeviceType::Sink(controller) => match controller.get_device_by_name(&device_name) { Ok(device) => Some(device), Err(e) => { eprintln!("Pulse Error: {}", e); None } }, VolumeDeviceType::Source(controller) => match controller.get_device_by_name(&device_name) { Ok(device) => Some(device), Err(e) => { eprintln!("Pulse Error: {}", e); None } }, } } pub fn change_brightness( change_type: BrightnessChangeType, step: Option, ) -> brightness_backend::BrightnessBackendResult { const BRIGHTNESS_CHANGE_DELTA: u8 = 5; let value = step.unwrap_or_default().parse::(); let mut backend = brightness_backend::get_preferred_backend(get_device_name())?; match change_type { BrightnessChangeType::Raise => { backend.raise(value.unwrap_or(BRIGHTNESS_CHANGE_DELTA) as u32)? } BrightnessChangeType::Lower => { backend.lower(value.unwrap_or(BRIGHTNESS_CHANGE_DELTA) as u32)? } BrightnessChangeType::Set => backend.set(value.unwrap() as u32)?, }; Ok(backend) } pub fn volume_to_f64(volume: &Volume) -> f64 { let tmp_vol = f64::from(volume.0 - Volume::MUTED.0); (100.0 * tmp_vol / f64::from(Volume::NORMAL.0 - Volume::MUTED.0)).round() } pub fn get_system_css_path() -> Option { let mut paths: Vec = Vec::new(); for path in system_config_dirs() { paths.push(path.join("swayosd").join("style.css")); } paths.push(Path::new("/usr/local/etc/xdg/swaync/style.css").to_path_buf()); let mut path: Option = None; for try_path in paths { if try_path.exists() { path = Some(try_path); break; } } path } pub fn user_style_path(custom_path: Option) -> Option { let path = user_config_dir().join("swayosd").join("style.css"); if let Some(custom_path) = custom_path { if custom_path.exists() { return custom_path.to_str().map(|s| s.to_string()); } } if path.exists() { return path.to_str().map(|s| s.to_string()); } None }