├── .github ├── FUNDING.yml └── workflows │ └── release.yml ├── .gitignore ├── BUILDING.md ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── DEBIAN.txt ├── LICENSE.md ├── Myxer.desktop ├── PKGBUILD ├── README.md ├── media ├── myxer_advanced.png ├── myxer_dark.png ├── myxer_light.png └── myxer_thumbnail.png ├── nodemon.json └── src ├── card.rs ├── main.rs ├── meter ├── base_meter.rs ├── mod.rs ├── sink_meter.rs ├── source_meter.rs └── stream_meter.rs ├── pulse.rs ├── shared.rs └── window ├── about.rs ├── mod.rs ├── myxer.rs ├── profiles.rs └── style.rs /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | patreon: Aurailus 2 | github: Aurailus 3 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: release 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Install Dependencies 20 | run: sudo apt install libpango1.0-dev libatk1.0-dev libgtk-3-dev libpulse-dev; cargo install cargo-deb 21 | - name: Build Executable 22 | run: cargo build --verbose --release 23 | - name: Upload Executable Artifact 24 | uses: actions/upload-artifact@v2.2.2 25 | with: 26 | name: myxer 27 | path: target/release/myxer 28 | - name: Build Debian 29 | run: cargo deb --verbose 30 | - name: Upload Debian Artifact 31 | uses: actions/upload-artifact@v2.2.2 32 | with: 33 | name: Myxer.deb 34 | path: target/debian/Myxer* 35 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /BUILDING.md: -------------------------------------------------------------------------------- 1 | # Building 2 | 3 | Building Myxer is trivial. Download this repository, Cargo, and `libpulse-dev` & `libgtk-3-dev` system libraries, and run `cargo build --release` in the root directory. 4 | 5 | ## Prebuilt Binaries 6 | 7 | Major releases are available on the [Releases](https://github.com/Aurailus/Myxer/releases) page. If you want something more breaking edge, you can download an artifact of the latest commit [here](https://nightly.link/Aurailus/myxer/workflows/release/master/Myxer.zip). These artifacts are untested, YMMV. 8 | 9 | ## Development 10 | 11 | Call `cargo run` to build and run the application. If you have nodemon installed, you can call it on the root directory to automatically watch the source files for changes and recompile. 12 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to Myxer 2 | 3 | Pull Requests are welcome and appreciated. I value any time you're willing to dedicate to Myxer. However, before you start, read through these guidelines to make sure that you're aware of the type of contributions the project requires. 4 | 5 | If you're looking to add a new feature, and you're unsure of whether or not it will be accepted, open an issue, and I'll get back to you as soon as possible. 6 | 7 | ## Before You Start 8 | 9 | Make sure you've read through the codebase and understand each component's purpose before attempting to modify the application so that you don't break something when trying to add a new feature. 10 | 11 | ## Code Style 12 | 13 | File names and variable names are `snake_case`'d, structs and traits are `PascalCase`. When at-all possible, leave JSDoc style comments above your functions and structs, with two newlines separating them from the previous code block and one separating them from the block they refer to. If something mandates an unclear solution, leave a comment behind for the contributors that come after. 14 | 15 | ## License 16 | 17 | Read through the [License](https://github.com/Aurailus/Myxer/blob/master/LICENSE.md) before contributing. All contributions must be under the same license. 18 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "anyhow" 7 | version = "1.0.44" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" 10 | 11 | [[package]] 12 | name = "atk" 13 | version = "0.9.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "812b4911e210bd51b24596244523c856ca749e6223c50a7fbbba3f89ee37c426" 16 | dependencies = [ 17 | "atk-sys", 18 | "bitflags", 19 | "glib", 20 | "glib-sys", 21 | "gobject-sys", 22 | "libc", 23 | ] 24 | 25 | [[package]] 26 | name = "atk-sys" 27 | version = "0.10.0" 28 | source = "registry+https://github.com/rust-lang/crates.io-index" 29 | checksum = "f530e4af131d94cc4fa15c5c9d0348f0ef28bac64ba660b6b2a1cf2605dedfce" 30 | dependencies = [ 31 | "glib-sys", 32 | "gobject-sys", 33 | "libc", 34 | "system-deps", 35 | ] 36 | 37 | [[package]] 38 | name = "autocfg" 39 | version = "1.0.1" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 42 | 43 | [[package]] 44 | name = "bitflags" 45 | version = "1.3.2" 46 | source = "registry+https://github.com/rust-lang/crates.io-index" 47 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 48 | 49 | [[package]] 50 | name = "cairo-rs" 51 | version = "0.9.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "c5c0f2e047e8ca53d0ff249c54ae047931d7a6ebe05d00af73e0ffeb6e34bdb8" 54 | dependencies = [ 55 | "bitflags", 56 | "cairo-sys-rs", 57 | "glib", 58 | "glib-sys", 59 | "gobject-sys", 60 | "libc", 61 | "thiserror", 62 | ] 63 | 64 | [[package]] 65 | name = "cairo-sys-rs" 66 | version = "0.10.0" 67 | source = "registry+https://github.com/rust-lang/crates.io-index" 68 | checksum = "2ed2639b9ad5f1d6efa76de95558e11339e7318426d84ac4890b86c03e828ca7" 69 | dependencies = [ 70 | "glib-sys", 71 | "libc", 72 | "system-deps", 73 | ] 74 | 75 | [[package]] 76 | name = "cc" 77 | version = "1.0.70" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "d26a6ce4b6a484fa3edb70f7efa6fc430fd2b87285fe8b84304fd0936faa0dc0" 80 | 81 | [[package]] 82 | name = "colorsys" 83 | version = "0.6.4" 84 | source = "registry+https://github.com/rust-lang/crates.io-index" 85 | checksum = "f666c4153782cd274a188c850716f96ba8b0f06178304b4efa8828e32e476689" 86 | 87 | [[package]] 88 | name = "either" 89 | version = "1.6.1" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 92 | 93 | [[package]] 94 | name = "futures" 95 | version = "0.3.17" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "a12aa0eb539080d55c3f2d45a67c3b58b6b0773c1a3ca2dfec66d58c97fd66ca" 98 | dependencies = [ 99 | "futures-channel", 100 | "futures-core", 101 | "futures-executor", 102 | "futures-io", 103 | "futures-sink", 104 | "futures-task", 105 | "futures-util", 106 | ] 107 | 108 | [[package]] 109 | name = "futures-channel" 110 | version = "0.3.17" 111 | source = "registry+https://github.com/rust-lang/crates.io-index" 112 | checksum = "5da6ba8c3bb3c165d3c7319fc1cc8304facf1fb8db99c5de877183c08a273888" 113 | dependencies = [ 114 | "futures-core", 115 | "futures-sink", 116 | ] 117 | 118 | [[package]] 119 | name = "futures-core" 120 | version = "0.3.17" 121 | source = "registry+https://github.com/rust-lang/crates.io-index" 122 | checksum = "88d1c26957f23603395cd326b0ffe64124b818f4449552f960d815cfba83a53d" 123 | 124 | [[package]] 125 | name = "futures-executor" 126 | version = "0.3.17" 127 | source = "registry+https://github.com/rust-lang/crates.io-index" 128 | checksum = "45025be030969d763025784f7f355043dc6bc74093e4ecc5000ca4dc50d8745c" 129 | dependencies = [ 130 | "futures-core", 131 | "futures-task", 132 | "futures-util", 133 | ] 134 | 135 | [[package]] 136 | name = "futures-io" 137 | version = "0.3.17" 138 | source = "registry+https://github.com/rust-lang/crates.io-index" 139 | checksum = "522de2a0fe3e380f1bc577ba0474108faf3f6b18321dbf60b3b9c39a75073377" 140 | 141 | [[package]] 142 | name = "futures-macro" 143 | version = "0.3.17" 144 | source = "registry+https://github.com/rust-lang/crates.io-index" 145 | checksum = "18e4a4b95cea4b4ccbcf1c5675ca7c4ee4e9e75eb79944d07defde18068f79bb" 146 | dependencies = [ 147 | "autocfg", 148 | "proc-macro-hack", 149 | "proc-macro2", 150 | "quote", 151 | "syn", 152 | ] 153 | 154 | [[package]] 155 | name = "futures-sink" 156 | version = "0.3.17" 157 | source = "registry+https://github.com/rust-lang/crates.io-index" 158 | checksum = "36ea153c13024fe480590b3e3d4cad89a0cfacecc24577b68f86c6ced9c2bc11" 159 | 160 | [[package]] 161 | name = "futures-task" 162 | version = "0.3.17" 163 | source = "registry+https://github.com/rust-lang/crates.io-index" 164 | checksum = "1d3d00f4eddb73e498a54394f228cd55853bdf059259e8e7bc6e69d408892e99" 165 | 166 | [[package]] 167 | name = "futures-util" 168 | version = "0.3.17" 169 | source = "registry+https://github.com/rust-lang/crates.io-index" 170 | checksum = "36568465210a3a6ee45e1f165136d68671471a501e632e9a98d96872222b5481" 171 | dependencies = [ 172 | "autocfg", 173 | "futures-channel", 174 | "futures-core", 175 | "futures-io", 176 | "futures-macro", 177 | "futures-sink", 178 | "futures-task", 179 | "memchr", 180 | "pin-project-lite", 181 | "pin-utils", 182 | "proc-macro-hack", 183 | "proc-macro-nested", 184 | "slab", 185 | ] 186 | 187 | [[package]] 188 | name = "gdk" 189 | version = "0.13.2" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "db00839b2a68a7a10af3fa28dfb3febaba3a20c3a9ac2425a33b7df1f84a6b7d" 192 | dependencies = [ 193 | "bitflags", 194 | "cairo-rs", 195 | "cairo-sys-rs", 196 | "gdk-pixbuf", 197 | "gdk-sys", 198 | "gio", 199 | "gio-sys", 200 | "glib", 201 | "glib-sys", 202 | "gobject-sys", 203 | "libc", 204 | "pango", 205 | ] 206 | 207 | [[package]] 208 | name = "gdk-pixbuf" 209 | version = "0.9.0" 210 | source = "registry+https://github.com/rust-lang/crates.io-index" 211 | checksum = "8f6dae3cb99dd49b758b88f0132f8d401108e63ae8edd45f432d42cdff99998a" 212 | dependencies = [ 213 | "gdk-pixbuf-sys", 214 | "gio", 215 | "gio-sys", 216 | "glib", 217 | "glib-sys", 218 | "gobject-sys", 219 | "libc", 220 | ] 221 | 222 | [[package]] 223 | name = "gdk-pixbuf-sys" 224 | version = "0.10.0" 225 | source = "registry+https://github.com/rust-lang/crates.io-index" 226 | checksum = "3bfe468a7f43e97b8d193a762b6c5cf67a7d36cacbc0b9291dbcae24bfea1e8f" 227 | dependencies = [ 228 | "gio-sys", 229 | "glib-sys", 230 | "gobject-sys", 231 | "libc", 232 | "system-deps", 233 | ] 234 | 235 | [[package]] 236 | name = "gdk-sys" 237 | version = "0.10.0" 238 | source = "registry+https://github.com/rust-lang/crates.io-index" 239 | checksum = "0a9653cfc500fd268015b1ac055ddbc3df7a5c9ea3f4ccef147b3957bd140d69" 240 | dependencies = [ 241 | "cairo-sys-rs", 242 | "gdk-pixbuf-sys", 243 | "gio-sys", 244 | "glib-sys", 245 | "gobject-sys", 246 | "libc", 247 | "pango-sys", 248 | "pkg-config", 249 | "system-deps", 250 | ] 251 | 252 | [[package]] 253 | name = "gio" 254 | version = "0.9.1" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "1fb60242bfff700772dae5d9e3a1f7aa2e4ebccf18b89662a16acb2822568561" 257 | dependencies = [ 258 | "bitflags", 259 | "futures", 260 | "futures-channel", 261 | "futures-core", 262 | "futures-io", 263 | "futures-util", 264 | "gio-sys", 265 | "glib", 266 | "glib-sys", 267 | "gobject-sys", 268 | "libc", 269 | "once_cell", 270 | "thiserror", 271 | ] 272 | 273 | [[package]] 274 | name = "gio-sys" 275 | version = "0.10.1" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "5e24fb752f8f5d2cf6bbc2c606fd2bc989c81c5e2fe321ab974d54f8b6344eac" 278 | dependencies = [ 279 | "glib-sys", 280 | "gobject-sys", 281 | "libc", 282 | "system-deps", 283 | "winapi", 284 | ] 285 | 286 | [[package]] 287 | name = "glib" 288 | version = "0.10.3" 289 | source = "registry+https://github.com/rust-lang/crates.io-index" 290 | checksum = "0c685013b7515e668f1b57a165b009d4d28cb139a8a989bbd699c10dad29d0c5" 291 | dependencies = [ 292 | "bitflags", 293 | "futures-channel", 294 | "futures-core", 295 | "futures-executor", 296 | "futures-task", 297 | "futures-util", 298 | "glib-macros", 299 | "glib-sys", 300 | "gobject-sys", 301 | "libc", 302 | "once_cell", 303 | ] 304 | 305 | [[package]] 306 | name = "glib-macros" 307 | version = "0.10.1" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "41486a26d1366a8032b160b59065a59fb528530a46a49f627e7048fb8c064039" 310 | dependencies = [ 311 | "anyhow", 312 | "heck", 313 | "itertools", 314 | "proc-macro-crate", 315 | "proc-macro-error", 316 | "proc-macro2", 317 | "quote", 318 | "syn", 319 | ] 320 | 321 | [[package]] 322 | name = "glib-sys" 323 | version = "0.10.1" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "c7e9b997a66e9a23d073f2b1abb4dbfc3925e0b8952f67efd8d9b6e168e4cdc1" 326 | dependencies = [ 327 | "libc", 328 | "system-deps", 329 | ] 330 | 331 | [[package]] 332 | name = "gobject-sys" 333 | version = "0.10.0" 334 | source = "registry+https://github.com/rust-lang/crates.io-index" 335 | checksum = "952133b60c318a62bf82ee75b93acc7e84028a093e06b9e27981c2b6fe68218c" 336 | dependencies = [ 337 | "glib-sys", 338 | "libc", 339 | "system-deps", 340 | ] 341 | 342 | [[package]] 343 | name = "gtk" 344 | version = "0.9.2" 345 | source = "registry+https://github.com/rust-lang/crates.io-index" 346 | checksum = "2f022f2054072b3af07666341984562c8e626a79daa8be27b955d12d06a5ad6a" 347 | dependencies = [ 348 | "atk", 349 | "bitflags", 350 | "cairo-rs", 351 | "cairo-sys-rs", 352 | "cc", 353 | "gdk", 354 | "gdk-pixbuf", 355 | "gdk-pixbuf-sys", 356 | "gdk-sys", 357 | "gio", 358 | "gio-sys", 359 | "glib", 360 | "glib-sys", 361 | "gobject-sys", 362 | "gtk-sys", 363 | "libc", 364 | "once_cell", 365 | "pango", 366 | "pango-sys", 367 | "pkg-config", 368 | ] 369 | 370 | [[package]] 371 | name = "gtk-sys" 372 | version = "0.10.0" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "89acda6f084863307d948ba64a4b1ef674e8527dddab147ee4cdcc194c880457" 375 | dependencies = [ 376 | "atk-sys", 377 | "cairo-sys-rs", 378 | "gdk-pixbuf-sys", 379 | "gdk-sys", 380 | "gio-sys", 381 | "glib-sys", 382 | "gobject-sys", 383 | "libc", 384 | "pango-sys", 385 | "system-deps", 386 | ] 387 | 388 | [[package]] 389 | name = "heck" 390 | version = "0.3.3" 391 | source = "registry+https://github.com/rust-lang/crates.io-index" 392 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 393 | dependencies = [ 394 | "unicode-segmentation", 395 | ] 396 | 397 | [[package]] 398 | name = "itertools" 399 | version = "0.9.0" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" 402 | dependencies = [ 403 | "either", 404 | ] 405 | 406 | [[package]] 407 | name = "libc" 408 | version = "0.2.153" 409 | source = "registry+https://github.com/rust-lang/crates.io-index" 410 | checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" 411 | 412 | [[package]] 413 | name = "libpulse-binding" 414 | version = "2.25.0" 415 | source = "registry+https://github.com/rust-lang/crates.io-index" 416 | checksum = "86835d7763ded6bc16b6c0061ec60214da7550dfcd4ef93745f6f0096129676a" 417 | dependencies = [ 418 | "bitflags", 419 | "libc", 420 | "libpulse-sys", 421 | "num-derive", 422 | "num-traits", 423 | "winapi", 424 | ] 425 | 426 | [[package]] 427 | name = "libpulse-sys" 428 | version = "1.19.2" 429 | source = "registry+https://github.com/rust-lang/crates.io-index" 430 | checksum = "f12950b69c1b66233a900414befde36c8d4ea49deec1e1f34e4cd2f586e00c7d" 431 | dependencies = [ 432 | "libc", 433 | "num-derive", 434 | "num-traits", 435 | "pkg-config", 436 | "winapi", 437 | ] 438 | 439 | [[package]] 440 | name = "memchr" 441 | version = "2.4.1" 442 | source = "registry+https://github.com/rust-lang/crates.io-index" 443 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 444 | 445 | [[package]] 446 | name = "myxer" 447 | version = "1.3.0" 448 | dependencies = [ 449 | "colorsys", 450 | "gdk", 451 | "gio", 452 | "glib", 453 | "gtk", 454 | "libpulse-binding", 455 | "pango", 456 | "slice_as_array", 457 | ] 458 | 459 | [[package]] 460 | name = "num-derive" 461 | version = "0.3.3" 462 | source = "registry+https://github.com/rust-lang/crates.io-index" 463 | checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" 464 | dependencies = [ 465 | "proc-macro2", 466 | "quote", 467 | "syn", 468 | ] 469 | 470 | [[package]] 471 | name = "num-traits" 472 | version = "0.2.14" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 475 | dependencies = [ 476 | "autocfg", 477 | ] 478 | 479 | [[package]] 480 | name = "once_cell" 481 | version = "1.8.0" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 484 | 485 | [[package]] 486 | name = "pango" 487 | version = "0.9.1" 488 | source = "registry+https://github.com/rust-lang/crates.io-index" 489 | checksum = "9937068580bebd8ced19975938573803273ccbcbd598c58d4906efd4ac87c438" 490 | dependencies = [ 491 | "bitflags", 492 | "glib", 493 | "glib-sys", 494 | "gobject-sys", 495 | "libc", 496 | "once_cell", 497 | "pango-sys", 498 | ] 499 | 500 | [[package]] 501 | name = "pango-sys" 502 | version = "0.10.0" 503 | source = "registry+https://github.com/rust-lang/crates.io-index" 504 | checksum = "24d2650c8b62d116c020abd0cea26a4ed96526afda89b1c4ea567131fdefc890" 505 | dependencies = [ 506 | "glib-sys", 507 | "gobject-sys", 508 | "libc", 509 | "system-deps", 510 | ] 511 | 512 | [[package]] 513 | name = "pin-project-lite" 514 | version = "0.2.7" 515 | source = "registry+https://github.com/rust-lang/crates.io-index" 516 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 517 | 518 | [[package]] 519 | name = "pin-utils" 520 | version = "0.1.0" 521 | source = "registry+https://github.com/rust-lang/crates.io-index" 522 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 523 | 524 | [[package]] 525 | name = "pkg-config" 526 | version = "0.3.19" 527 | source = "registry+https://github.com/rust-lang/crates.io-index" 528 | checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" 529 | 530 | [[package]] 531 | name = "proc-macro-crate" 532 | version = "0.1.5" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" 535 | dependencies = [ 536 | "toml", 537 | ] 538 | 539 | [[package]] 540 | name = "proc-macro-error" 541 | version = "1.0.4" 542 | source = "registry+https://github.com/rust-lang/crates.io-index" 543 | checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" 544 | dependencies = [ 545 | "proc-macro-error-attr", 546 | "proc-macro2", 547 | "quote", 548 | "syn", 549 | "version_check", 550 | ] 551 | 552 | [[package]] 553 | name = "proc-macro-error-attr" 554 | version = "1.0.4" 555 | source = "registry+https://github.com/rust-lang/crates.io-index" 556 | checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" 557 | dependencies = [ 558 | "proc-macro2", 559 | "quote", 560 | "version_check", 561 | ] 562 | 563 | [[package]] 564 | name = "proc-macro-hack" 565 | version = "0.5.19" 566 | source = "registry+https://github.com/rust-lang/crates.io-index" 567 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 568 | 569 | [[package]] 570 | name = "proc-macro-nested" 571 | version = "0.1.7" 572 | source = "registry+https://github.com/rust-lang/crates.io-index" 573 | checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" 574 | 575 | [[package]] 576 | name = "proc-macro2" 577 | version = "1.0.29" 578 | source = "registry+https://github.com/rust-lang/crates.io-index" 579 | checksum = "b9f5105d4fdaab20335ca9565e106a5d9b82b6219b5ba735731124ac6711d23d" 580 | dependencies = [ 581 | "unicode-xid", 582 | ] 583 | 584 | [[package]] 585 | name = "quote" 586 | version = "1.0.9" 587 | source = "registry+https://github.com/rust-lang/crates.io-index" 588 | checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" 589 | dependencies = [ 590 | "proc-macro2", 591 | ] 592 | 593 | [[package]] 594 | name = "serde" 595 | version = "1.0.130" 596 | source = "registry+https://github.com/rust-lang/crates.io-index" 597 | checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913" 598 | 599 | [[package]] 600 | name = "slab" 601 | version = "0.4.4" 602 | source = "registry+https://github.com/rust-lang/crates.io-index" 603 | checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" 604 | 605 | [[package]] 606 | name = "slice_as_array" 607 | version = "1.1.0" 608 | source = "registry+https://github.com/rust-lang/crates.io-index" 609 | checksum = "64c963ee59ddedb5ab95dc2cd97c48b4a292572a52c5636fbbabdb9985bfe4c3" 610 | 611 | [[package]] 612 | name = "strum" 613 | version = "0.18.0" 614 | source = "registry+https://github.com/rust-lang/crates.io-index" 615 | checksum = "57bd81eb48f4c437cadc685403cad539345bf703d78e63707418431cecd4522b" 616 | 617 | [[package]] 618 | name = "strum_macros" 619 | version = "0.18.0" 620 | source = "registry+https://github.com/rust-lang/crates.io-index" 621 | checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c" 622 | dependencies = [ 623 | "heck", 624 | "proc-macro2", 625 | "quote", 626 | "syn", 627 | ] 628 | 629 | [[package]] 630 | name = "syn" 631 | version = "1.0.76" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "c6f107db402c2c2055242dbf4d2af0e69197202e9faacbef9571bbe47f5a1b84" 634 | dependencies = [ 635 | "proc-macro2", 636 | "quote", 637 | "unicode-xid", 638 | ] 639 | 640 | [[package]] 641 | name = "system-deps" 642 | version = "1.3.2" 643 | source = "registry+https://github.com/rust-lang/crates.io-index" 644 | checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b" 645 | dependencies = [ 646 | "heck", 647 | "pkg-config", 648 | "strum", 649 | "strum_macros", 650 | "thiserror", 651 | "toml", 652 | "version-compare", 653 | ] 654 | 655 | [[package]] 656 | name = "thiserror" 657 | version = "1.0.29" 658 | source = "registry+https://github.com/rust-lang/crates.io-index" 659 | checksum = "602eca064b2d83369e2b2f34b09c70b605402801927c65c11071ac911d299b88" 660 | dependencies = [ 661 | "thiserror-impl", 662 | ] 663 | 664 | [[package]] 665 | name = "thiserror-impl" 666 | version = "1.0.29" 667 | source = "registry+https://github.com/rust-lang/crates.io-index" 668 | checksum = "bad553cc2c78e8de258400763a647e80e6d1b31ee237275d756f6836d204494c" 669 | dependencies = [ 670 | "proc-macro2", 671 | "quote", 672 | "syn", 673 | ] 674 | 675 | [[package]] 676 | name = "toml" 677 | version = "0.5.8" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" 680 | dependencies = [ 681 | "serde", 682 | ] 683 | 684 | [[package]] 685 | name = "unicode-segmentation" 686 | version = "1.8.0" 687 | source = "registry+https://github.com/rust-lang/crates.io-index" 688 | checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" 689 | 690 | [[package]] 691 | name = "unicode-xid" 692 | version = "0.2.2" 693 | source = "registry+https://github.com/rust-lang/crates.io-index" 694 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 695 | 696 | [[package]] 697 | name = "version-compare" 698 | version = "0.0.10" 699 | source = "registry+https://github.com/rust-lang/crates.io-index" 700 | checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" 701 | 702 | [[package]] 703 | name = "version_check" 704 | version = "0.9.3" 705 | source = "registry+https://github.com/rust-lang/crates.io-index" 706 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 707 | 708 | [[package]] 709 | name = "winapi" 710 | version = "0.3.9" 711 | source = "registry+https://github.com/rust-lang/crates.io-index" 712 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 713 | dependencies = [ 714 | "winapi-i686-pc-windows-gnu", 715 | "winapi-x86_64-pc-windows-gnu", 716 | ] 717 | 718 | [[package]] 719 | name = "winapi-i686-pc-windows-gnu" 720 | version = "0.4.0" 721 | source = "registry+https://github.com/rust-lang/crates.io-index" 722 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 723 | 724 | [[package]] 725 | name = "winapi-x86_64-pc-windows-gnu" 726 | version = "0.4.0" 727 | source = "registry+https://github.com/rust-lang/crates.io-index" 728 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 729 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "myxer" 3 | version = "1.3.0" 4 | description = "A modern Volume Mixer for PulseAudio" 5 | readme = "README.md" 6 | license = "GPL-3.0" 7 | authors = [ "Auri " ] 8 | homepage = "https://myxer.aurailus.com" 9 | repository = "https://github.com/Aurailus/Myxer" 10 | edition = "2018" 11 | 12 | [package.metadata.deb] 13 | name = "Myxer" 14 | section = "sound" 15 | copyright = "(c) Auri Collings, 2021" 16 | extended-description-file = "DEBIAN.txt" 17 | assets = [ 18 | ["target/release/myxer", "usr/bin/", "755"], 19 | ["README.md", "usr/share/doc/Myxer/README", "644"], 20 | ["Myxer.desktop", "/usr/share/applications/", "644"] 21 | ] 22 | 23 | [dependencies] 24 | gdk = "0.13.2" 25 | glib = "0.10.3" 26 | pango = "0.9.1" 27 | colorsys = "0.6.3" 28 | slice_as_array = "1.1.0" 29 | 30 | [dependencies.libpulse] 31 | version = "2.23.0" 32 | package = "libpulse-binding" 33 | 34 | [dependencies.gtk] 35 | version = "0.9.0" 36 | features = [ "v3_22" ] 37 | 38 | [dependencies.gio] 39 | version = "*" 40 | features = [ "v2_44" ] 41 | -------------------------------------------------------------------------------- /DEBIAN.txt: -------------------------------------------------------------------------------- 1 | Myxer is a lightweight, powerful Volume Mixer. Devices, Streams, and even Card profiles can be managed, providing a complete replacement for the stock Volume Mixer. 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 [Free Software Foundation, Inc.](http://fsf.org/) 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license 7 | document, but changing it is not allowed. 8 | 9 | ## Preamble 10 | 11 | The GNU General Public License is a free, copyleft license for software and 12 | other kinds of works. 13 | 14 | The licenses for most software and other practical works are designed to take 15 | away your freedom to share and change the works. By contrast, the GNU General 16 | Public License is intended to guarantee your freedom to share and change all 17 | versions of a program--to make sure it remains free software for all its users. 18 | We, the Free Software Foundation, use the GNU General Public License for most 19 | of our software; it applies also to any other work released this way by its 20 | authors. You can apply it to your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not price. Our 23 | General Public Licenses are designed to make sure that you have the freedom to 24 | distribute copies of free software (and charge for them if you wish), that you 25 | receive source code or can get it if you want it, that you can change the 26 | software or use pieces of it in new free programs, and that you know you can do 27 | these things. 28 | 29 | To protect your rights, we need to prevent others from denying you these rights 30 | or asking you to surrender the rights. Therefore, you have certain 31 | responsibilities if you distribute copies of the software, or if you modify it: 32 | responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether gratis or for 35 | a fee, you must pass on to the recipients the same freedoms that you received. 36 | You must make sure that they, too, receive or can get the source code. And you 37 | must show them these terms so they know their rights. 38 | 39 | Developers that use the GNU GPL protect your rights with two steps: 40 | 41 | 1. assert copyright on the software, and 42 | 2. offer you this License giving you legal permission to copy, distribute 43 | and/or modify it. 44 | 45 | For the developers' and authors' protection, the GPL clearly explains that 46 | there is no warranty for this free software. For both users' and authors' sake, 47 | the GPL requires that modified versions be marked as changed, so that their 48 | problems will not be attributed erroneously to authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run modified 51 | versions of the software inside them, although the manufacturer can do so. This 52 | is fundamentally incompatible with the aim of protecting users' freedom to 53 | change the software. The systematic pattern of such abuse occurs in the area of 54 | products for individuals to use, which is precisely where it is most 55 | unacceptable. Therefore, we have designed this version of the GPL to prohibit 56 | the practice for those products. If such problems arise substantially in other 57 | domains, we stand ready to extend this provision to those domains in future 58 | versions of the GPL, as needed to protect the freedom of users. 59 | 60 | Finally, every program is threatened constantly by software patents. States 61 | should not allow patents to restrict development and use of software on 62 | general-purpose computers, but in those that do, we wish to avoid the special 63 | danger that patents applied to a free program could make it effectively 64 | proprietary. To prevent this, the GPL assures that patents cannot be used to 65 | render the program non-free. 66 | 67 | The precise terms and conditions for copying, distribution and modification 68 | follow. 69 | 70 | ## TERMS AND CONDITIONS 71 | 72 | ### 0. Definitions. 73 | 74 | *This License* refers to version 3 of the GNU General Public License. 75 | 76 | *Copyright* also means copyright-like laws that apply to other kinds of works, 77 | such as semiconductor masks. 78 | 79 | *The Program* refers to any copyrightable work licensed under this License. 80 | Each licensee is addressed as *you*. *Licensees* and *recipients* may be 81 | individuals or organizations. 82 | 83 | To *modify* a work means to copy from or adapt all or part of the work in a 84 | fashion requiring copyright permission, other than the making of an exact copy. 85 | The resulting work is called a *modified version* of the earlier work or a work 86 | *based on* the earlier work. 87 | 88 | A *covered work* means either the unmodified Program or a work based on the 89 | Program. 90 | 91 | To *propagate* a work means to do anything with it that, without permission, 92 | would make you directly or secondarily liable for infringement under applicable 93 | copyright law, except executing it on a computer or modifying a private copy. 94 | Propagation includes copying, distribution (with or without modification), 95 | making available to the public, and in some countries other activities as well. 96 | 97 | To *convey* a work means any kind of propagation that enables other parties to 98 | make or receive copies. Mere interaction with a user through a computer 99 | network, with no transfer of a copy, is not conveying. 100 | 101 | An interactive user interface displays *Appropriate Legal Notices* to the 102 | extent that it includes a convenient and prominently visible feature that 103 | 104 | 1. displays an appropriate copyright notice, and 105 | 2. tells the user that there is no warranty for the work (except to the 106 | extent that warranties are provided), that licensees may convey the work 107 | under this License, and how to view a copy of this License. 108 | 109 | If the interface presents a list of user commands or options, such as a menu, a 110 | prominent item in the list meets this criterion. 111 | 112 | ### 1. Source Code. 113 | 114 | The *source code* for a work means the preferred form of the work for making 115 | modifications to it. *Object code* means any non-source form of a work. 116 | 117 | A *Standard Interface* means an interface that either is an official standard 118 | defined by a recognized standards body, or, in the case of interfaces specified 119 | for a particular programming language, one that is widely used among developers 120 | working in that language. 121 | 122 | The *System Libraries* of an executable work include anything, other than the 123 | work as a whole, that (a) is included in the normal form of packaging a Major 124 | Component, but which is not part of that Major Component, and (b) serves only 125 | to enable use of the work with that Major Component, or to implement a Standard 126 | Interface for which an implementation is available to the public in source code 127 | form. A *Major Component*, in this context, means a major essential component 128 | (kernel, window system, and so on) of the specific operating system (if any) on 129 | which the executable work runs, or a compiler used to produce the work, or an 130 | object code interpreter used to run it. 131 | 132 | The *Corresponding Source* for a work in object code form means all the source 133 | code needed to generate, install, and (for an executable work) run the object 134 | code and to modify the work, including scripts to control those activities. 135 | However, it does not include the work's System Libraries, or general-purpose 136 | tools or generally available free programs which are used unmodified in 137 | performing those activities but which are not part of the work. For example, 138 | Corresponding Source includes interface definition files associated with source 139 | files for the work, and the source code for shared libraries and dynamically 140 | linked subprograms that the work is specifically designed to require, such as 141 | by intimate data communication or control flow between those subprograms and 142 | other parts of the work. 143 | 144 | The Corresponding Source need not include anything that users can regenerate 145 | automatically from other parts of the Corresponding Source. 146 | 147 | The Corresponding Source for a work in source code form is that same work. 148 | 149 | ### 2. Basic Permissions. 150 | 151 | All rights granted under this License are granted for the term of copyright on 152 | the Program, and are irrevocable provided the stated conditions are met. This 153 | License explicitly affirms your unlimited permission to run the unmodified 154 | Program. The output from running a covered work is covered by this License only 155 | if the output, given its content, constitutes a covered work. This License 156 | acknowledges your rights of fair use or other equivalent, as provided by 157 | copyright law. 158 | 159 | You may make, run and propagate covered works that you do not convey, without 160 | conditions so long as your license otherwise remains in force. You may convey 161 | covered works to others for the sole purpose of having them make modifications 162 | exclusively for you, or provide you with facilities for running those works, 163 | provided that you comply with the terms of this License in conveying all 164 | material for which you do not control copyright. Those thus making or running 165 | the covered works for you must do so exclusively on your behalf, under your 166 | direction and control, on terms that prohibit them from making any copies of 167 | your copyrighted material outside their relationship with you. 168 | 169 | Conveying under any other circumstances is permitted solely under the 170 | conditions stated below. Sublicensing is not allowed; section 10 makes it 171 | unnecessary. 172 | 173 | ### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 174 | 175 | No covered work shall be deemed part of an effective technological measure 176 | under any applicable law fulfilling obligations under article 11 of the WIPO 177 | copyright treaty adopted on 20 December 1996, or similar laws prohibiting or 178 | restricting circumvention of such measures. 179 | 180 | When you convey a covered work, you waive any legal power to forbid 181 | circumvention of technological measures to the extent such circumvention is 182 | effected by exercising rights under this License with respect to the covered 183 | work, and you disclaim any intention to limit operation or modification of the 184 | work as a means of enforcing, against the work's users, your or third parties' 185 | legal rights to forbid circumvention of technological measures. 186 | 187 | ### 4. Conveying Verbatim Copies. 188 | 189 | You may convey verbatim copies of the Program's source code as you receive it, 190 | in any medium, provided that you conspicuously and appropriately publish on 191 | each copy an appropriate copyright notice; keep intact all notices stating that 192 | this License and any non-permissive terms added in accord with section 7 apply 193 | to the code; keep intact all notices of the absence of any warranty; and give 194 | all recipients a copy of this License along with the Program. 195 | 196 | You may charge any price or no price for each copy that you convey, and you may 197 | offer support or warranty protection for a fee. 198 | 199 | ### 5. Conveying Modified Source Versions. 200 | 201 | You may convey a work based on the Program, or the modifications to produce it 202 | from the Program, in the form of source code under the terms of section 4, 203 | provided that you also meet all of these conditions: 204 | 205 | - a) The work must carry prominent notices stating that you modified it, and 206 | giving a relevant date. 207 | - b) The work must carry prominent notices stating that it is released under 208 | this License and any conditions added under section 7. This requirement 209 | modifies the requirement in section 4 to *keep intact all notices*. 210 | - c) You must license the entire work, as a whole, under this License to 211 | anyone who comes into possession of a copy. This License will therefore 212 | apply, along with any applicable section 7 additional terms, to the whole 213 | of the work, and all its parts, regardless of how they are packaged. This 214 | License gives no permission to license the work in any other way, but it 215 | does not invalidate such permission if you have separately received it. 216 | - d) If the work has interactive user interfaces, each must display 217 | Appropriate Legal Notices; however, if the Program has interactive 218 | interfaces that do not display Appropriate Legal Notices, your work need 219 | not make them do so. 220 | 221 | A compilation of a covered work with other separate and independent works, 222 | which are not by their nature extensions of the covered work, and which are not 223 | combined with it such as to form a larger program, in or on a volume of a 224 | storage or distribution medium, is called an *aggregate* if the compilation and 225 | its resulting copyright are not used to limit the access or legal rights of the 226 | compilation's users beyond what the individual works permit. Inclusion of a 227 | covered work in an aggregate does not cause this License to apply to the other 228 | parts of the aggregate. 229 | 230 | ### 6. Conveying Non-Source Forms. 231 | 232 | You may convey a covered work in object code form under the terms of sections 4 233 | and 5, provided that you also convey the machine-readable Corresponding Source 234 | under the terms of this License, in one of these ways: 235 | 236 | - a) Convey the object code in, or embodied in, a physical product (including 237 | a physical distribution medium), accompanied by the Corresponding Source 238 | fixed on a durable physical medium customarily used for software 239 | interchange. 240 | - b) Convey the object code in, or embodied in, a physical product (including 241 | a physical distribution medium), accompanied by a written offer, valid for 242 | at least three years and valid for as long as you offer spare parts or 243 | customer support for that product model, to give anyone who possesses the 244 | object code either 245 | 1. a copy of the Corresponding Source for all the software in the product 246 | that is covered by this License, on a durable physical medium 247 | customarily used for software interchange, for a price no more than your 248 | reasonable cost of physically performing this conveying of source, or 249 | 2. access to copy the Corresponding Source from a network server at no 250 | charge. 251 | - c) Convey individual copies of the object code with a copy of the written 252 | offer to provide the Corresponding Source. This alternative is allowed only 253 | occasionally and noncommercially, and only if you received the object code 254 | with such an offer, in accord with subsection 6b. 255 | - d) Convey the object code by offering access from a designated place 256 | (gratis or for a charge), and offer equivalent access to the Corresponding 257 | Source in the same way through the same place at no further charge. You 258 | need not require recipients to copy the Corresponding Source along with the 259 | object code. If the place to copy the object code is a network server, the 260 | Corresponding Source may be on a different server operated by you or a 261 | third party) that supports equivalent copying facilities, provided you 262 | maintain clear directions next to the object code saying where to find the 263 | Corresponding Source. Regardless of what server hosts the Corresponding 264 | Source, you remain obligated to ensure that it is available for as long as 265 | needed to satisfy these requirements. 266 | - e) Convey the object code using peer-to-peer transmission, provided you 267 | inform other peers where the object code and Corresponding Source of the 268 | work are being offered to the general public at no charge under subsection 269 | 6d. 270 | 271 | A separable portion of the object code, whose source code is excluded from the 272 | Corresponding Source as a System Library, need not be included in conveying the 273 | object code work. 274 | 275 | A *User Product* is either 276 | 277 | 1. a *consumer product*, which means any tangible personal property which is 278 | normally used for personal, family, or household purposes, or 279 | 2. anything designed or sold for incorporation into a dwelling. 280 | 281 | In determining whether a product is a consumer product, doubtful cases shall be 282 | resolved in favor of coverage. For a particular product received by a 283 | particular user, *normally used* refers to a typical or common use of that 284 | class of product, regardless of the status of the particular user or of the way 285 | in which the particular user actually uses, or expects or is expected to use, 286 | the product. A product is a consumer product regardless of whether the product 287 | has substantial commercial, industrial or non-consumer uses, unless such uses 288 | represent the only significant mode of use of the product. 289 | 290 | *Installation Information* for a User Product means any methods, procedures, 291 | authorization keys, or other information required to install and execute 292 | modified versions of a covered work in that User Product from a modified 293 | version of its Corresponding Source. The information must suffice to ensure 294 | that the continued functioning of the modified object code is in no case 295 | prevented or interfered with solely because modification has been made. 296 | 297 | If you convey an object code work under this section in, or with, or 298 | specifically for use in, a User Product, and the conveying occurs as part of a 299 | transaction in which the right of possession and use of the User Product is 300 | transferred to the recipient in perpetuity or for a fixed term (regardless of 301 | how the transaction is characterized), the Corresponding Source conveyed under 302 | this section must be accompanied by the Installation Information. But this 303 | requirement does not apply if neither you nor any third party retains the 304 | ability to install modified object code on the User Product (for example, the 305 | work has been installed in ROM). 306 | 307 | The requirement to provide Installation Information does not include a 308 | requirement to continue to provide support service, warranty, or updates for a 309 | work that has been modified or installed by the recipient, or for the User 310 | Product in which it has been modified or installed. Access to a network may be 311 | denied when the modification itself materially and adversely affects the 312 | operation of the network or violates the rules and protocols for communication 313 | across the network. 314 | 315 | Corresponding Source conveyed, and Installation Information provided, in accord 316 | with this section must be in a format that is publicly documented (and with an 317 | implementation available to the public in source code form), and must require 318 | no special password or key for unpacking, reading or copying. 319 | 320 | ### 7. Additional Terms. 321 | 322 | *Additional permissions* are terms that supplement the terms of this License by 323 | making exceptions from one or more of its conditions. Additional permissions 324 | that are applicable to the entire Program shall be treated as though they were 325 | included in this License, to the extent that they are valid under applicable 326 | law. If additional permissions apply only to part of the Program, that part may 327 | be used separately under those permissions, but the entire Program remains 328 | governed by this License without regard to the additional permissions. 329 | 330 | When you convey a copy of a covered work, you may at your option remove any 331 | additional permissions from that copy, or from any part of it. (Additional 332 | permissions may be written to require their own removal in certain cases when 333 | you modify the work.) You may place additional permissions on material, added 334 | by you to a covered work, for which you have or can give appropriate copyright 335 | permission. 336 | 337 | Notwithstanding any other provision of this License, for material you add to a 338 | covered work, you may (if authorized by the copyright holders of that material) 339 | supplement the terms of this License with terms: 340 | 341 | - a) Disclaiming warranty or limiting liability differently from the terms of 342 | sections 15 and 16 of this License; or 343 | - b) Requiring preservation of specified reasonable legal notices or author 344 | attributions in that material or in the Appropriate Legal Notices displayed 345 | by works containing it; or 346 | - c) Prohibiting misrepresentation of the origin of that material, or 347 | requiring that modified versions of such material be marked in reasonable 348 | ways as different from the original version; or 349 | - d) Limiting the use for publicity purposes of names of licensors or authors 350 | of the material; or 351 | - e) Declining to grant rights under trademark law for use of some trade 352 | names, trademarks, or service marks; or 353 | - f) Requiring indemnification of licensors and authors of that material by 354 | anyone who conveys the material (or modified versions of it) with 355 | contractual assumptions of liability to the recipient, for any liability 356 | that these contractual assumptions directly impose on those licensors and 357 | authors. 358 | 359 | All other non-permissive additional terms are considered *further restrictions* 360 | within the meaning of section 10. If the Program as you received it, or any 361 | part of it, contains a notice stating that it is governed by this License along 362 | with a term that is a further restriction, you may remove that term. If a 363 | license document contains a further restriction but permits relicensing or 364 | conveying under this License, you may add to a covered work material governed 365 | by the terms of that license document, provided that the further restriction 366 | does not survive such relicensing or conveying. 367 | 368 | If you add terms to a covered work in accord with this section, you must place, 369 | in the relevant source files, a statement of the additional terms that apply to 370 | those files, or a notice indicating where to find the applicable terms. 371 | 372 | Additional terms, permissive or non-permissive, may be stated in the form of a 373 | separately written license, or stated as exceptions; the above requirements 374 | apply either way. 375 | 376 | ### 8. Termination. 377 | 378 | You may not propagate or modify a covered work except as expressly provided 379 | under this License. Any attempt otherwise to propagate or modify it is void, 380 | and will automatically terminate your rights under this License (including any 381 | patent licenses granted under the third paragraph of section 11). 382 | 383 | However, if you cease all violation of this License, then your license from a 384 | particular copyright holder is reinstated 385 | 386 | - a) provisionally, unless and until the copyright holder explicitly and 387 | finally terminates your license, and 388 | - b) permanently, if the copyright holder fails to notify you of the 389 | violation by some reasonable means prior to 60 days after the cessation. 390 | 391 | Moreover, your license from a particular copyright holder is reinstated 392 | permanently if the copyright holder notifies you of the violation by some 393 | reasonable means, this is the first time you have received notice of violation 394 | of this License (for any work) from that copyright holder, and you cure the 395 | violation prior to 30 days after your receipt of the notice. 396 | 397 | Termination of your rights under this section does not terminate the licenses 398 | of parties who have received copies or rights from you under this License. If 399 | your rights have been terminated and not permanently reinstated, you do not 400 | qualify to receive new licenses for the same material under section 10. 401 | 402 | ### 9. Acceptance Not Required for Having Copies. 403 | 404 | You are not required to accept this License in order to receive or run a copy 405 | of the Program. Ancillary propagation of a covered work occurring solely as a 406 | consequence of using peer-to-peer transmission to receive a copy likewise does 407 | not require acceptance. However, nothing other than this License grants you 408 | permission to propagate or modify any covered work. These actions infringe 409 | copyright if you do not accept this License. Therefore, by modifying or 410 | propagating a covered work, you indicate your acceptance of this License to do 411 | so. 412 | 413 | ### 10. Automatic Licensing of Downstream Recipients. 414 | 415 | Each time you convey a covered work, the recipient automatically receives a 416 | license from the original licensors, to run, modify and propagate that work, 417 | subject to this License. You are not responsible for enforcing compliance by 418 | third parties with this License. 419 | 420 | An *entity transaction* is a transaction transferring control of an 421 | organization, or substantially all assets of one, or subdividing an 422 | organization, or merging organizations. If propagation of a covered work 423 | results from an entity transaction, each party to that transaction who receives 424 | a copy of the work also receives whatever licenses to the work the party's 425 | predecessor in interest had or could give under the previous paragraph, plus a 426 | right to possession of the Corresponding Source of the work from the 427 | predecessor in interest, if the predecessor has it or can get it with 428 | reasonable efforts. 429 | 430 | You may not impose any further restrictions on the exercise of the rights 431 | granted or affirmed under this License. For example, you may not impose a 432 | license fee, royalty, or other charge for exercise of rights granted under this 433 | License, and you may not initiate litigation (including a cross-claim or 434 | counterclaim in a lawsuit) alleging that any patent claim is infringed by 435 | making, using, selling, offering for sale, or importing the Program or any 436 | portion of it. 437 | 438 | ### 11. Patents. 439 | 440 | A *contributor* is a copyright holder who authorizes use under this License of 441 | the Program or a work on which the Program is based. The work thus licensed is 442 | called the contributor's *contributor version*. 443 | 444 | A contributor's *essential patent claims* are all patent claims owned or 445 | controlled by the contributor, whether already acquired or hereafter acquired, 446 | that would be infringed by some manner, permitted by this License, of making, 447 | using, or selling its contributor version, but do not include claims that would 448 | be infringed only as a consequence of further modification of the contributor 449 | version. For purposes of this definition, *control* includes the right to grant 450 | patent sublicenses in a manner consistent with the requirements of this 451 | License. 452 | 453 | Each contributor grants you a non-exclusive, worldwide, royalty-free patent 454 | license under the contributor's essential patent claims, to make, use, sell, 455 | offer for sale, import and otherwise run, modify and propagate the contents of 456 | its contributor version. 457 | 458 | In the following three paragraphs, a *patent license* is any express agreement 459 | or commitment, however denominated, not to enforce a patent (such as an express 460 | permission to practice a patent or covenant not to sue for patent 461 | infringement). To *grant* such a patent license to a party means to make such 462 | an agreement or commitment not to enforce a patent against the party. 463 | 464 | If you convey a covered work, knowingly relying on a patent license, and the 465 | Corresponding Source of the work is not available for anyone to copy, free of 466 | charge and under the terms of this License, through a publicly available 467 | network server or other readily accessible means, then you must either 468 | 469 | 1. cause the Corresponding Source to be so available, or 470 | 2. arrange to deprive yourself of the benefit of the patent license for this 471 | particular work, or 472 | 3. arrange, in a manner consistent with the requirements of this License, to 473 | extend the patent license to downstream recipients. 474 | 475 | *Knowingly relying* means you have actual knowledge that, but for the patent 476 | license, your conveying the covered work in a country, or your recipient's use 477 | of the covered work in a country, would infringe one or more identifiable 478 | patents in that country that you have reason to believe are valid. 479 | 480 | If, pursuant to or in connection with a single transaction or arrangement, you 481 | convey, or propagate by procuring conveyance of, a covered work, and grant a 482 | patent license to some of the parties receiving the covered work authorizing 483 | them to use, propagate, modify or convey a specific copy of the covered work, 484 | then the patent license you grant is automatically extended to all recipients 485 | of the covered work and works based on it. 486 | 487 | A patent license is *discriminatory* if it does not include within the scope of 488 | its coverage, prohibits the exercise of, or is conditioned on the non-exercise 489 | of one or more of the rights that are specifically granted under this License. 490 | You may not convey a covered work if you are a party to an arrangement with a 491 | third party that is in the business of distributing software, under which you 492 | make payment to the third party based on the extent of your activity of 493 | conveying the work, and under which the third party grants, to any of the 494 | parties who would receive the covered work from you, a discriminatory patent 495 | license 496 | 497 | - a) in connection with copies of the covered work conveyed by you (or copies 498 | made from those copies), or 499 | - b) primarily for and in connection with specific products or compilations 500 | that contain the covered work, unless you entered into that arrangement, or 501 | that patent license was granted, prior to 28 March 2007. 502 | 503 | Nothing in this License shall be construed as excluding or limiting any implied 504 | license or other defenses to infringement that may otherwise be available to 505 | you under applicable patent law. 506 | 507 | ### 12. No Surrender of Others' Freedom. 508 | 509 | If conditions are imposed on you (whether by court order, agreement or 510 | otherwise) that contradict the conditions of this License, they do not excuse 511 | you from the conditions of this License. If you cannot convey a covered work so 512 | as to satisfy simultaneously your obligations under this License and any other 513 | pertinent obligations, then as a consequence you may not convey it at all. For 514 | example, if you agree to terms that obligate you to collect a royalty for 515 | further conveying from those to whom you convey the Program, the only way you 516 | could satisfy both those terms and this License would be to refrain entirely 517 | from conveying the Program. 518 | 519 | ### 13. Use with the GNU Affero General Public License. 520 | 521 | Notwithstanding any other provision of this License, you have permission to 522 | link or combine any covered work with a work licensed under version 3 of the 523 | GNU Affero General Public License into a single combined work, and to convey 524 | the resulting work. The terms of this License will continue to apply to the 525 | part which is the covered work, but the special requirements of the GNU Affero 526 | General Public License, section 13, concerning interaction through a network 527 | will apply to the combination as such. 528 | 529 | ### 14. Revised Versions of this License. 530 | 531 | The Free Software Foundation may publish revised and/or new versions of the GNU 532 | General Public License from time to time. Such new versions will be similar in 533 | spirit to the present version, but may differ in detail to address new problems 534 | or concerns. 535 | 536 | Each version is given a distinguishing version number. If the Program specifies 537 | that a certain numbered version of the GNU General Public License *or any later 538 | version* applies to it, you have the option of following the terms and 539 | conditions either of that numbered version or of any later version published by 540 | the Free Software Foundation. If the Program does not specify a version number 541 | of the GNU General Public License, you may choose any version ever published by 542 | the Free Software Foundation. 543 | 544 | If the Program specifies that a proxy can decide which future versions of the 545 | GNU General Public License can be used, that proxy's public statement of 546 | acceptance of a version permanently authorizes you to choose that version for 547 | the Program. 548 | 549 | Later license versions may give you additional or different permissions. 550 | However, no additional obligations are imposed on any author or copyright 551 | holder as a result of your choosing to follow a later version. 552 | 553 | ### 15. Disclaimer of Warranty. 554 | 555 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE 556 | LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER 557 | PARTIES PROVIDE THE PROGRAM *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER 558 | EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 559 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE 560 | QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE 561 | DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR 562 | CORRECTION. 563 | 564 | ### 16. Limitation of Liability. 565 | 566 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY 567 | COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS 568 | PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, 569 | INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE 570 | THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED 571 | INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE 572 | PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY 573 | HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 574 | 575 | ### 17. Interpretation of Sections 15 and 16. 576 | 577 | If the disclaimer of warranty and limitation of liability provided above cannot 578 | be given local legal effect according to their terms, reviewing courts shall 579 | apply local law that most closely approximates an absolute waiver of all civil 580 | liability in connection with the Program, unless a warranty or assumption of 581 | liability accompanies a copy of the Program in return for a fee. 582 | 583 | ## END OF TERMS AND CONDITIONS ### 584 | 585 | ### How to Apply These Terms to Your New Programs 586 | 587 | If you develop a new program, and you want it to be of the greatest possible 588 | use to the public, the best way to achieve this is to make it free software 589 | which everyone can redistribute and change under these terms. 590 | 591 | To do so, attach the following notices to the program. It is safest to attach 592 | them to the start of each source file to most effectively state the exclusion 593 | of warranty; and each file should have at least the *copyright* line and a 594 | pointer to where the full notice is found. 595 | 596 | 597 | Copyright (C) 598 | 599 | This program is free software: you can redistribute it and/or modify 600 | it under the terms of the GNU General Public License as published by 601 | the Free Software Foundation, either version 3 of the License, or 602 | (at your option) any later version. 603 | 604 | This program is distributed in the hope that it will be useful, 605 | but WITHOUT ANY WARRANTY; without even the implied warranty of 606 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 607 | GNU General Public License for more details. 608 | 609 | You should have received a copy of the GNU General Public License 610 | along with this program. If not, see . 611 | 612 | Also add information on how to contact you by electronic and paper mail. 613 | 614 | If the program does terminal interaction, make it output a short notice like 615 | this when it starts in an interactive mode: 616 | 617 | Copyright (C) 618 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w`. 619 | This is free software, and you are welcome to redistribute it 620 | under certain conditions; type `show c` for details. 621 | 622 | The hypothetical commands `show w` and `show c` should show the appropriate 623 | parts of the General Public License. Of course, your program's commands might 624 | be different; for a GUI interface, you would use an *about box*. 625 | 626 | You should also get your employer (if you work as a programmer) or school, if 627 | any, to sign a *copyright disclaimer* for the program, if necessary. For more 628 | information on this, and how to apply and follow the GNU GPL, see 629 | [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/). 630 | 631 | The GNU General Public License does not permit incorporating your program into 632 | proprietary programs. If your program is a subroutine library, you may consider 633 | it more useful to permit linking proprietary applications with the library. If 634 | this is what you want to do, use the GNU Lesser General Public License instead 635 | of this License. But first, please read 636 | [http://www.gnu.org/philosophy/why-not-lgpl.html](http://www.gnu.org/philosophy/why-not-lgpl.html). 637 | -------------------------------------------------------------------------------- /Myxer.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Encoding=UTF-8 4 | Name=Myxer 5 | GenericName=Volume Mixer 6 | Comment=Adjust application and device volumes. 7 | Exec=myxer 8 | Icon=multimedia-volume-control 9 | Terminal=false 10 | StartupNotify=true 11 | Categories=AudioVideo;Audio;Mixer;GTK; 12 | Keywords=volume;control;audio 13 | -------------------------------------------------------------------------------- /PKGBUILD: -------------------------------------------------------------------------------- 1 | pkgname=myxer 2 | _pkgname=Myxer 3 | pkgver=1.3.0 4 | pkgrel=1 5 | pkgdesc='A modern Volume Mixer for PulseAudio, built with you in mind.' 6 | url='https://github.com/Aurailus/Myxer' 7 | source=("$pkgname-$pkgver.tar.gz::$url/archive/refs/tags/$pkgver.tar.gz") 8 | arch=('any') 9 | license=('GPL3') 10 | makedepends=('cargo') 11 | depends=('pulseaudio' 'gtk3') 12 | sha256sums=('4784746fd491d51397b3c47eb5ed5cf3f04ba54a116c192620bb532db2c2d550') 13 | 14 | build () { 15 | cd "$srcdir/$_pkgname-$pkgver" 16 | 17 | cargo build --release 18 | } 19 | 20 | package() { 21 | cd "$srcdir/$_pkgname-$pkgver" 22 | 23 | install -Dm755 target/release/$pkgname "${pkgdir}/usr/bin/myxer" 24 | } 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Myxer

2 | 3 | > [!IMPORTANT] 4 | > This project is in maintenance only mode. Myxer currently fulfills all of the use-cases I have for it, and I am too busy with work to justify time implementing feature requests for others. Pull Requests are welcome, so long as they maintain a high quality of code, and maintain the vision of the project. Thank you all! :heart: 5 | 6 |

7 | 8 |

9 | 10 |

A modern Volume Mixer for PulseAudio, built with you in mind.

11 | 12 |

13 | Releases 14 | Commit Activity 15 | Join Discord 16 | Support on Patreon 17 |

18 | 19 |
20 | 21 | Myxer is a lightweight, powerful Volume Mixer built with modern UI design for a seamless user experience. Devices, Streams, and even Card profiles can all be managed with Myxer, providing a complete replacement for your system Volume Mixer. 22 | 23 |
24 |
25 | 26 | 27 | 28 | ### Adaptive 29 | 30 | Myxer adapts to your selected GTK theme so that it fits seamlessly into your stock applications. 31 | 32 | Additionally, one can easily configure PulseAudio panel plugins to open Myxer when you click the "Audio Mixer" entry on the popup menu so that it behaves like a stock app, too! 33 | 34 |
35 |
36 |
37 |
38 | 39 | 40 | 41 | ### Advanced 42 | 43 | Behind the context menu, there are options to show individual audio channels and even configure Audio Card profiles. There's no need for pavucontrol anymore. 44 | 45 |
46 |
47 |
48 | 49 |

Open Source

50 | 51 | Myxer is licensed under the [GNU General Public License v3](https://github.com/Aurailus/Myxer/blob/master/LICENSE.md). It's being actively developed, and all issues and pull requests will be responded to promptly. It's also super lightweight, and should only take an hour or two to read through the source code, if that's your sort of thing. See [Contributing](https://github.com/Aurailus/Myxer/blob/master/CONTRIBUTING.md) for more details. 52 | 53 |
54 |
55 | 56 |

Heard enough? Download the Latest Release now.

57 | 58 |

Latest Artifact (Deb)   •   Building   •   Contributing

59 | 60 |
61 |
62 |
63 | 64 | © [Auri Collings](https://twitter.com/Aurailus), 2021. Made with <3 65 | 66 | -------------------------------------------------------------------------------- /media/myxer_advanced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aurailus/Myxer/ea53586408350e00b58c09e30864b3ec316503fb/media/myxer_advanced.png -------------------------------------------------------------------------------- /media/myxer_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aurailus/Myxer/ea53586408350e00b58c09e30864b3ec316503fb/media/myxer_dark.png -------------------------------------------------------------------------------- /media/myxer_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aurailus/Myxer/ea53586408350e00b58c09e30864b3ec316503fb/media/myxer_light.png -------------------------------------------------------------------------------- /media/myxer_thumbnail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Aurailus/Myxer/ea53586408350e00b58c09e30864b3ec316503fb/media/myxer_thumbnail.png -------------------------------------------------------------------------------- /nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "watch": ["src"], 3 | "ext": ".rs", 4 | "exec": "RUST_BACKTRACE=1 cargo run" 5 | } 6 | -------------------------------------------------------------------------------- /src/card.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * A widget representing a pulseaudio sound card. 3 | * Has a dropdown that allows the current card profile to be changed. 4 | */ 5 | 6 | use gtk::prelude::*; 7 | use glib::translate::ToGlib; 8 | use glib::translate::FromGlib; 9 | 10 | use crate::pulse::Pulse; 11 | use crate::shared::Shared; 12 | 13 | 14 | /** 15 | * Holds a Card's data. 16 | */ 17 | 18 | #[derive(Debug, Clone, Default)] 19 | pub struct CardData { 20 | pub index: u32, 21 | 22 | pub name: String, 23 | pub icon: String, 24 | 25 | pub profiles: Vec<(String, String)>, 26 | pub active_profile: String 27 | } 28 | 29 | 30 | /** 31 | * Holds a Card's widgets. 32 | */ 33 | 34 | struct CardWidgets { 35 | root: gtk::Box, 36 | 37 | label: gtk::Label, 38 | combo: gtk::ComboBoxText, 39 | } 40 | 41 | 42 | /** 43 | * A widget representing a pulseaudio sound card. 44 | * Has a dropdown that allows the current card profile to be changed. 45 | */ 46 | 47 | pub struct Card { 48 | pub widget: gtk::Box, 49 | widgets: CardWidgets, 50 | 51 | data: CardData, 52 | pulse: Option>, 53 | combo_connect_id: Option, 54 | } 55 | 56 | impl Card { 57 | 58 | /** 59 | * Constructs the GTK widgets required for the card widget. 60 | */ 61 | 62 | fn build() -> CardWidgets { 63 | let root = gtk::Box::new(gtk::Orientation::Horizontal, 0); 64 | root.set_widget_name("card"); 65 | 66 | let inner = gtk::Box::new(gtk::Orientation::Vertical, 0); 67 | inner.set_border_width(3); 68 | root.pack_start(&inner, true, true, 3); 69 | 70 | let label_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 71 | label_box.set_border_width(0); 72 | inner.pack_start(&label_box, false, false, 3); 73 | 74 | let icon = gtk::Image::from_icon_name(Some("audio-card"), gtk::IconSize::LargeToolbar); 75 | let label = gtk::Label::new(Some("Unknown Card")); 76 | 77 | label_box.pack_start(&icon, false, false, 3); 78 | label_box.pack_start(&label, false, true, 3); 79 | 80 | let combo = gtk::ComboBoxText::new(); 81 | inner.pack_start(&combo, false, false, 6); 82 | 83 | CardWidgets { 84 | root, 85 | label, 86 | combo 87 | } 88 | } 89 | 90 | 91 | /** 92 | * Creates a new card widget. 93 | */ 94 | 95 | pub fn new(pulse: Option>) -> Self { 96 | let widgets = Card::build(); 97 | Self { 98 | widget: widgets.root.clone(), widgets, 99 | data: CardData::default(), 100 | pulse, 101 | combo_connect_id: None 102 | } 103 | } 104 | 105 | 106 | /** 107 | * Disconnect's a card widget from the Pulse instance, 108 | * in the event that significant information has changed for the callbacks to be invalid. 109 | */ 110 | 111 | fn disconnect(&mut self) { 112 | if self.combo_connect_id.is_some() { 113 | self.widgets.combo.disconnect(glib::signal::SignalHandlerId::from_glib(self.combo_connect_id.as_ref().unwrap().to_glib())); 114 | } 115 | } 116 | 117 | 118 | /** 119 | * Connects a callback to the widget's dropdown, 120 | * so that changing the selected option changes the card's profile. 121 | * If the Pulse instance is None, the callback is not bound. 122 | */ 123 | 124 | fn connect(&mut self) { 125 | if self.pulse.is_none() { return; } 126 | 127 | let index = self.data.index; 128 | let pulse = self.pulse.as_ref().unwrap().clone(); 129 | self.combo_connect_id = Some(self.widgets.combo.connect_changed(move |combo| { 130 | pulse.borrow_mut().set_card_profile(index, &String::from(combo.get_active_id().unwrap())); 131 | })); 132 | } 133 | 134 | 135 | /** 136 | * Updates the Card's data, and visually refreshes the required components. 137 | */ 138 | 139 | pub fn set_data(&mut self, data: &CardData) { 140 | if data.index != self.data.index { 141 | self.data.index = data.index; 142 | self.disconnect(); 143 | self.connect(); 144 | } 145 | 146 | if data.name != self.data.name { 147 | self.data.name = data.name.clone(); 148 | self.widgets.label.set_label(&self.data.name); 149 | } 150 | 151 | if data.profiles.len() != self.data.profiles.len() { 152 | self.disconnect(); 153 | self.data.profiles = data.profiles.clone(); 154 | self.widgets.combo.remove_all(); 155 | for (i, n) in &data.profiles { self.widgets.combo.append(Some(&i), &n); } 156 | self.connect(); 157 | } 158 | 159 | if data.active_profile != self.data.active_profile { 160 | self.disconnect(); 161 | self.data.active_profile = data.active_profile.clone(); 162 | self.widgets.combo.set_active_id(Some(&self.data.active_profile)); 163 | self.connect(); 164 | } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /src/main.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Myxer is a GTK based pulse audio volume mixer. 3 | * This module serves as the main entry point to the application. 4 | */ 5 | 6 | #![allow(clippy::tabs_in_doc_comments)] 7 | 8 | use gio::prelude::*; 9 | 10 | mod card; 11 | mod meter; 12 | mod pulse; 13 | mod window; 14 | mod shared; 15 | 16 | use pulse::Pulse; 17 | use window::Myxer; 18 | use shared::Shared; 19 | 20 | 21 | /** 22 | * Attempts to start the application. 23 | * The attempt will abort if another instance is already live, this is 24 | * because GTK attempts to share the pulse manager between instances, 25 | * which doesn't work with the message consumption model that is currently 26 | * in-place. Presumably, there is a way to make both instances have completely 27 | * independent memory, but I was unable to find it. 28 | */ 29 | 30 | fn main() { 31 | let pulse = Shared::new(Pulse::new()); 32 | 33 | let app = gtk::Application::new(Some("com.aurailus.myxer"), Default::default()) 34 | .expect("Failed to initialize GTK application."); 35 | 36 | let pulse_clone = pulse.clone(); 37 | app.connect_activate(|app| drop(app.register::(None))); 38 | app.connect_startup(move |app| activate(app, &pulse_clone)); 39 | app.run(&[]); 40 | 41 | pulse.borrow_mut().cleanup(); 42 | } 43 | 44 | 45 | /** 46 | * Called by GTK when the application has initialized. Creates the main Myxer 47 | * instance, which controls the visible window, and handles the update loop. 48 | */ 49 | 50 | fn activate(app: >k::Application, pulse: &Shared) { 51 | let mut myxer = Myxer::new(app, pulse); 52 | 53 | glib::timeout_add_local(1000 / 30, move || { 54 | myxer.update(); 55 | glib::Continue(true) 56 | }); 57 | } 58 | -------------------------------------------------------------------------------- /src/meter/base_meter.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Contains constants and base traits for specialized meter widgets. 3 | */ 4 | 5 | use gtk::prelude::*; 6 | use libpulse::volume::{ Volume, ChannelVolumes }; 7 | 8 | use crate::shared::Shared; 9 | use crate::pulse::{ Pulse, StreamType }; 10 | 11 | /** The maximum natural volume, i.e. 100% */ 12 | pub const MAX_NATURAL_VOL: u32 = 65536; 13 | 14 | /** The maximum scale volume, i.e. 150% */ 15 | pub const MAX_SCALE_VOL: u32 = (MAX_NATURAL_VOL as f64 * 1.5) as u32; 16 | 17 | /** The increment step of the scale, e.g. how far it moves when you press up & down. */ 18 | pub const SCALE_STEP: f64 = MAX_NATURAL_VOL as f64 / 20.0; 19 | 20 | /** The icon names for the input meter statuses. */ 21 | pub const INPUT_ICONS: [&str; 4] = [ "microphone-sensitivity-muted-symbolic", "microphone-sensitivity-low-symbolic", 22 | "microphone-sensitivity-medium-symbolic", "microphone-sensitivity-high-symbolic" ]; 23 | 24 | /** The icon names for the output meter statuses. */ 25 | pub const OUTPUT_ICONS: [&str; 4] = [ "audio-volume-muted-symbolic", "audio-volume-low-symbolic", 26 | "audio-volume-medium-symbolic", "audio-volume-high-symbolic" ]; 27 | 28 | 29 | /** 30 | * Holds a Meter widget's display data. 31 | */ 32 | 33 | #[derive(Debug, Clone, Default)] 34 | pub struct MeterData { 35 | pub t: StreamType, 36 | pub index: u32, 37 | 38 | pub name: String, 39 | pub icon: String, 40 | pub description: String, 41 | 42 | pub volume: ChannelVolumes, 43 | pub muted: bool, 44 | } 45 | 46 | 47 | /** 48 | * Holds references to a Meter's widgets. 49 | */ 50 | 51 | pub struct MeterWidgets { 52 | pub root: gtk::Box, 53 | 54 | pub icon: gtk::Image, 55 | pub label: gtk::Label, 56 | pub select: gtk::Button, 57 | pub app_button: gtk::Button, 58 | 59 | pub status: gtk::Button, 60 | pub status_icon: gtk::Image, 61 | 62 | pub scales_outer: gtk::Box, 63 | pub scales_inner: gtk::Box, 64 | } 65 | 66 | 67 | /** 68 | * The base trait for all Meter widgets. 69 | * A Meter widget is a visual control consisting of a name, 70 | * app icon, volume slider, and mute button. 71 | */ 72 | 73 | pub trait Meter { 74 | /** 75 | * Gets the meter's underlying stream index. 76 | */ 77 | 78 | fn get_index(&self) -> u32; 79 | 80 | 81 | /** 82 | * Sets whether or not to split channels into individual meters. 83 | * 84 | * * `split` - Whether or not channels should be separated. 85 | */ 86 | 87 | fn split_channels(&mut self, split: bool); 88 | 89 | 90 | /** 91 | * Updates the meter's data, and visually refreshes the required widgets. 92 | */ 93 | 94 | fn set_data(&mut self, data: &MeterData); 95 | 96 | 97 | /** 98 | * Sets the meter's current peak. 99 | * 100 | * * `peak` - The meter's peak, or None if no peak indicator should be shown. 101 | */ 102 | 103 | fn set_peak(&mut self, peak: Option); 104 | } 105 | 106 | impl dyn Meter { 107 | 108 | /** 109 | * Builds a scale. This may be for a single channel, or all channels. 110 | */ 111 | 112 | fn build_scale() -> gtk::Scale { 113 | let scale = gtk::Scale::with_range(gtk::Orientation::Vertical, 0.0, MAX_SCALE_VOL as f64, SCALE_STEP); 114 | 115 | scale.set_inverted(true); 116 | scale.set_draw_value(false); 117 | scale.set_increments(SCALE_STEP, SCALE_STEP); 118 | scale.set_restrict_to_fill_level(false); 119 | 120 | scale.add_mark(0.0, gtk::PositionType::Right, Some("")); 121 | scale.add_mark(MAX_SCALE_VOL as f64, gtk::PositionType::Right, Some("")); 122 | scale.add_mark(MAX_NATURAL_VOL as f64, gtk::PositionType::Right, Some("")); 123 | 124 | scale 125 | } 126 | 127 | 128 | /** 129 | * Builds the required scales for a Meter. 130 | * This may be one or more, depending on the state of the `split` variable. 131 | * 132 | * * `pulse` - The pulse store to bind events to. 133 | * * `data` - The meter data to base the scales off of. 134 | * * `split` - Whether or not one merged bar should be created, or individual bars for each channel. 135 | */ 136 | 137 | pub fn build_scales(pulse: &Shared, data: &MeterData, split: bool) -> gtk::Box { 138 | let t = data.t; 139 | let index = data.index; 140 | 141 | let pulse = pulse.clone(); 142 | let scales_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 143 | 144 | if split { 145 | for _ in 0 .. data.volume.len() { 146 | let scale = Meter::build_scale(); 147 | let pulse = pulse.clone(); 148 | 149 | scale.connect_change_value(move |scale, _, val| { 150 | let parent = scale.get_parent().unwrap().downcast::().unwrap(); 151 | let children = parent.get_children(); 152 | 153 | let mut volumes = ChannelVolumes::default(); 154 | 155 | // So, if you're wondering why rev() is necessary or why I set the len after or why this is horrible in general, 156 | // Check out libpulse_binding::volumes::ChannelVolumes::set, and you'll see ._. 157 | for (i, w) in children.iter().enumerate().rev() { 158 | let s = w.clone().downcast::().unwrap(); 159 | let value = if *scale == s { val } else { s.get_value() }; 160 | let volume = Volume(value as u32); 161 | volumes.set(i as u8 + 1, volume); 162 | } 163 | 164 | volumes.set_len(children.len() as u8); 165 | 166 | let pulse = pulse.borrow_mut(); 167 | pulse.set_volume(t, index, volumes); 168 | if volumes.max().0 > 0 { pulse.set_muted(t, index, false); } 169 | gtk::Inhibit(false) 170 | }); 171 | 172 | scales_box.pack_start(&scale, false, false, 0); 173 | } 174 | } 175 | else { 176 | let scale = Meter::build_scale(); 177 | let channels = data.volume.len(); 178 | let pulse = pulse.clone(); 179 | scale.connect_change_value(move |_, _, value| { 180 | let mut volumes = ChannelVolumes::default(); 181 | volumes.set_len(channels); 182 | volumes.set(channels, Volume(value as u32)); 183 | let pulse = pulse.borrow_mut(); 184 | pulse.set_volume(t, index, volumes); 185 | if volumes.max().0 > 0 { pulse.set_muted(t, index, false); } 186 | gtk::Inhibit(false) 187 | }); 188 | scales_box.pack_start(&scale, false, false, 0); 189 | } 190 | 191 | scales_box.show_all(); 192 | scales_box 193 | } 194 | 195 | 196 | /** 197 | * Initializes all of the Widgets to make a meter, and returns them. 198 | */ 199 | 200 | pub fn build_meter() -> MeterWidgets { 201 | let root = gtk::Box::new(gtk::Orientation::Vertical, 0); 202 | root.set_widget_name("meter"); 203 | 204 | root.set_orientation(gtk::Orientation::Vertical); 205 | root.set_hexpand(false); 206 | root.set_size_request(86, -1); 207 | 208 | let app_button = gtk::Button::new(); 209 | app_button.set_widget_name("top"); 210 | app_button.get_style_context().add_class("flat"); 211 | let label_container = gtk::Box::new(gtk::Orientation::Vertical, 0); 212 | app_button.add(&label_container); 213 | 214 | let icon = gtk::Image::from_icon_name(Some("audio-volume-muted-symbolic"), gtk::IconSize::Dnd); 215 | 216 | let label = gtk::Label::new(Some("Unknown")); 217 | label.set_widget_name("app_label"); 218 | 219 | label.set_size_request(-1, 42); 220 | label.set_justify(gtk::Justification::Center); 221 | label.set_ellipsize(pango::EllipsizeMode::End); 222 | label.set_line_wrap_mode(pango::WrapMode::WordChar); 223 | label.set_max_width_chars(8); 224 | label.set_line_wrap(true); 225 | label.set_lines(2); 226 | 227 | label_container.pack_end(&label, false, true, 0); 228 | label_container.pack_end(&icon, false, false, 3); 229 | 230 | let select = gtk::Button::new(); 231 | select.set_widget_name("app_select"); 232 | select.get_style_context().add_class("flat"); 233 | 234 | let scales_outer = gtk::Box::new(gtk::Orientation::Horizontal, 0); 235 | let scales_inner = gtk::Box::new(gtk::Orientation::Horizontal, 0); 236 | scales_outer.pack_start(&scales_inner, true, false, 0); 237 | 238 | let status_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 239 | let status_icon = gtk::Image::from_icon_name(Some("audio-volume-muted-symbolic"), gtk::IconSize::Button); 240 | 241 | let status = gtk::Button::new(); 242 | status.set_widget_name("mute_toggle"); 243 | status_box.pack_start(&status, true, false, 0); 244 | 245 | status.set_image(Some(&status_icon)); 246 | status.set_always_show_image(true); 247 | status.get_style_context().add_class("flat"); 248 | status.get_style_context().add_class("muted"); 249 | 250 | root.pack_end(&status_box, false, false, 3); 251 | root.pack_end(&scales_outer, true, true, 2); 252 | root.pack_start(&app_button, false, false, 0); 253 | 254 | MeterWidgets { 255 | root, 256 | 257 | icon, 258 | label, 259 | select, 260 | app_button, 261 | 262 | status, 263 | status_icon, 264 | 265 | scales_outer, 266 | scales_inner 267 | } 268 | } 269 | } 270 | -------------------------------------------------------------------------------- /src/meter/mod.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Declares and re-exports the different Meter widgets. 3 | */ 4 | 5 | mod base_meter; 6 | pub use base_meter::*; 7 | 8 | mod sink_meter; 9 | pub use sink_meter::*; 10 | 11 | mod source_meter; 12 | pub use source_meter::*; 13 | 14 | mod stream_meter; 15 | pub use stream_meter::*; 16 | -------------------------------------------------------------------------------- /src/meter/sink_meter.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * A specialized meter for representing sinks. 3 | */ 4 | 5 | use gtk::prelude::*; 6 | use glib::translate::{ ToGlib, FromGlib }; 7 | 8 | use crate::pulse::Pulse; 9 | use crate::shared::Shared; 10 | use super::base_meter::{ Meter, MeterWidgets, MeterData }; 11 | use super::base_meter::{ MAX_NATURAL_VOL, MAX_SCALE_VOL, OUTPUT_ICONS }; 12 | 13 | 14 | /** 15 | * A meter widget representing a sink. 16 | * Has interactions to allow changing the active sink. 17 | */ 18 | 19 | pub struct SinkMeter { 20 | pub widget: gtk::Box, 21 | 22 | data: MeterData, 23 | widgets: MeterWidgets, 24 | pulse: Shared, 25 | 26 | pub split: bool, 27 | pub peak: Option, 28 | 29 | l_id: Option, 30 | s_id: Option, 31 | } 32 | 33 | impl SinkMeter { 34 | 35 | /** 36 | * Creates a new SinkMeter. 37 | */ 38 | 39 | pub fn new(pulse: Shared) -> Self { 40 | let widgets = Meter::build_meter(); 41 | Self { 42 | widget: widgets.root.clone(), 43 | 44 | pulse, 45 | widgets, 46 | data: MeterData::default(), 47 | 48 | split: false, peak: None, s_id: None, l_id: None 49 | } 50 | } 51 | 52 | 53 | /** 54 | * Rebuilds widgets that are dependent on the Pulse instance or the sink index. 55 | * Reconnects the widgets to the Pulse instance, if one is provided. 56 | */ 57 | 58 | fn rebuild_widgets(&mut self) { 59 | let scales = Meter::build_scales(&self.pulse, &self.data, self.split); 60 | self.widgets.scales_outer.remove(&self.widgets.scales_inner); 61 | self.widgets.scales_outer.pack_start(&scales, true, false, 0); 62 | self.widgets.scales_inner = scales; 63 | self.update_widgets(); 64 | 65 | let t = self.data.t; 66 | let index = self.data.index; 67 | let pulse = self.pulse.clone(); 68 | 69 | if self.s_id.is_some() { self.widgets.status.disconnect(glib::signal::SignalHandlerId::from_glib(self.s_id.as_ref().unwrap().to_glib())) } 70 | self.s_id = Some(self.widgets.status.connect_clicked(move |status| { 71 | pulse.borrow_mut().set_muted(t, index, 72 | !status.get_style_context().has_class("muted")); 73 | })); 74 | 75 | let pulse = self.pulse.clone(); 76 | let index = self.data.index; 77 | 78 | if self.l_id.is_some() { self.widgets.app_button.disconnect( 79 | glib::signal::SignalHandlerId::from_glib(self.l_id.as_ref().unwrap().to_glib())) } 80 | self.l_id = Some(self.widgets.app_button.connect_clicked(move |trigger| { 81 | SinkMeter::show_popup(&trigger, &pulse, index); 82 | })); 83 | } 84 | 85 | 86 | /** 87 | * Updates each scale widget to reflect the current volume level. 88 | */ 89 | 90 | fn update_widgets(&mut self) { 91 | for (i, v) in self.data.volume.get().iter().enumerate() { 92 | if let Some(scale) = self.widgets.scales_inner.get_children().get(i) { 93 | let scale = scale.clone().downcast::().expect("Scales box has non-scale children."); 94 | scale.set_sensitive(!self.data.muted); 95 | scale.set_value(v.0 as f64); 96 | } 97 | } 98 | } 99 | 100 | 101 | /** 102 | * Shows a popup menu on the top button, with items to set 103 | * the Sink as default, and change the visible sink. 104 | */ 105 | 106 | fn show_popup(trigger: >k::Button, pulse_shr: &Shared, index: u32) { 107 | let pulse = pulse_shr.borrow_mut(); 108 | let root = gtk::PopoverMenu::new(); 109 | root.set_border_width(6); 110 | 111 | let menu = gtk::Box::new(gtk::Orientation::Vertical, 0); 112 | menu.set_size_request(132, -1); 113 | root.add(&menu); 114 | 115 | // let split_channels = gtk::ModelButton::new(); 116 | // split_channels.set_property_text(Some("Split Channels")); 117 | // split_channels.set_action_name(Some("app.split_channels")); 118 | // menu.add(&split_channels); 119 | 120 | let set_default = gtk::ModelButton::new(); 121 | set_default.set_property_role(gtk::ButtonRole::Check); 122 | set_default.set_property_text(Some("Set as Default")); 123 | set_default.set_property_active(pulse.default_sink == index); 124 | set_default.set_sensitive(pulse.default_sink != index); 125 | 126 | let pulse_clone = pulse_shr.clone(); 127 | set_default.connect_clicked(move |set_default| { 128 | pulse_clone.borrow_mut().set_default_sink(index); 129 | set_default.set_property_active(true); 130 | set_default.set_sensitive(false); 131 | }); 132 | menu.add(&set_default); 133 | 134 | if pulse.sinks.len() >= 2 { 135 | menu.pack_start(>k::SeparatorMenuItem::new(), false, false, 3); 136 | 137 | let label = gtk::Label::new(Some("Visible Output")); 138 | label.set_sensitive(false); 139 | menu.pack_start(&label, true, true, 3); 140 | 141 | for (i, v) in &pulse.sinks { 142 | let button = gtk::ModelButton::new(); 143 | button.set_property_role(gtk::ButtonRole::Radio); 144 | button.set_property_active(v.data.index == index); 145 | let button_label = gtk::Label::new(Some(&v.data.description)); 146 | button_label.set_ellipsize(pango::EllipsizeMode::End); 147 | button_label.set_max_width_chars(18); 148 | button.get_child().unwrap().downcast::().unwrap().add(&button_label); 149 | 150 | let i = *i; 151 | let root = root.clone(); 152 | let pulse_clone = pulse_shr.clone(); 153 | button.connect_clicked(move |_| { 154 | pulse_clone.borrow_mut().set_active_sink(i); 155 | root.popdown(); 156 | }); 157 | 158 | menu.add(&button); 159 | } 160 | } 161 | 162 | for child in &root.get_children() { child.show_all(); } 163 | root.set_relative_to(Some(trigger)); 164 | root.popup(); 165 | } 166 | } 167 | 168 | impl Meter for SinkMeter { 169 | fn get_index(&self) -> u32 { 170 | self.data.index 171 | } 172 | 173 | fn split_channels(&mut self, split: bool) { 174 | if self.split == split { return } 175 | self.split = split; 176 | self.rebuild_widgets(); 177 | } 178 | 179 | fn set_data(&mut self, data: &MeterData) { 180 | let volume_old = self.data.volume; 181 | let volume_changed = data.volume != volume_old; 182 | 183 | if data.t != self.data.t || data.index != self.data.index || data.volume.len() != self.data.volume.len() { 184 | self.data.t = data.t; 185 | self.data.volume = data.volume; 186 | self.data.index = data.index; 187 | self.rebuild_widgets(); 188 | } 189 | 190 | if data.icon != self.data.icon { 191 | self.data.icon = data.icon.clone(); 192 | self.widgets.icon.set_from_icon_name(Some(&self.data.icon), gtk::IconSize::Dnd); 193 | } 194 | 195 | if data.name != self.data.name { 196 | self.data.name = data.name.clone(); 197 | self.rebuild_widgets(); 198 | } 199 | 200 | if data.description != self.data.description { 201 | self.data.description = data.description.clone(); 202 | self.widgets.label.set_label(&self.data.description); 203 | self.widgets.app_button.set_tooltip_text(Some(&self.data.description)); 204 | } 205 | 206 | if volume_changed || data.muted != self.data.muted { 207 | self.data.volume = data.volume; 208 | self.data.muted = data.muted; 209 | self.update_widgets(); 210 | 211 | let status_vol = if self.data.muted { 0 } else { self.data.volume.max().0 }; 212 | 213 | self.widgets.status_icon.set_from_icon_name(Some(OUTPUT_ICONS[ 214 | if status_vol == 0 { 0 } else if status_vol >= MAX_NATURAL_VOL { 3 } 215 | else if status_vol >= MAX_NATURAL_VOL / 2 { 2 } else { 1 }]), gtk::IconSize::Button); 216 | 217 | let mut vol_scaled = ((status_vol as f64) / MAX_NATURAL_VOL as f64 * 100.0).round() as u8; 218 | if vol_scaled > 150 { vol_scaled = 150 } 219 | 220 | let mut string = vol_scaled.to_string(); 221 | string.push('%'); 222 | 223 | self.widgets.status.set_label(&string); 224 | 225 | if status_vol == 0 {self.widgets.status.get_style_context().add_class("muted") } 226 | else { self.widgets.status.get_style_context().remove_class("muted") } 227 | } 228 | } 229 | 230 | fn set_peak(&mut self, peak: Option) { 231 | self.peak = peak; 232 | 233 | if self.peak.is_some() { 234 | for (i, s) in self.widgets.scales_inner.get_children().iter().enumerate() { 235 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 236 | let peak_scaled = self.peak.unwrap() as f64 * (self.data.volume.get()[i].0 as f64 / MAX_SCALE_VOL as f64); 237 | s.set_fill_level(peak_scaled as f64); 238 | s.set_show_fill_level(!self.data.muted && peak_scaled > 0.5); 239 | s.get_style_context().add_class("visualizer"); 240 | } 241 | } 242 | else { 243 | for s in &self.widgets.scales_inner.get_children() { 244 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 245 | s.set_show_fill_level(false); 246 | s.get_style_context().remove_class("visualizer"); 247 | } 248 | } 249 | } 250 | } 251 | -------------------------------------------------------------------------------- /src/meter/source_meter.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * A specialized meter for representing sources. 3 | */ 4 | 5 | use gtk::prelude::*; 6 | use glib::translate::{ ToGlib, FromGlib }; 7 | 8 | use crate::pulse::Pulse; 9 | use crate::shared::Shared; 10 | use super::base_meter::{ Meter, MeterWidgets, MeterData }; 11 | use super::base_meter::{ MAX_NATURAL_VOL, MAX_SCALE_VOL, INPUT_ICONS }; 12 | 13 | 14 | /** 15 | * A meter widget representing a source. 16 | * Has interactions to allow changing the active source. 17 | */ 18 | 19 | pub struct SourceMeter { 20 | pub widget: gtk::Box, 21 | 22 | data: MeterData, 23 | widgets: MeterWidgets, 24 | pulse: Shared, 25 | 26 | split: bool, 27 | peak: Option, 28 | 29 | l_id: Option, 30 | s_id: Option, 31 | } 32 | 33 | impl SourceMeter { 34 | 35 | /** 36 | * Creates a new SourceMeter. 37 | */ 38 | 39 | pub fn new(pulse: Shared) -> Self { 40 | let widgets = Meter::build_meter(); 41 | 42 | Self { 43 | widget: widgets.root.clone(), 44 | 45 | pulse, 46 | widgets, 47 | data: MeterData::default(), 48 | 49 | split: false, peak: None, l_id: None, s_id: None 50 | } 51 | } 52 | 53 | 54 | /** 55 | * Rebuilds widgets that are dependent on the Pulse instance or the source index. 56 | * Reconnects the widgets to the Pulse instance, if one is provided. 57 | */ 58 | 59 | fn rebuild_widgets(&mut self) { 60 | let scales = Meter::build_scales(&self.pulse, &self.data, self.split); 61 | self.widgets.scales_outer.remove(&self.widgets.scales_inner); 62 | self.widgets.scales_outer.pack_start(&scales, true, false, 0); 63 | self.widgets.scales_inner = scales; 64 | self.update_widgets(); 65 | 66 | let t = self.data.t; 67 | let index = self.data.index; 68 | let pulse = self.pulse.clone(); 69 | 70 | if self.s_id.is_some() { self.widgets.status.disconnect( 71 | glib::signal::SignalHandlerId::from_glib(self.s_id.as_ref().unwrap().to_glib())) } 72 | self.s_id = Some(self.widgets.status.connect_clicked(move |status| { 73 | pulse.borrow_mut().set_muted(t, index, 74 | !status.get_style_context().has_class("muted")); 75 | })); 76 | 77 | let pulse = self.pulse.clone(); 78 | let index = self.data.index; 79 | 80 | if self.l_id.is_some() { self.widgets.app_button.disconnect( 81 | glib::signal::SignalHandlerId::from_glib(self.l_id.as_ref().unwrap().to_glib())) } 82 | self.l_id = Some(self.widgets.app_button.connect_clicked(move |trigger| { 83 | SourceMeter::show_popup(&trigger, &pulse, index); 84 | })); 85 | } 86 | 87 | 88 | /** 89 | * Updates each scale widget to reflect the current volume level. 90 | */ 91 | 92 | fn update_widgets(&mut self) { 93 | for (i, v) in self.data.volume.get().iter().enumerate() { 94 | if let Some(scale) = self.widgets.scales_inner.get_children().get(i) { 95 | let scale = scale.clone().downcast::().expect("Scales box has non-scale children."); 96 | scale.set_sensitive(!self.data.muted); 97 | scale.set_value(v.0 as f64); 98 | } 99 | } 100 | } 101 | 102 | 103 | /** 104 | * Shows a popup menu on the top button, with items to set 105 | * the Sink as default, and change the visible source. 106 | */ 107 | 108 | fn show_popup(trigger: >k::Button, pulse_shr: &Shared, index: u32) { 109 | let pulse = pulse_shr.borrow_mut(); 110 | let root = gtk::PopoverMenu::new(); 111 | root.set_border_width(6); 112 | 113 | let menu = gtk::Box::new(gtk::Orientation::Vertical, 0); 114 | menu.set_size_request(132, -1); 115 | root.add(&menu); 116 | 117 | // let split_channels = gtk::ModelButton::new(); 118 | // split_channels.set_property_text(Some("Split Channels")); 119 | // split_channels.set_action_name(Some("app.split_channels")); 120 | // menu.add(&split_channels); 121 | 122 | let set_default = gtk::ModelButton::new(); 123 | set_default.set_property_role(gtk::ButtonRole::Check); 124 | set_default.set_property_text(Some("Set as Default")); 125 | set_default.set_property_active(pulse.default_source == index); 126 | set_default.set_sensitive(pulse.default_source != index); 127 | 128 | let pulse_clone = pulse_shr.clone(); 129 | set_default.connect_clicked(move |set_default| { 130 | pulse_clone.borrow_mut().set_default_source(index); 131 | set_default.set_property_active(true); 132 | set_default.set_sensitive(false); 133 | }); 134 | menu.add(&set_default); 135 | 136 | if pulse.sources.len() >= 2 { 137 | menu.pack_start(>k::SeparatorMenuItem::new(), false, false, 3); 138 | 139 | let label = gtk::Label::new(Some("Visible Input")); 140 | label.set_sensitive(false); 141 | menu.pack_start(&label, true, true, 3); 142 | 143 | for (i, v) in &pulse.sources { 144 | let button = gtk::ModelButton::new(); 145 | button.set_property_role(gtk::ButtonRole::Radio); 146 | button.set_property_active(v.data.index == index); 147 | let button_label = gtk::Label::new(Some(&v.data.description)); 148 | button_label.set_ellipsize(pango::EllipsizeMode::End); 149 | button_label.set_max_width_chars(18); 150 | button.get_child().unwrap().downcast::().unwrap().add(&button_label); 151 | 152 | let i = *i; 153 | let root = root.clone(); 154 | let pulse_clone = pulse_shr.clone(); 155 | button.connect_clicked(move |_| { 156 | pulse_clone.borrow_mut().set_active_source(i); 157 | root.popdown(); 158 | }); 159 | 160 | menu.add(&button); 161 | } 162 | } 163 | 164 | for child in &root.get_children() { child.show_all(); } 165 | root.set_relative_to(Some(trigger)); 166 | root.popup(); 167 | } 168 | } 169 | 170 | impl Meter for SourceMeter { 171 | fn get_index(&self) -> u32 { 172 | self.data.index 173 | } 174 | 175 | fn split_channels(&mut self, split: bool) { 176 | if self.split == split { return } 177 | self.split = split; 178 | self.rebuild_widgets(); 179 | } 180 | 181 | fn set_data(&mut self, data: &MeterData) { 182 | let volume_old = self.data.volume; 183 | let volume_changed = data.volume != volume_old; 184 | 185 | if data.t != self.data.t || data.index != self.data.index || data.volume.len() != self.data.volume.len() { 186 | self.data.t = data.t; 187 | self.data.volume = data.volume; 188 | self.data.index = data.index; 189 | self.rebuild_widgets(); 190 | } 191 | 192 | if data.icon != self.data.icon { 193 | self.data.icon = data.icon.clone(); 194 | self.widgets.icon.set_from_icon_name(Some(&self.data.icon), gtk::IconSize::Dnd); 195 | } 196 | 197 | if data.name != self.data.name { 198 | self.data.name = data.name.clone(); 199 | self.rebuild_widgets(); 200 | } 201 | 202 | if data.description != self.data.description { 203 | self.data.description = data.description.clone(); 204 | self.widgets.label.set_label(&self.data.description); 205 | self.widgets.app_button.set_tooltip_text(Some(&self.data.description)); 206 | } 207 | 208 | if volume_changed || data.muted != self.data.muted { 209 | self.data.volume = data.volume; 210 | self.data.muted = data.muted; 211 | self.update_widgets(); 212 | 213 | let status_vol = if self.data.muted { 0 } else { self.data.volume.max().0 }; 214 | 215 | self.widgets.status_icon.set_from_icon_name(Some(INPUT_ICONS[ 216 | if status_vol == 0 { 0 } else if status_vol >= MAX_NATURAL_VOL { 3 } 217 | else if status_vol >= MAX_NATURAL_VOL / 2 { 2 } else { 1 }]), gtk::IconSize::Button); 218 | 219 | let mut vol_scaled = ((status_vol as f64) / MAX_NATURAL_VOL as f64 * 100.0).round() as u8; 220 | if vol_scaled > 150 { vol_scaled = 150 } 221 | 222 | let mut string = vol_scaled.to_string(); 223 | string.push('%'); 224 | 225 | self.widgets.status.set_label(&string); 226 | 227 | if status_vol == 0 {self.widgets.status.get_style_context().add_class("muted") } 228 | else { self.widgets.status.get_style_context().remove_class("muted") } 229 | } 230 | } 231 | 232 | fn set_peak(&mut self, peak: Option) { 233 | if self.peak != peak { 234 | self.peak = peak; 235 | 236 | if self.peak.is_some() { 237 | for (i, s) in self.widgets.scales_inner.get_children().iter().enumerate() { 238 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 239 | let peak_scaled = self.peak.unwrap() as f64 * (self.data.volume.get()[i].0 as f64 / MAX_SCALE_VOL as f64); 240 | s.set_fill_level(peak_scaled as f64); 241 | s.set_show_fill_level(!self.data.muted && peak_scaled > 0.5); 242 | s.get_style_context().add_class("visualizer"); 243 | } 244 | } 245 | else { 246 | for s in &self.widgets.scales_inner.get_children() { 247 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 248 | s.set_show_fill_level(false); 249 | s.get_style_context().remove_class("visualizer"); 250 | } 251 | } 252 | } 253 | } 254 | } 255 | -------------------------------------------------------------------------------- /src/meter/stream_meter.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * A specialized meter for representing application streams. 3 | */ 4 | 5 | use gtk::prelude::*; 6 | use glib::translate::{ ToGlib, FromGlib }; 7 | 8 | use crate::shared::Shared; 9 | use crate::pulse::{ Pulse, StreamType }; 10 | use super::base_meter::{ Meter, MeterWidgets, MeterData }; 11 | use super::base_meter::{ MAX_NATURAL_VOL, MAX_SCALE_VOL, INPUT_ICONS, OUTPUT_ICONS }; 12 | 13 | 14 | /** 15 | * A meter widget representing an application stream, 16 | * be it a sink input or a source output. 17 | */ 18 | 19 | pub struct StreamMeter { 20 | pub widget: gtk::Box, 21 | 22 | data: MeterData, 23 | widgets: MeterWidgets, 24 | pulse: Shared, 25 | 26 | pub split: bool, 27 | pub peak: Option, 28 | 29 | b_id: Option, 30 | } 31 | 32 | impl StreamMeter { 33 | 34 | /** 35 | * Creates a new StreamMeter. 36 | */ 37 | 38 | pub fn new(pulse: Shared) -> Self { 39 | let widgets = Meter::build_meter(); 40 | Self { 41 | widget: widgets.root.clone(), 42 | 43 | pulse, 44 | widgets, 45 | data: MeterData::default(), 46 | 47 | split: false, peak: None, b_id: None 48 | } 49 | } 50 | 51 | 52 | /** 53 | * Rebuilds widgets that are dependent on the Pulse instance or the stream index. 54 | * Reconnects the widgets to the Pulse instance, if one is provided. 55 | */ 56 | 57 | fn rebuild_widgets(&mut self) { 58 | let scales = Meter::build_scales(&self.pulse, &self.data, self.split); 59 | self.widgets.scales_outer.remove(&self.widgets.scales_inner); 60 | self.widgets.scales_outer.pack_start(&scales, true, false, 0); 61 | self.widgets.scales_inner = scales; 62 | self.update_widgets(); 63 | 64 | let t = self.data.t; 65 | let index = self.data.index; 66 | let pulse = self.pulse.clone(); 67 | 68 | if self.b_id.is_some() { self.widgets.status.disconnect(glib::signal::SignalHandlerId::from_glib(self.b_id.as_ref().unwrap().to_glib())) } 69 | self.b_id = Some(self.widgets.status.connect_clicked(move |status| { 70 | pulse.borrow_mut().set_muted(t, index, !status.get_style_context().has_class("muted")); 71 | })); 72 | } 73 | 74 | 75 | /** 76 | * Updates each scale widget to reflect the current volume level. 77 | */ 78 | 79 | fn update_widgets(&mut self) { 80 | for (i, v) in self.data.volume.get().iter().enumerate() { 81 | if let Some(scale) = self.widgets.scales_inner.get_children().get(i) { 82 | let scale = scale.clone().downcast::().expect("Scales box has non-scale children."); 83 | scale.set_value(if self.data.muted { 0.0 } else { v.0 as f64 }); 84 | } 85 | } 86 | } 87 | } 88 | 89 | impl Meter for StreamMeter { 90 | fn get_index(&self) -> u32 { 91 | self.data.index 92 | } 93 | 94 | fn split_channels(&mut self, split: bool) { 95 | if self.split == split { return } 96 | self.split = split; 97 | self.rebuild_widgets(); 98 | } 99 | 100 | fn set_data(&mut self, data: &MeterData) { 101 | let volume_old = self.data.volume; 102 | let volume_changed = data.volume != volume_old; 103 | 104 | if data.t != self.data.t || data.index != self.data.index || data.volume.len() != self.data.volume.len() { 105 | self.data.t = data.t; 106 | self.data.volume = data.volume; 107 | self.data.index = data.index; 108 | self.rebuild_widgets(); 109 | } 110 | 111 | if data.icon != self.data.icon { 112 | self.data.icon = data.icon.clone(); 113 | self.widgets.icon.set_from_icon_name(Some(&self.data.icon), gtk::IconSize::Dnd); 114 | } 115 | 116 | if data.name != self.data.name { 117 | self.data.name = data.name.clone(); 118 | } 119 | 120 | if data.description != self.data.description { 121 | self.data.description = data.description.clone(); 122 | self.widgets.label.set_label(&self.data.description); 123 | self.widgets.app_button.set_tooltip_text(Some(&self.data.description)); 124 | } 125 | 126 | if volume_changed || data.muted != self.data.muted { 127 | self.data.volume = data.volume; 128 | self.data.muted = data.muted; 129 | self.update_widgets(); 130 | 131 | let status_vol = if self.data.muted { 0 } else { self.data.volume.max().0 }; 132 | 133 | let &icons = if self.data.t == StreamType::Sink || self.data.t == StreamType::SinkInput 134 | { &OUTPUT_ICONS } else { &INPUT_ICONS }; 135 | 136 | self.widgets.status_icon.set_from_icon_name(Some(icons[ 137 | if status_vol == 0 { 0 } else if status_vol >= MAX_NATURAL_VOL { 3 } 138 | else if status_vol >= MAX_NATURAL_VOL / 2 { 2 } else { 1 }]), gtk::IconSize::Button); 139 | 140 | let mut vol_scaled = ((status_vol as f64) / MAX_NATURAL_VOL as f64 * 100.0).round() as u8; 141 | if vol_scaled > 150 { vol_scaled = 150 } 142 | 143 | let mut string = vol_scaled.to_string(); 144 | string.push('%'); 145 | 146 | self.widgets.status.set_label(&string); 147 | 148 | if status_vol == 0 {self.widgets.status.get_style_context().add_class("muted") } 149 | else { self.widgets.status.get_style_context().remove_class("muted") } 150 | } 151 | } 152 | 153 | fn set_peak(&mut self, peak: Option) { 154 | self.peak = peak; 155 | 156 | if self.peak.is_some() { 157 | for (i, s) in self.widgets.scales_inner.get_children().iter().enumerate() { 158 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 159 | let peak_scaled = self.peak.unwrap() as f64 * (self.data.volume.get()[i].0 as f64 / MAX_SCALE_VOL as f64); 160 | s.set_fill_level(peak_scaled as f64); 161 | s.set_show_fill_level(!self.data.muted && peak_scaled > 0.5); 162 | s.get_style_context().add_class("visualizer"); 163 | } 164 | } 165 | else { 166 | for s in &self.widgets.scales_inner.get_children() { 167 | let s = s.clone().downcast::().expect("Scales box has non-scale children."); 168 | s.set_show_fill_level(false); 169 | s.get_style_context().remove_class("visualizer"); 170 | } 171 | } 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /src/pulse.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * The main data-store / binding module that interacts with the pulse audio server. 3 | * Monitors the pulse server for updates, and also exposes methods to request changes. 4 | */ 5 | 6 | use slice_as_array::{ slice_as_array, slice_as_array_transmute }; 7 | 8 | use libpulse::def::BufferAttr; 9 | use libpulse::callbacks::ListResult; 10 | use libpulse::sample::{ Spec, Format }; 11 | use libpulse::mainloop::threaded::Mainloop; 12 | use libpulse::proplist::{ Proplist, properties }; 13 | use libpulse::volume::{ Volume, ChannelVolumes }; 14 | use libpulse::stream::{ Stream, FlagSet as StreamFlagSet, PeekResult }; 15 | use libpulse::context::subscribe::{ InterestMaskSet, Facility, Operation }; 16 | use libpulse::context::{ Context, FlagSet as CtxFlagSet, State as ContextState }; 17 | use libpulse::context::introspect::{ ServerInfo, SourceInfo, SinkInfo, SinkInputInfo, SourceOutputInfo, CardInfo }; 18 | 19 | use std::collections::HashMap; 20 | use std::sync::mpsc::{ channel, Sender, Receiver }; 21 | 22 | use super::shared::Shared; 23 | use super::card::CardData; 24 | use super::meter::MeterData; 25 | use super::meter::MAX_NATURAL_VOL; 26 | 27 | 28 | /** 29 | * Represents a stream's underlying type. 30 | */ 31 | 32 | #[derive(Copy, Clone, Debug, PartialEq)] 33 | pub enum StreamType { 34 | Sink, SinkInput, Source, SourceOutput 35 | } 36 | 37 | impl Default for StreamType { 38 | fn default() -> Self { StreamType::Sink } 39 | } 40 | 41 | 42 | /** 43 | * The different message types that can be passed from the pulse 44 | * thread to the data store. They contain data related to the 45 | * current state of the pulse server. 46 | */ 47 | 48 | enum TxMessage { 49 | Default(String, String), 50 | StreamUpdate(StreamType, TxStreamData), 51 | StreamRemove(StreamType, u32), 52 | CardUpdate(CardData), 53 | CardRemove(u32), 54 | Peak(StreamType, u32, u32) 55 | } 56 | 57 | 58 | /** 59 | * Transferrable information pertaining to a stream. 60 | */ 61 | 62 | #[derive(Debug)] 63 | pub struct TxStreamData { 64 | pub data: MeterData, 65 | pub monitor_index: u32, 66 | } 67 | 68 | 69 | /** 70 | * Stored representation of a pulse stream. 71 | * The stream index is not in this struct, but 72 | * it is the index it is keyed under in its hashmap. 73 | */ 74 | 75 | pub struct StreamData { 76 | pub data: MeterData, 77 | 78 | pub peak: u32, 79 | pub repetitions: u32, 80 | pub monitor_index: u32, 81 | pub monitor: Shared 82 | } 83 | 84 | 85 | /** Container for mspc channel sender & receiver. */ 86 | struct Channel { tx: Sender, rx: Receiver } 87 | 88 | 89 | /** 90 | * The main controller for all pulse server interactions. 91 | * Handles peak monitoring, stream discovery, and meter information. 92 | * Stores data for all known streams, allowing public access. 93 | */ 94 | 95 | pub struct Pulse { 96 | mainloop: Shared, 97 | context: Shared, 98 | channel: Channel, 99 | 100 | pub default_sink: u32, 101 | pub default_source: u32, 102 | pub active_sink: u32, 103 | pub active_source: u32, 104 | 105 | pub sinks: HashMap, 106 | pub sink_inputs: HashMap, 107 | pub sources: HashMap, 108 | pub source_outputs: HashMap, 109 | pub cards: HashMap, 110 | } 111 | 112 | impl Pulse { 113 | 114 | /** 115 | * Creates a new pulse controller, configuring (but not initializing) the pulse connection. 116 | */ 117 | 118 | pub fn new() -> Self { 119 | let mut proplist = Proplist::new().unwrap(); 120 | proplist.set_str(properties::APPLICATION_NAME, "Myxer").unwrap(); 121 | 122 | let mainloop = Shared::new(Mainloop::new().expect("Failed to initialize pulse mainloop.")); 123 | 124 | let context = Shared::new( 125 | Context::new_with_proplist(&*mainloop.borrow(), "Myxer Context", &proplist) 126 | .expect("Failed to initialize pulse context.")); 127 | 128 | let ( tx, rx ) = channel::(); 129 | 130 | Pulse { 131 | mainloop, context, 132 | channel: Channel { tx, rx }, 133 | 134 | default_sink: u32::MAX, 135 | default_source: u32::MAX, 136 | active_sink: u32::MAX, 137 | active_source: u32::MAX, 138 | 139 | sinks: HashMap::new(), 140 | sink_inputs: HashMap::new(), 141 | sources: HashMap::new(), 142 | source_outputs: HashMap::new(), 143 | cards: HashMap::new() 144 | } 145 | } 146 | 147 | 148 | /** 149 | * Initiates a connection to pulse. Blocks until success, panics on failure. 150 | * TODO: Graceful error handling, with debug message. 151 | * TODO: Try to see if there's a way to avoid using unsafe? It's in the docs... but...? 152 | */ 153 | 154 | pub fn connect(&mut self) { 155 | let mut mainloop = self.mainloop.borrow_mut(); 156 | let mut ctx = self.context.borrow_mut(); 157 | 158 | let mainloop_shr_ref = self.mainloop.clone(); 159 | let ctx_shr_ref = self.context.clone(); 160 | 161 | ctx.set_state_callback(Some(Box::new(move || { 162 | match unsafe { (*ctx_shr_ref.as_ptr()).get_state() } { 163 | ContextState::Ready | 164 | ContextState::Failed | 165 | ContextState::Terminated => 166 | unsafe { (*mainloop_shr_ref.as_ptr()).signal(false); }, 167 | _ => {}, 168 | } 169 | }))); 170 | 171 | ctx.connect(None, CtxFlagSet::NOFLAGS, None) 172 | .expect("Failed to connect to the pulse server."); 173 | 174 | mainloop.lock(); 175 | mainloop.start().expect("Failed to start pulse mainloop."); 176 | 177 | loop { 178 | match ctx.get_state() { 179 | ContextState::Ready => { 180 | ctx.set_state_callback(None); 181 | mainloop.unlock(); 182 | break; 183 | }, 184 | ContextState::Failed | 185 | ContextState::Terminated => { 186 | eprintln!("Context state failed/terminated, quitting..."); 187 | mainloop.unlock(); 188 | mainloop.stop(); 189 | panic!("Pulse session terminated."); 190 | }, 191 | _ => { mainloop.wait(); }, 192 | } 193 | } 194 | 195 | drop(ctx); 196 | drop(mainloop); 197 | self.subscribe(); 198 | } 199 | 200 | 201 | /** 202 | * Asynchronously sets the default sink to the index provided. 203 | * This is sometimes described as the fallback device. 204 | * 205 | * * `sink` - The sink index to set as the default. 206 | */ 207 | 208 | pub fn set_default_sink(&self, sink: u32) { 209 | if let Some(sink) = self.sinks.get(&sink) { 210 | let mut mainloop = self.mainloop.borrow_mut(); 211 | mainloop.lock(); 212 | self.context.borrow_mut().set_default_sink(&sink.data.name, |_|()); 213 | mainloop.unlock(); 214 | } 215 | } 216 | 217 | 218 | /** 219 | * Asynchronously sets the default source to the index provided. 220 | * This is sometimes described as the fallback device. 221 | * 222 | * * `source` - The source index to set as the default. 223 | */ 224 | 225 | pub fn set_default_source(&self, source: u32) { 226 | if let Some(source) = self.sources.get(&source) { 227 | let mut mainloop = self.mainloop.borrow_mut(); 228 | mainloop.lock(); 229 | self.context.borrow_mut().set_default_source(&source.data.name, |_|()); 230 | mainloop.unlock(); 231 | } 232 | } 233 | 234 | 235 | /** 236 | * Sets the 'active' sink to the index provided. 237 | * This is the sink that is currently displayed on the interface. 238 | * 239 | * * `sink` - The sink index to set as active. 240 | */ 241 | 242 | pub fn set_active_sink(&mut self, sink: u32) { 243 | self.active_sink = sink; 244 | } 245 | 246 | 247 | /** 248 | * Sets the 'active' source to the index provided. 249 | * This is the source that is currently displayed on the interface. 250 | * 251 | * * `source` - The source to set as active. 252 | */ 253 | 254 | pub fn set_active_source(&mut self, source: u32) { 255 | self.active_source = source; 256 | } 257 | 258 | 259 | /** 260 | * Sets the volume of the stream to the volumes specified. 261 | * This operation is asynchronous, so changes will not be reflected immediately. 262 | * 263 | * * `t` - The type of stream to set the volume of. 264 | * * `index` - The index of the stream to set the volume of. 265 | * * `volumes` - The desired volumes to set the channels of the stream to. 266 | */ 267 | 268 | pub fn set_volume(&self, t: StreamType, index: u32, volumes: ChannelVolumes) { 269 | let mut introspect = self.context.borrow().introspect(); 270 | let mut mainloop = self.mainloop.borrow_mut(); 271 | mainloop.lock(); 272 | 273 | match t { 274 | StreamType::Sink => { introspect.set_sink_volume_by_index(index, &volumes, None); }, 275 | StreamType::SinkInput => { introspect.set_sink_input_volume(index, &volumes, None); }, 276 | StreamType::Source => { introspect.set_source_volume_by_index(index, &volumes, None); }, 277 | StreamType::SourceOutput => { introspect.set_source_output_volume(index, &volumes, None); } 278 | }; 279 | 280 | mainloop.unlock(); 281 | } 282 | 283 | 284 | /** 285 | * Mutes or unmutes a stream. 286 | * This operation is asynchronous, so changes will not be reflected immediately. 287 | * 288 | * * `t` - The type of stream to update. 289 | * * `index` - The index of the stream to update. 290 | * * `mute` - Whether the stream should be muted or not. 291 | */ 292 | 293 | pub fn set_muted(&self, t: StreamType, index: u32, mute: bool) { 294 | // If unmuting a stream that has been set to 0 volume, it should be reset to full. 295 | if !mute { 296 | let entry = match t { 297 | StreamType::Sink => self.sinks.get(&index), 298 | StreamType::SinkInput => self.sink_inputs.get(&index), 299 | StreamType::Source => self.sources.get(&index), 300 | StreamType::SourceOutput => self.source_outputs.get(&index), 301 | }; 302 | 303 | if let Some(entry) = entry { 304 | if entry.data.volume.max().0 == 0 { 305 | let mut volumes = ChannelVolumes::default(); 306 | volumes.set_len(entry.data.volume.len()); 307 | volumes.set(entry.data.volume.len(), Volume(MAX_NATURAL_VOL)); 308 | self.set_volume(t, index, volumes); 309 | } 310 | } 311 | }; 312 | 313 | let mut introspect = self.context.borrow().introspect(); 314 | let mut mainloop = self.mainloop.borrow_mut(); 315 | mainloop.lock(); 316 | 317 | match t { 318 | StreamType::Sink => { introspect.set_sink_mute_by_index(index, mute, None) }, 319 | StreamType::SinkInput => { introspect.set_sink_input_mute(index, mute, None) }, 320 | StreamType::Source => { introspect.set_source_mute_by_index(index, mute, None) }, 321 | StreamType::SourceOutput => { introspect.set_source_output_mute(index, mute, None) } 322 | }; 323 | 324 | mainloop.unlock(); 325 | } 326 | 327 | 328 | /** 329 | * Set's a sound card's profile. 330 | * This effects how the card behaves, and how the system can utilize it. 331 | * 332 | * * `index` - The card index to update. 333 | * * `profile` - The profile name to update the card to. 334 | */ 335 | 336 | pub fn set_card_profile(&self, index: u32, profile: &str) { 337 | let mut introspect = self.context.borrow().introspect(); 338 | let mut mainloop = self.mainloop.borrow_mut(); 339 | mainloop.lock(); 340 | introspect.set_card_profile_by_index(index, profile, None); 341 | mainloop.unlock(); 342 | } 343 | 344 | 345 | /** 346 | * Binds listeners to server events, and triggers an 347 | * initial sweep to populate the internal stores. 348 | * Called by connect(), separated for readability. 349 | */ 350 | 351 | fn subscribe(&mut self) { 352 | /** Updates the client when the server information changes. */ 353 | fn tx_server(tx: &Sender, item: &ServerInfo<'_>) { 354 | tx.send(TxMessage::Default(item.default_sink_name.clone().unwrap().into_owned(), 355 | item.default_source_name.clone().unwrap().into_owned())).unwrap(); 356 | }; 357 | 358 | /** Updates the client when a sink changes. */ 359 | fn tx_sink(tx: &Sender, result: ListResult<&SinkInfo<'_>>) { 360 | if let ListResult::Item(item) = result { 361 | tx.send(TxMessage::StreamUpdate(StreamType::Sink, TxStreamData { 362 | data: MeterData { 363 | t: StreamType::Sink, 364 | index: item.index, 365 | icon: "multimedia-volume-control".to_owned(), 366 | name: item.name.clone().unwrap().into_owned(), 367 | description: item.description.clone().unwrap().into_owned(), 368 | volume: item.volume, 369 | muted: item.mute 370 | }, 371 | monitor_index: item.monitor_source 372 | })).unwrap(); 373 | }; 374 | }; 375 | 376 | /** Updates the client when a sink input changes. */ 377 | fn tx_sink_input(tx: &Sender, result: ListResult<&SinkInputInfo<'_>>) { 378 | if let ListResult::Item(item) = result { 379 | tx.send(TxMessage::StreamUpdate(StreamType::SinkInput, TxStreamData { 380 | data: MeterData { 381 | t: StreamType::SinkInput, 382 | index: item.index, 383 | icon: item.proplist.get_str("application.icon_name").unwrap_or_else(|| "audio-card".to_owned()), 384 | name: item.name.clone().unwrap().into_owned(), 385 | description: item.proplist.get_str("application.name").unwrap_or_else(|| "".to_owned()), 386 | volume: item.volume, 387 | muted: item.mute 388 | }, 389 | monitor_index: item.sink 390 | })).unwrap(); 391 | }; 392 | }; 393 | 394 | /** Updates the client when a source changes. */ 395 | fn tx_source(tx: &Sender, result: ListResult<&SourceInfo<'_>>) { 396 | if let ListResult::Item(item) = result { 397 | let name = item.name.clone().unwrap().into_owned(); 398 | if name.ends_with(".monitor") { return; } 399 | tx.send(TxMessage::StreamUpdate(StreamType::Source, TxStreamData { 400 | data: MeterData { 401 | t: StreamType::Source, 402 | index: item.index, 403 | icon: "audio-input-microphone".to_owned(), 404 | name: item.name.clone().unwrap().into_owned(), 405 | description: item.description.clone().unwrap().into_owned(), 406 | volume: item.volume, 407 | muted: item.mute 408 | }, 409 | monitor_index: item.index 410 | })).unwrap(); 411 | }; 412 | }; 413 | 414 | /** Updates the client when a source output changes. */ 415 | fn tx_source_output(tx: &Sender, result: ListResult<&SourceOutputInfo<'_>>) { 416 | if let ListResult::Item(item) = result { 417 | let app_id = item.proplist.get_str("application.process.binary").unwrap_or_else(|| "".to_owned()).to_lowercase(); 418 | if app_id.contains("pavucontrol") || app_id.contains("myxer") { return; } 419 | tx.send(TxMessage::StreamUpdate(StreamType::SourceOutput, TxStreamData { 420 | data: MeterData { 421 | t: StreamType::SourceOutput, 422 | index: item.index, 423 | icon: item.proplist.get_str("application.icon_name").unwrap_or_else(|| "audio-card".to_owned()), 424 | name: item.name.clone().unwrap().into_owned(), 425 | description: item.proplist.get_str("application.name").unwrap_or_else(|| "".to_owned()), 426 | volume: item.volume, 427 | muted: item.mute 428 | }, 429 | monitor_index: item.source 430 | })).unwrap(); 431 | }; 432 | }; 433 | 434 | /** Updates the client when a sound card changes. */ 435 | fn tx_card(tx: &Sender, result: ListResult<&CardInfo<'_>>) { 436 | if let ListResult::Item(item) = result { 437 | tx.send(TxMessage::CardUpdate(CardData { 438 | index: item.index, 439 | name: item.proplist.get_str("device.description") 440 | .or_else(|| item.proplist.get_str("device.alias")) 441 | .or_else(|| item.proplist.get_str("device.name")) 442 | .unwrap_or_else(|| "".to_owned()), 443 | icon: item.proplist.get_str("device.icon_name").unwrap_or_else(|| "audio-card-pci".to_owned()), 444 | profiles: item.profiles.iter().map(|p| (p.name.as_ref().unwrap().clone().into_owned(), 445 | p.description.as_ref().unwrap().clone().into_owned())).collect(), 446 | active_profile: item.active_profile.as_ref().unwrap().name.as_ref().unwrap().clone().into_owned() 447 | })).unwrap(); 448 | } 449 | } 450 | 451 | let mut mainloop = self.mainloop.borrow_mut(); 452 | mainloop.lock(); 453 | let mut context = self.context.borrow_mut(); 454 | let introspect = context.introspect(); 455 | 456 | let tx = self.channel.tx.clone(); 457 | introspect.get_sink_info_list(move |res| tx_sink(&tx, res)); 458 | let tx = self.channel.tx.clone(); 459 | introspect.get_sink_input_info_list(move |res| tx_sink_input(&tx, res)); 460 | let tx = self.channel.tx.clone(); 461 | introspect.get_source_info_list(move |res| tx_source(&tx, res)); 462 | let tx = self.channel.tx.clone(); 463 | introspect.get_source_output_info_list(move |res| tx_source_output(&tx, res)); 464 | let tx = self.channel.tx.clone(); 465 | introspect.get_card_info_list(move |res| tx_card(&tx, res)); 466 | let tx = self.channel.tx.clone(); 467 | introspect.get_server_info(move |res| tx_server(&tx, res)); 468 | 469 | let tx = self.channel.tx.clone(); 470 | context.subscribe(InterestMaskSet::SERVER | InterestMaskSet::SINK | InterestMaskSet::SINK_INPUT | 471 | InterestMaskSet::SOURCE | InterestMaskSet::SOURCE_OUTPUT | InterestMaskSet::CARD, |_|()); 472 | context.set_subscribe_callback(Some(Box::new(move |fac, op, index| { 473 | let tx = tx.clone(); 474 | let facility = fac.unwrap(); 475 | let operation = op.unwrap(); 476 | 477 | match facility { 478 | Facility::Server => { introspect.get_server_info(move |res| tx_server(&tx, res)); }, 479 | Facility::Sink => match operation { 480 | Operation::Removed => tx.send(TxMessage::StreamRemove(StreamType::Sink, index)).unwrap(), 481 | _ => { introspect.get_sink_info_by_index(index, move |res| tx_sink(&tx, res)); } 482 | }, 483 | Facility::SinkInput => match operation { 484 | Operation::Removed => tx.send(TxMessage::StreamRemove(StreamType::SinkInput, index)).unwrap(), 485 | _ => { introspect.get_sink_input_info(index, move |res| tx_sink_input(&tx, res)); } 486 | }, 487 | Facility::Source => match operation { 488 | Operation::Removed => tx.send(TxMessage::StreamRemove(StreamType::Source, index)).unwrap(), 489 | _ => { introspect.get_source_info_by_index(index, move |res| tx_source(&tx, res)); } 490 | }, 491 | Facility::SourceOutput => match operation { 492 | Operation::Removed => tx.send(TxMessage::StreamRemove(StreamType::SourceOutput, index)).unwrap(), 493 | _ => { introspect.get_source_output_info(index, move |res| tx_source_output(&tx, res)); } 494 | }, 495 | Facility::Card => match operation { 496 | Operation::Removed => tx.send(TxMessage::CardRemove(index)).unwrap(), 497 | _ => { introspect.get_card_info_by_index(index, move |res| tx_card(&tx, res)); } 498 | }, 499 | _ => () 500 | }; 501 | }))); 502 | 503 | mainloop.unlock(); 504 | } 505 | 506 | 507 | /** 508 | * Handles queued messages from the pulse thread, updating the internal storage. 509 | * Returns a boolean indicating that a layout refresh is required. 510 | */ 511 | 512 | pub fn update(&mut self) -> bool { 513 | let mut received = false; 514 | 515 | loop { 516 | let res = self.channel.rx.try_recv(); 517 | match res { 518 | Ok(res) => { 519 | received = true; 520 | match res { 521 | TxMessage::Default(sink, source) => self.update_default(sink, source), 522 | TxMessage::StreamUpdate(t, data) => self.update_stream(t, &data), 523 | TxMessage::StreamRemove(t, ind) => self.remove_stream(t, ind), 524 | TxMessage::CardUpdate(data) => self.update_card(&data), 525 | TxMessage::CardRemove(ind) => self.remove_card(ind), 526 | TxMessage::Peak(t, ind, peak) => self.update_peak(t, ind, peak), 527 | } 528 | }, 529 | _ => break 530 | } 531 | } 532 | 533 | received 534 | } 535 | 536 | 537 | /** 538 | * Closes the connection to the pulse server, and cleans up any dangling monitors. 539 | * After this operation, no other methods should be called, and the instance should be freed from memory. 540 | */ 541 | 542 | pub fn cleanup(&mut self) { 543 | while let Some((i, _)) = self.sinks.iter().next() { let i = *i; self.remove_stream(StreamType::Sink, i) } 544 | while let Some((i, _)) = self.sink_inputs.iter().next() { let i = *i; self.remove_stream(StreamType::SinkInput, i) } 545 | while let Some((i, _)) = self.sources.iter().next() { let i = *i; self.remove_stream(StreamType::Source, i) } 546 | while let Some((i, _)) = self.source_outputs.iter().next() { let i = *i; self.remove_stream(StreamType::SourceOutput, i) } 547 | 548 | let mut mainloop = self.mainloop.borrow_mut(); 549 | mainloop.stop(); 550 | } 551 | 552 | 553 | /** 554 | * Updates the stored default sink and source to the ones identified. 555 | * This method is called by the update method, the names are provided by the pulse server. 556 | * 557 | * * `sink` - The default sink. 558 | * * `source` - The default source. 559 | */ 560 | 561 | fn update_default(&mut self, sink: String, source: String) { 562 | for (i, v) in &self.sinks { 563 | if v.data.name == sink { 564 | self.default_sink = *i; 565 | self.active_sink = *i; 566 | break; 567 | } 568 | } 569 | 570 | for (i, v) in &self.sources { 571 | if v.data.name == source { 572 | self.default_source = *i; 573 | self.active_source = *i; 574 | break; 575 | } 576 | } 577 | } 578 | 579 | 580 | /** 581 | * Updates a stream in the store, or creates a new one and begins monitoring the peaks. 582 | * This method is called by the update method, the data is provided by the pulse server. 583 | * 584 | * * `t` - The type of stream to update. 585 | * * `stream` - The new stream's data. 586 | */ 587 | 588 | fn update_stream(&mut self, t: StreamType, stream: &TxStreamData) { 589 | let data = stream.data.clone(); 590 | let index = data.index; 591 | 592 | let entry = match t { 593 | StreamType::Sink => self.sinks.get_mut(&index), 594 | StreamType::SinkInput => self.sink_inputs.get_mut(&index), 595 | StreamType::Source => self.sources.get_mut(&index), 596 | StreamType::SourceOutput => self.source_outputs.get_mut(&index), 597 | }; 598 | 599 | if let Some(stream) = entry { stream.data = data; } 600 | else { 601 | let source_str = stream.monitor_index.to_string(); 602 | let monitor = self.create_monitor_stream(t, if t == StreamType::SinkInput { None } else { Some(&source_str) }, index); 603 | let data = StreamData { data, peak: 0, repetitions: 0, monitor, monitor_index: stream.monitor_index }; 604 | match t { 605 | StreamType::Sink => self.sinks.insert(index, data), 606 | StreamType::SinkInput => self.sink_inputs.insert(index, data), 607 | StreamType::Source => self.sources.insert(index, data), 608 | StreamType::SourceOutput => self.source_outputs.insert(index, data) 609 | }; 610 | } 611 | } 612 | 613 | 614 | /** 615 | * Removes a stream from the store, stopping the monitor, if there is one. 616 | * This method is called by the update method, the data is provided by the pulse server. 617 | * 618 | * * `t` - The type of stream to remove. 619 | * * `index` - The index of the stream to remove. 620 | */ 621 | 622 | fn remove_stream(&mut self, t: StreamType, index: u32) { 623 | let stream_opt = match t { 624 | StreamType::Sink => self.sinks.get_mut(&index), 625 | StreamType::SinkInput => self.sink_inputs.get_mut(&index), 626 | StreamType::Source => self.sources.get_mut(&index), 627 | StreamType::SourceOutput => self.source_outputs.get_mut(&index), 628 | }; 629 | 630 | if let Some(stream) = stream_opt { 631 | let mut monitor = stream.monitor.borrow_mut(); 632 | let mut mainloop = self.mainloop.borrow_mut(); 633 | mainloop.lock(); 634 | if monitor.get_state().is_good() { 635 | monitor.set_read_callback(None); 636 | let _ = monitor.disconnect(); 637 | } 638 | mainloop.unlock(); 639 | } 640 | 641 | match t { 642 | StreamType::Sink => self.sinks.remove(&index), 643 | StreamType::SinkInput => self.sink_inputs.remove(&index), 644 | StreamType::Source => self.sources.remove(&index), 645 | StreamType::SourceOutput => self.source_outputs.remove(&index), 646 | }; 647 | } 648 | 649 | 650 | /** 651 | * Updates a stored stream's peak. 652 | * This method is called by the update method, the data is provided by a monitor stream. 653 | * 654 | * * `t` - The type of stream to update. 655 | * * `index` - The index of the stream to update. 656 | * * `peak` - The peak value to store. 657 | */ 658 | 659 | fn update_peak(&mut self, t: StreamType, index: u32, peak: u32) { 660 | match t { 661 | StreamType::Sink => self.sinks.entry(index).and_modify(|e| e.peak = peak), 662 | StreamType::SinkInput => self.sink_inputs.entry(index).and_modify(|e| e.peak = peak), 663 | StreamType::Source => self.sources.entry(index).and_modify(|e| e.peak = peak), 664 | StreamType::SourceOutput => self.source_outputs.entry(index).and_modify(|e| e.peak = peak) 665 | }; 666 | } 667 | 668 | 669 | /** 670 | * Creates a monitor stream for the stream specified, and returns it. 671 | * Panics if there's an error. 672 | * TODO: Don't panic. 673 | * 674 | * * `t` - The type of stream to monitor. 675 | * * `source` - The source string of the stream, if one is needed. 676 | * * `stream_index` - The index of the stream to monitor. 677 | */ 678 | 679 | fn create_monitor_stream(&mut self, t: StreamType, source: Option<&str>, stream_index: u32) -> Shared { 680 | fn read_callback(stream: &mut Stream, t: StreamType, index: u32, tx: &Sender) { 681 | let mut raw_peak = 0.0; 682 | while stream.readable_size().is_some() { 683 | match stream.peek().unwrap() { 684 | PeekResult::Hole(_) => stream.discard().unwrap(), 685 | PeekResult::Data(b) => { 686 | #[allow(clippy::transmute_ptr_to_ref)] 687 | let buf = slice_as_array!(b, [u8; 4]).expect("Bad length."); 688 | raw_peak = f32::from_le_bytes(*buf).max(raw_peak); 689 | stream.discard().unwrap(); 690 | }, 691 | _ => break 692 | } 693 | } 694 | let peak = (raw_peak.sqrt() * 65535.0 * 1.5).round() as u32; 695 | tx.send(TxMessage::Peak(t, index, peak)).unwrap(); 696 | } 697 | 698 | let attr = BufferAttr { 699 | fragsize: 4, 700 | maxlength: u32::MAX, 701 | ..Default::default() 702 | }; 703 | 704 | let spec = Spec { channels: 1, format: Format::F32le, rate: 30 }; 705 | assert!(spec.is_valid()); 706 | 707 | let stream = Shared::new(Stream::new(&mut self.context.borrow_mut(), "Peak Detect", &spec, None).unwrap()); 708 | { 709 | let mut stream_mut = stream.borrow_mut(); 710 | if t == StreamType::SinkInput { 711 | stream_mut.set_monitor_stream(stream_index).unwrap(); 712 | } 713 | 714 | let mut mainloop = self.mainloop.borrow_mut(); 715 | mainloop.lock(); 716 | stream_mut.connect_record(source, Some(&attr), 717 | StreamFlagSet::DONT_MOVE | StreamFlagSet::ADJUST_LATENCY | StreamFlagSet::PEAK_DETECT).unwrap(); 718 | mainloop.unlock(); 719 | 720 | let stream_clone = stream.clone(); 721 | let txc = self.channel.tx.clone(); 722 | stream_mut.set_read_callback(Some(Box::new(move |_| read_callback(&mut stream_clone.borrow_mut(), t, stream_index, &txc)))); 723 | } 724 | 725 | stream 726 | } 727 | 728 | 729 | /** 730 | * Updates a card in the store, or creates a new one. 731 | * This method is called by the update method, the data is provided by the pulse server. 732 | * 733 | * * `data` - The card's data. 734 | */ 735 | 736 | fn update_card(&mut self, data: &CardData) { 737 | let index = data.index; 738 | self.cards.insert(index, data.clone()); 739 | } 740 | 741 | 742 | /** 743 | * Removes a card from the store. 744 | * This method is called by the update method, the data is provided by the pulse server. 745 | * 746 | * * `index` - The index of the stream to remove. 747 | */ 748 | 749 | fn remove_card(&mut self, index: u32) { 750 | self.cards.remove(&index); 751 | } 752 | } 753 | -------------------------------------------------------------------------------- /src/shared.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * A simple abstraction over the Rc> pattern. 3 | * Shamelessly copied from https://gist.github.com/stevedonovan/7e3a6d8c8921e3eff16c4b11ab82b8d7. 4 | */ 5 | 6 | use std::rc::Rc; 7 | use std::cell::{RefCell, Ref, RefMut}; 8 | use std::ops::Deref; 9 | use std::fmt; 10 | 11 | 12 | /** 13 | * Represents a shared pointer to an object 14 | * on the heap, with interior mutability. 15 | */ 16 | 17 | #[derive(Clone)] 18 | pub struct Shared { 19 | v: Rc> 20 | } 21 | 22 | impl Shared { 23 | 24 | /** 25 | * Creates a new Shared with the contents provided. 26 | */ 27 | 28 | pub fn new(t: T) -> Shared { 29 | Shared { v: Rc::new(RefCell::new(t)) } 30 | } 31 | } 32 | 33 | impl Shared { 34 | 35 | /** 36 | * Borrows an immutable reference to the stored object. 37 | */ 38 | 39 | pub fn borrow(&self) -> Ref { 40 | self.v.borrow() 41 | } 42 | 43 | 44 | /** 45 | * Borrows a mutable reference to the stored object. 46 | */ 47 | 48 | pub fn borrow_mut(&self) -> RefMut { 49 | self.v.borrow_mut() 50 | } 51 | 52 | 53 | /** 54 | * Borrows a mutable pointer to the stored object. 55 | */ 56 | 57 | pub fn as_ptr(&self) -> *mut T { 58 | self.v.as_ptr() 59 | } 60 | 61 | 62 | /** 63 | * Replaces the stored object with a new one. 64 | */ 65 | 66 | pub fn replace(&self, t: T) -> T { 67 | self.v.replace(t) 68 | } 69 | 70 | 71 | /** 72 | * Creates a new pointer to the stored memory. 73 | * This operation is inexpensive, and does not clone the underlying object. 74 | */ 75 | 76 | pub fn clone(&self) -> Shared { 77 | Shared { v: Rc::clone(&self.v) } 78 | } 79 | } 80 | 81 | 82 | impl fmt::Display for Shared { 83 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 84 | write!(f, "{}", self.deref()) 85 | } 86 | } 87 | 88 | 89 | impl fmt::Debug for Shared { 90 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 91 | write!(f, "{:?}", self.deref()) 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/window/about.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Contains the About window. 3 | */ 4 | 5 | use gtk::prelude::*; 6 | 7 | 8 | /** 9 | * Creates and runs the About popup window, 10 | * which contains information about the app, license, and Auri. 11 | */ 12 | 13 | pub fn about() { 14 | let about = gtk::AboutDialog::new(); 15 | about.set_logo_icon_name(Some("multimedia-volume-control")); 16 | about.set_program_name("Myxer"); 17 | about.set_version(Some("1.3.0")); 18 | about.set_comments(Some("A modern Volume Mixer for PulseAudio.")); 19 | about.set_website(Some("https://github.com/Aurailus/Myxer")); 20 | about.set_copyright(Some("© 2021 Auri Collings")); 21 | about.set_license_type(gtk::License::Gpl30); 22 | about.add_credit_section("Created by", &[ "Auri Collings" ]); 23 | about.add_credit_section("With the help of", &[ "zWolfrost" ]); 24 | about.add_credit_section("libpulse-binding by", &[ "Lyndon Brown" ]); 25 | 26 | about.connect_response(|about, _| about.close()); 27 | about.run(); 28 | } 29 | -------------------------------------------------------------------------------- /src/window/mod.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Declares and re-exports modules pertaining to app windows. 3 | */ 4 | 5 | mod style; 6 | 7 | mod myxer; 8 | pub use myxer::*; 9 | 10 | mod about; 11 | pub use about::*; 12 | 13 | mod profiles; 14 | pub use profiles::*; 15 | -------------------------------------------------------------------------------- /src/window/myxer.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Contains he main application window, and associated data structs. 3 | */ 4 | 5 | use std::collections::HashMap; 6 | 7 | use gtk::prelude::*; 8 | use gio::prelude::*; 9 | 10 | use super::style; 11 | use crate::pulse::Pulse; 12 | use crate::shared::Shared; 13 | use super::{ about, Profiles }; 14 | use crate::meter::{ Meter, SinkMeter, SourceMeter, StreamMeter }; 15 | 16 | 17 | /** 18 | * Stores meter widgets and options. 19 | */ 20 | 21 | pub struct Meters { 22 | pub sink: SinkMeter, 23 | pub sink_box: gtk::Box, 24 | pub sink_inputs: HashMap, 25 | pub sink_inputs_box: gtk::Box, 26 | 27 | pub source: SourceMeter, 28 | pub source_box: gtk::Box, 29 | pub source_outputs: HashMap, 30 | pub source_outputs_box: gtk::Box, 31 | 32 | pub show_visualizers: bool, 33 | pub separate_channels: bool, 34 | pub remember_position: bool, 35 | 36 | pub window_position: (i32, i32), 37 | 38 | pub _config_path: std::path::PathBuf 39 | } 40 | 41 | impl Meters { 42 | 43 | /** 44 | * Creates the Struct, and some base widgets, 45 | * including the Sink and Source meters. 46 | * 47 | * * `pulse` - The Pulse instance used by the app. 48 | */ 49 | 50 | pub fn new(pulse: &Shared) -> Self { 51 | let sink = SinkMeter::new(pulse.clone()); 52 | 53 | let sink_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 54 | sink_box.get_style_context().add_class("pad_side"); 55 | sink_box.add(&sink.widget); 56 | 57 | let source = SourceMeter::new(pulse.clone()); 58 | 59 | let source_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 60 | source_box.get_style_context().add_class("pad_side"); 61 | source_box.add(&source.widget); 62 | 63 | let sink_inputs_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 64 | sink_inputs_box.get_style_context().add_class("pad_side"); 65 | 66 | let source_outputs_box = gtk::Box::new(gtk::Orientation::Horizontal, 0); 67 | source_outputs_box.get_style_context().add_class("pad_side"); 68 | 69 | // get config path 70 | let home_dir = std::env::var_os("HOME").ok_or("no home directory").unwrap(); 71 | let mut config_path = std::path::PathBuf::new(); 72 | config_path.push(&home_dir); 73 | config_path.push(".config"); 74 | config_path.push("myxer"); 75 | config_path.push("myxer.conf"); 76 | 77 | // create the Meters struct 78 | let mut meters = Meters { 79 | sink, source, 80 | sink_box, source_box, 81 | sink_inputs_box, source_outputs_box, 82 | sink_inputs: HashMap::new(), 83 | source_outputs: HashMap::new(), 84 | show_visualizers: true, 85 | separate_channels: false, 86 | remember_position: false, 87 | 88 | window_position: (0, 0), 89 | 90 | _config_path: config_path 91 | }; 92 | 93 | // load config 94 | let _ = meters.load_config(); 95 | 96 | meters 97 | } 98 | 99 | 100 | /* 101 | * Saves the current settings to the configuration file. 102 | */ 103 | 104 | pub fn save_config(&self) -> Result> { 105 | let config_path = self._config_path.clone(); 106 | 107 | let config_content = format!( 108 | "show_visualizers={}\nseparate_channels={}\nremember_position={}\nwindow_position_x={}\nwindow_position_y={}\n", 109 | self.show_visualizers, self.separate_channels, self.remember_position, self.window_position.0, self.window_position.1 110 | ); 111 | 112 | let dir_name = std::path::Path::new(&config_path).parent().ok_or("incorrect directory")?; 113 | std::fs::create_dir_all(dir_name)?; 114 | std::fs::write(&config_path, config_content)?; 115 | 116 | Ok(config_path) 117 | } 118 | 119 | 120 | /** 121 | * Loads the settings from the configuration file. 122 | */ 123 | 124 | pub fn load_config(&mut self) -> Result<(std::ffi::OsString, String), Box> { 125 | let config_path = self._config_path.clone(); 126 | 127 | let config_content = std::fs::read_to_string(&config_path)?; 128 | 129 | for line in config_content.lines() { 130 | let mut parts = line.split('='); 131 | let key = parts.next().ok_or("no key")?; 132 | let value = parts.next().ok_or("no value")?; 133 | 134 | match key { 135 | "show_visualizers" => self.show_visualizers = value.parse().unwrap_or(self.show_visualizers), 136 | "separate_channels" => self.separate_channels = value.parse().unwrap_or(self.separate_channels), 137 | "remember_position" => self.remember_position = value.parse().unwrap_or(self.remember_position), 138 | "window_position_x" => self.window_position.0 = value.parse().unwrap_or(self.window_position.0), 139 | "window_position_y" => self.window_position.1 = value.parse().unwrap_or(self.window_position.1), 140 | _ => {} 141 | } 142 | } 143 | 144 | Ok((config_path.file_name().unwrap().to_os_string(), config_content)) 145 | } 146 | 147 | 148 | /** 149 | * Toggles the show visualizers setting, and returns its current state. 150 | */ 151 | 152 | fn toggle_visualizers(&mut self) -> bool { 153 | self.show_visualizers = !self.show_visualizers; 154 | let _ = self.save_config(); 155 | self.show_visualizers 156 | } 157 | 158 | 159 | /** 160 | * Toggles the separate channels setting, and returns its current state. 161 | */ 162 | 163 | fn toggle_separate_channels(&mut self) -> bool { 164 | self.separate_channels = !self.separate_channels; 165 | let _ = self.save_config(); 166 | self.separate_channels 167 | } 168 | 169 | 170 | /** 171 | * Toggles the remember position setting, and returns its current state. 172 | */ 173 | 174 | fn toggle_remember_position(&mut self) -> bool { 175 | self.remember_position = !self.remember_position; 176 | let _ = self.save_config(); 177 | self.remember_position 178 | } 179 | } 180 | 181 | 182 | /** 183 | * The main Myxer application window, 184 | * Displays meters for each sink, source, sink input, and source output. 185 | */ 186 | 187 | pub struct Myxer { 188 | window: gtk::ApplicationWindow, 189 | 190 | pulse: Shared, 191 | meters: Shared, 192 | 193 | profiles: Shared> 194 | } 195 | 196 | impl Myxer { 197 | 198 | /** 199 | * Initializes the main window. 200 | * 201 | * * `app` - The GTK application. 202 | * * `pulse` - The Pulse store instance. 203 | */ 204 | 205 | pub fn new(app: >k::Application, pulse: &Shared) -> Self { 206 | let window = gtk::ApplicationWindow::new(app); 207 | let header = gtk::HeaderBar::new(); 208 | let stack = gtk::Stack::new(); 209 | let meters = Shared::new(Meters::new(pulse)); 210 | 211 | { 212 | window.set_title("Volume Mixer"); 213 | window.set_icon_name(Some("multimedia-volume-control")); 214 | 215 | let geom = gdk::Geometry { 216 | min_width: 580, min_height: 400, 217 | max_width: 10000, max_height: 400, 218 | base_width: -1, base_height: -1, 219 | width_inc: -1, height_inc: -1, 220 | min_aspect: 0.0, max_aspect: 0.0, 221 | win_gravity: gdk::Gravity::Center 222 | }; 223 | 224 | window.set_type_hint(gdk::WindowTypeHint::Dialog); 225 | window.set_geometry_hints::(None, Some(&geom), gdk::WindowHints::MIN_SIZE | gdk::WindowHints::MAX_SIZE); 226 | window.get_style_context().add_class("Myxer"); 227 | style::style(&window); 228 | 229 | let stack_switcher = gtk::StackSwitcher::new(); 230 | stack_switcher.set_stack(Some(&stack)); 231 | 232 | header.set_show_close_button(true); 233 | header.set_custom_title(Some(&stack_switcher)); 234 | 235 | let title_vert = gtk::Box::new(gtk::Orientation::Vertical, 0); 236 | header.pack_start(&title_vert); 237 | 238 | let title_hor = gtk::Box::new(gtk::Orientation::Horizontal, 0); 239 | title_vert.pack_start(&title_hor, true, true, 0); 240 | 241 | let icon = gtk::Image::from_icon_name(Some("multimedia-volume-control"), gtk::IconSize::Button); 242 | title_hor.pack_start(&icon, true, true, 3); 243 | let title = gtk::Label::new(Some("Volume Mixer")); 244 | title.get_style_context().add_class("title"); 245 | title_hor.pack_start(&title, true, true, 0); 246 | 247 | window.set_titlebar(Some(&header)); 248 | 249 | if meters.borrow().remember_position { 250 | window.move_(meters.borrow().window_position.0, meters.borrow().window_position.1); 251 | } 252 | } 253 | 254 | { 255 | let prefs_button = gtk::Button::from_icon_name(Some("open-menu-symbolic"), gtk::IconSize::SmallToolbar); 256 | prefs_button.get_style_context().add_class("flat"); 257 | prefs_button.set_widget_name("preferences"); 258 | prefs_button.set_can_focus(false); 259 | header.pack_end(&prefs_button); 260 | 261 | let prefs = gtk::PopoverMenu::new(); 262 | prefs.set_pointing_to(>k::Rectangle { x: 12, y: 32, width: 2, height: 2 }); 263 | prefs.set_relative_to(Some(&prefs_button)); 264 | prefs.set_border_width(6); 265 | 266 | let prefs_box = gtk::Box::new(gtk::Orientation::Vertical, 0); 267 | prefs.add(&prefs_box); 268 | 269 | let show_visualizers = gtk::ModelButton::new(); 270 | show_visualizers.set_property_text(Some("Visualize Peaks")); 271 | show_visualizers.set_action_name(Some("app.show_visualizers")); 272 | prefs_box.add(&show_visualizers); 273 | 274 | let split_channels = gtk::ModelButton::new(); 275 | split_channels.set_property_text(Some("Split Channels")); 276 | split_channels.set_action_name(Some("app.split_channels")); 277 | prefs_box.add(&split_channels); 278 | 279 | let remember_position = gtk::ModelButton::new(); 280 | remember_position.set_property_text(Some("Remember Position")); 281 | remember_position.set_action_name(Some("app.remember_position")); 282 | prefs_box.add(&remember_position); 283 | 284 | let card_profiles = gtk::ModelButton::new(); 285 | card_profiles.set_property_text(Some("Card Profiles...")); 286 | card_profiles.set_action_name(Some("app.card_profiles")); 287 | prefs_box.add(&card_profiles); 288 | 289 | prefs_box.pack_start(>k::Separator::new(gtk::Orientation::Horizontal), false, false, 4); 290 | 291 | let about = gtk::ModelButton::new(); 292 | about.set_property_text(Some("About Myxer")); 293 | about.set_action_name(Some("app.about")); 294 | prefs_box.add(&about); 295 | 296 | prefs_box.show_all(); 297 | prefs_button.connect_clicked(move |_| prefs.popup()); 298 | } 299 | 300 | pulse.borrow_mut().connect(); 301 | 302 | { 303 | let output = gtk::Box::new(gtk::Orientation::Horizontal, 0); 304 | output.pack_start(&meters.borrow_mut().sink_box, false, false, 0); 305 | 306 | output.pack_start(>k::Separator::new(gtk::Orientation::Vertical), false, true, 0); 307 | 308 | let output_scroller = gtk::ScrolledWindow::new::(None, None); 309 | output_scroller.set_policy(gtk::PolicyType::Automatic, gtk::PolicyType::Never); 310 | output_scroller.get_style_context().add_class("bordered"); 311 | output.pack_start(&output_scroller, true, true, 0); 312 | output_scroller.add(&meters.borrow().sink_inputs_box); 313 | 314 | let input = gtk::Box::new(gtk::Orientation::Horizontal, 0); 315 | input.pack_start(&meters.borrow_mut().source_box, false, false, 0); 316 | 317 | input.pack_start(>k::Separator::new(gtk::Orientation::Vertical), false, true, 0); 318 | 319 | let input_scroller = gtk::ScrolledWindow::new::(None, None); 320 | input_scroller.set_policy(gtk::PolicyType::Automatic, gtk::PolicyType::Never); 321 | input_scroller.get_style_context().add_class("bordered"); 322 | input.pack_start(&input_scroller, true, true, 0); 323 | input_scroller.add(&meters.borrow().source_outputs_box); 324 | 325 | stack.add_titled(&output, "output", "Output"); 326 | stack.add_titled(&input, "input", "Input"); 327 | 328 | window.add(&stack); 329 | window.show_all(); 330 | } 331 | 332 | let profiles = Shared::new(None); 333 | 334 | { 335 | let window = window.clone(); 336 | 337 | let actions = gio::SimpleActionGroup::new(); 338 | window.insert_action_group("app", Some(&actions)); 339 | 340 | let about = gio::SimpleAction::new("about", None); 341 | about.connect_activate(|_, _| about::about()); 342 | actions.add_action(&about); 343 | 344 | let card_profiles = gio::SimpleAction::new("card_profiles", None); 345 | let pulse = pulse.clone(); 346 | let profiles = profiles.clone(); 347 | card_profiles.connect_activate(move |_, _| { 348 | profiles.replace(Some(Profiles::new(&window, &pulse))); 349 | }); 350 | actions.add_action(&card_profiles); 351 | 352 | let meters_clone = meters.clone(); 353 | let split_channels = gio::SimpleAction::new_stateful("split_channels", glib::VariantTy::new("bool").ok(), &(meters_clone.borrow().separate_channels).to_variant()); 354 | split_channels.connect_activate(move |s, _| s.set_state(&meters_clone.borrow_mut().toggle_separate_channels().to_variant())); 355 | actions.add_action(&split_channels); 356 | 357 | let meters_clone = meters.clone(); 358 | let remember_position = gio::SimpleAction::new_stateful("remember_position", glib::VariantTy::new("bool").ok(), &(meters_clone.borrow().remember_position).to_variant()); 359 | remember_position.connect_activate(move |s, _| s.set_state(&meters_clone.borrow_mut().toggle_remember_position().to_variant())); 360 | actions.add_action(&remember_position); 361 | 362 | let meters_clone = meters.clone(); 363 | let show_visualizers = gio::SimpleAction::new_stateful("show_visualizers", glib::VariantTy::new("bool").ok(), &(meters_clone.borrow().show_visualizers).to_variant()); 364 | show_visualizers.connect_activate(move |s, _| s.set_state(&meters_clone.borrow_mut().toggle_visualizers().to_variant())); 365 | actions.add_action(&show_visualizers); 366 | } 367 | 368 | Self { 369 | window, 370 | pulse: pulse.clone(), 371 | meters, 372 | profiles 373 | } 374 | } 375 | 376 | 377 | /** 378 | * Updates the app's widgets based on information stored in the Pulse instance. 379 | * Kills the Card Profiles window if it has been requested. 380 | */ 381 | 382 | pub fn update(&mut self) { 383 | let mut kill = false; 384 | if let Some(profiles) = self.profiles.borrow_mut().as_mut() { kill = !profiles.update(); } 385 | if kill { self.profiles.replace(None); } 386 | 387 | if self.pulse.borrow_mut().update() { 388 | let mut pulse = self.pulse.borrow_mut(); 389 | 390 | let mut meters = self.meters.borrow_mut(); 391 | 392 | let offset = meters.sink.widget.get_allocation().height + 393 | meters.sink.widget.get_margin_bottom() - meters.sink_inputs_box.get_allocation().height; 394 | if offset != meters.sink.widget.get_margin_bottom() { meters.sink.widget.set_margin_bottom(offset) } 395 | 396 | let offset = meters.source.widget.get_allocation().height + 397 | meters.source.widget.get_margin_bottom() - meters.source_outputs_box.get_allocation().height; 398 | if offset != meters.source.widget.get_margin_bottom() { meters.source.widget.set_margin_bottom(offset) } 399 | 400 | 401 | let show = meters.show_visualizers; 402 | let separate = meters.separate_channels; 403 | 404 | 405 | if let Some(sink) = pulse.sinks.get(&pulse.active_sink) { 406 | meters.sink.set_data(&sink.data); 407 | 408 | // refresh the peaks if they have changed OR if the split channels setting has changed 409 | let peak = if show { Some(sink.peak) } else { None }; 410 | let refresh_peaks = (meters.sink.peak != peak) || (meters.sink.split != separate && show); 411 | 412 | meters.sink.split_channels(separate); 413 | 414 | if refresh_peaks { 415 | meters.sink.set_peak(peak); 416 | } 417 | } 418 | 419 | const DECREASE: u32 = 2000; 420 | const REPETITIONS: u32 = 3; 421 | 422 | for (index, input) in &mut pulse.sink_inputs { 423 | let sink_inputs_box = meters.sink_inputs_box.clone(); 424 | 425 | let meter = meters.sink_inputs.entry(*index).or_insert_with(|| StreamMeter::new(self.pulse.clone())); 426 | if meter.widget.get_parent().is_none() { sink_inputs_box.pack_start(&meter.widget, false, false, 0); } 427 | 428 | // gradually decrease the peak value if it is not changing 429 | if input.peak != 0 && Some(input.peak) == meter.peak { 430 | if input.repetitions < REPETITIONS { input.repetitions += 1; } 431 | else { 432 | if input.peak < DECREASE { input.peak = 0; } 433 | else { input.peak -= DECREASE; } 434 | } 435 | } 436 | else { input.repetitions = 0; } 437 | 438 | // refresh the peaks if they have changed OR if the split channels setting has changed 439 | let peak = if show { Some(input.peak) } else { None }; 440 | let refresh_peaks = (meter.peak != peak) || (meter.split != separate && show); 441 | 442 | meter.set_data(&input.data); 443 | meter.split_channels(separate); 444 | 445 | if refresh_peaks { 446 | meter.set_peak(peak); 447 | } 448 | } 449 | 450 | let sink_inputs_box = meters.sink_inputs_box.clone(); 451 | meters.sink_inputs.retain(|index, meter| { 452 | let keep = pulse.sink_inputs.contains_key(index); 453 | if !keep { sink_inputs_box.remove(&meter.widget); } 454 | keep 455 | }); 456 | 457 | if let Some(source) = pulse.sources.get(&pulse.active_source) { 458 | meters.source.set_data(&source.data); 459 | meters.source.split_channels(separate); 460 | meters.source.set_peak(if show { Some(source.peak) } else { None }); 461 | } 462 | 463 | for (index, output) in &pulse.source_outputs { 464 | let source_outputs_box = meters.source_outputs_box.clone(); 465 | 466 | let meter = meters.source_outputs.entry(*index).or_insert_with(|| StreamMeter::new(self.pulse.clone())); 467 | if meter.widget.get_parent().is_none() { source_outputs_box.pack_start(&meter.widget, false, false, 0); } 468 | meter.set_data(&output.data); 469 | meter.split_channels(separate); 470 | meter.set_peak(if show { Some(output.peak) } else { None }); 471 | } 472 | 473 | let source_outputs_box = meters.source_outputs_box.clone(); 474 | meters.source_outputs.retain(|index, meter| { 475 | let keep = pulse.source_outputs.contains_key(index); 476 | if !keep { source_outputs_box.remove(&meter.widget); } 477 | keep 478 | }); 479 | 480 | meters.sink_inputs_box.show_all(); 481 | meters.source_outputs_box.show_all(); 482 | 483 | 484 | if meters.window_position != self.window.get_position() && self.window.get_focus().is_some() { 485 | meters.window_position = self.window.get_position(); 486 | let _ = meters.save_config(); 487 | } 488 | } 489 | } 490 | } 491 | -------------------------------------------------------------------------------- /src/window/profiles.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Contains the Card Profiles window and associated data structs. 3 | */ 4 | 5 | use std::collections::HashMap; 6 | 7 | use gtk::prelude::*; 8 | 9 | use crate::card::Card; 10 | use crate::pulse::Pulse; 11 | use crate::shared::Shared; 12 | 13 | 14 | /** 15 | * Stores the created Card widgets. 16 | */ 17 | 18 | struct Cards { 19 | cards: HashMap, 20 | cards_box: gtk::Box, 21 | } 22 | 23 | impl Cards { 24 | 25 | /** 26 | * Initializes the structure. 27 | */ 28 | 29 | pub fn new() -> Self { 30 | Cards { cards: HashMap::new(), cards_box: gtk::Box::new(gtk::Orientation::Vertical, 8) } 31 | } 32 | } 33 | 34 | 35 | /** 36 | * The Card Profiles popup window. 37 | * Allows listing and changing pulseaudio sound Card profiles. 38 | */ 39 | 40 | pub struct Profiles { 41 | cards: Shared, 42 | pulse: Shared, 43 | 44 | /** Indicates if the popup should remain open. */ 45 | live: Shared 46 | } 47 | 48 | impl Profiles { 49 | 50 | /** 51 | * Creates the Card Profiles window, and its contents. 52 | */ 53 | 54 | pub fn new(parent: >k::ApplicationWindow, pulse: &Shared) -> Self { 55 | let dialog = gtk::Dialog::with_buttons(Some("Card Profiles"), Some(parent), gtk::DialogFlags::all(), &[]); 56 | dialog.set_border_width(0); 57 | 58 | let live = Shared::new(true); 59 | dialog.connect_response(|s, _| s.emit_close()); 60 | let live_clone = live.clone(); 61 | dialog.connect_close(move |_| { live_clone.replace(false); }); 62 | 63 | let geom = gdk::Geometry { 64 | min_width: 450, min_height: 550, 65 | max_width: 450, max_height: 10000, 66 | base_width: -1, base_height: -1, 67 | width_inc: -1, height_inc: -1, 68 | min_aspect: 0.0, max_aspect: 0.0, 69 | win_gravity: gdk::Gravity::Center 70 | }; 71 | 72 | dialog.set_geometry_hints::(None, Some(&geom), gdk::WindowHints::MIN_SIZE | gdk::WindowHints::MAX_SIZE); 73 | let cards = Shared::new(Cards::new()); 74 | 75 | let scroller = gtk::ScrolledWindow::new::(None, None); 76 | scroller.set_policy(gtk::PolicyType::Never, gtk::PolicyType::Automatic); 77 | dialog.get_content_area().pack_start(&scroller, true, true, 0); 78 | dialog.get_content_area().set_border_width(0); 79 | scroller.add(&cards.borrow().cards_box); 80 | 81 | dialog.show_all(); 82 | 83 | Self { 84 | live, 85 | cards, 86 | pulse: pulse.clone() 87 | } 88 | } 89 | 90 | 91 | /** 92 | * Updates the card widgets to the latest information, 93 | * returns a boolean indicating if the window should continue to be open or not. 94 | */ 95 | 96 | pub fn update(&mut self) -> bool { 97 | let pulse = self.pulse.borrow_mut(); 98 | let mut cards = self.cards.borrow_mut(); 99 | for (index, data) in &pulse.cards { 100 | let cards_box = cards.cards_box.clone(); 101 | 102 | let card = cards.cards.entry(*index).or_insert_with(|| Card::new(Some(self.pulse.clone()))); 103 | if card.widget.get_parent().is_none() { 104 | cards_box.pack_start(&card.widget, false, false, 0); 105 | cards_box.pack_start(>k::Separator::new(gtk::Orientation::Horizontal), false, false, 0); 106 | } 107 | card.set_data(&data); 108 | } 109 | 110 | cards.cards_box.show_all(); 111 | *self.live.borrow() 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/window/style.rs: -------------------------------------------------------------------------------- 1 | /*! 2 | * Handles loading and generating custom styles for the Myxer application. 3 | */ 4 | 5 | #![allow(deprecated)] 6 | 7 | use gtk::prelude::*; 8 | 9 | 10 | /** 11 | * Applies application-specific styles to the specified window. 12 | * Generates a few GTK widgets to steal their theme colors using deprecated methods. 13 | * Unfortunately, it seems that there is no other way to pull theme colors dynamically, 14 | * which seems odd, perhaps I've overlooked something. 15 | * 16 | * * `window` - The main Myxer application window. 17 | */ 18 | 19 | pub fn style(window: >k::ApplicationWindow) { 20 | let provider = gtk::CssProvider::new(); 21 | 22 | let mut s = String::new(); 23 | 24 | let mut add_color = |identifier: &str, color: &gdk::RGBA| { 25 | s.push_str("@define-color "); 26 | s.push_str(identifier); 27 | s.push(' '); 28 | s.push_str(&colorsys::Rgb::new(color.red * 255.0, color.green * 255.0, color.blue * 255.0, None).to_css_string()); 29 | s.push_str(";\n"); 30 | }; 31 | 32 | let row = gtk::ListBoxRow::new(); 33 | let button = gtk::Button::new(); 34 | add_color("scale_color", &row.get_style_context().get_background_color(gtk::StateFlags::SELECTED)); 35 | add_color("background_color", &window.get_style_context().get_background_color(gtk::StateFlags::NORMAL)); 36 | add_color("foreground_color", &button.get_style_context().get_color(gtk::StateFlags::NORMAL)); 37 | 38 | s.push_str(STYLE); 39 | 40 | provider.load_from_data(s.as_bytes()).expect("Failed to load CSS."); 41 | gtk::StyleContext::add_provider_for_screen(&gdk::Screen::get_default().expect("Error initializing GTK CSS provider."), 42 | &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION); 43 | } 44 | 45 | /** 46 | * The custom stylesheet used by Myxer. 47 | */ 48 | 49 | const STYLE: &str = r#" 50 | .title { 51 | margin-left: -6px; 52 | } 53 | 54 | .pad_side { 55 | padding-left: 3px; 56 | padding-right: 3px; 57 | } 58 | 59 | headerbar box:last-child { 60 | padding-left: 0; 61 | } 62 | 63 | headerbar button#preferences.image-button { 64 | border-radius: 16px; 65 | padding: 0px; 66 | margin-top: 8px; 67 | margin-bottom: 8px; 68 | } 69 | 70 | headerbar #preferences image { 71 | opacity: .7; 72 | -gtk-icon-transform: scale(0.75); 73 | } 74 | 75 | headerbar box:last-child separator { 76 | border-width: 0; 77 | border-image-source: none; 78 | } 79 | 80 | #meter scale.visualizer trough highlight { 81 | background: none; 82 | background-color: alpha(@scale_color, 0.4); 83 | } 84 | 85 | #meter scale.visualizer trough fill { 86 | background: none; 87 | background-color: alpha(@scale_color, 1); 88 | } 89 | 90 | #meter { 91 | padding-top: 3px; 92 | padding-bottom: 3px; 93 | } 94 | 95 | #meter #top { 96 | padding: 0; 97 | margin: 2px; 98 | } 99 | 100 | #meter #app_label { 101 | padding: 0 3px; 102 | } 103 | 104 | #meter #app_select { 105 | padding: 0; 106 | margin: -1px 2px; 107 | } 108 | 109 | #meter #app_select #app_label { 110 | padding: 0; 111 | } 112 | 113 | #meter #mute_toggle image { 114 | margin-top: 1px; 115 | } 116 | 117 | #meter #mute_toggle label { 118 | margin-left: 3px; 119 | } 120 | 121 | #meter #mute_toggle.muted { 122 | border-color: darker(@background_color); 123 | } 124 | 125 | #meter #mute_toggle.muted { 126 | color: alpha(@foreground_color, 0.4); 127 | } 128 | 129 | undershoot { 130 | background: none; 131 | } 132 | 133 | #card { 134 | margin-top: -3px; 135 | margin-bottom: -6px; 136 | } 137 | 138 | #card:first-child { 139 | margin-top: 6px; 140 | } 141 | "#; 142 | --------------------------------------------------------------------------------