From 9d7f0ff6dcfa0fe9a4668f13816ac56f14306a5e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:43:55 +0000 Subject: [PATCH 01/18] build(deps): bump clap from 4.5.7 to 4.5.8 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.7 to 4.5.8. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.7...v4.5.8) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 12 ++++++------ Cargo.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0db173a..8bc9135 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5db83dced34638ad474f39f250d7fea9598bdd239eaced1bdf45d597da0f433f" +checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" dependencies = [ "clap_builder", "clap_derive", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.7" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7e204572485eb3fbf28f871612191521df159bc3e15a9f5064c66dba3a8c05f" +checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" dependencies = [ "anstream", "anstyle", @@ -478,9 +478,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.5" +version = "4.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c780290ccf4fb26629baa7a1081e68ced113f1d3ec302fa5948f1c381ebf06c6" +checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" dependencies = [ "heck 0.5.0", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index 6be1241..c654fed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,7 @@ ctrlc = "3.4.2" cfg-if = "1.0.0" # cli -clap = { version = "4.5.7", optional = true, features = ["derive"] } +clap = { version = "4.5.8", optional = true, features = ["derive"] } # ipc serde_json = { version = "1.0.117", optional = true } From da7c190c428883e888efdfdfc712a85eacdb1109 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Jul 2024 14:44:08 +0000 Subject: [PATCH 02/18] build(deps): bump serde_json from 1.0.117 to 1.0.119 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.117 to 1.0.119. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.117...v1.0.119) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0db173a..6198360 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2798,9 +2798,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.117" +version = "1.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" +checksum = "e8eddb61f0697cc3989c5d64b452f5488e2b8a60fd7d5076a3045076ffef8cb0" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 6be1241..e78f797 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ cfg-if = "1.0.0" clap = { version = "4.5.7", optional = true, features = ["derive"] } # ipc -serde_json = { version = "1.0.117", optional = true } +serde_json = { version = "1.0.119", optional = true } # http reqwest = { version = "0.12.5", default-features = false, features = ["default-tls", "http2"], optional = true } From 92ae1a8d73d68ebf51e008cd6322a9269cd10325 Mon Sep 17 00:00:00 2001 From: Alpha-Ursae-Minoris <100356220+Alpha-Ursae-Minoris@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:38:35 +0000 Subject: [PATCH 03/18] feat(nix): home-manager option to read style.css file --- flake.nix | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/flake.nix b/flake.nix index ac2a5ea..0e7a8ad 100644 --- a/flake.nix +++ b/flake.nix @@ -162,7 +162,7 @@ }; style = lib.mkOption { - type = lib.types.lines; + type = lib.types.either (lib.types.lines) (lib.types.path); default = ""; description = "The stylesheet to apply to ironbar."; }; @@ -189,8 +189,12 @@ source = jsonFormat.generate "ironbar-config" cfg.config; }; - "ironbar/style.css" = - lib.mkIf (cfg.style != "") { text = cfg.style; }; + "ironbar/style.css" = lib.mkIf (cfg.style != "") ( + if builtins.isPath cfg.style || lib.isStorePath cfg.style then + { source = cfg.style; } + else + { text = cfg.style; } + ); }; systemd.user.services.ironbar = lib.mkIf cfg.systemd { From 3a9753b14aef4493414ed9e97832439ed93df91f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 8 Jul 2024 14:49:47 +0000 Subject: [PATCH 04/18] build(deps): bump serde_json from 1.0.119 to 1.0.120 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.119 to 1.0.120. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.119...v1.0.120) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6fe9551..d0b353b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2798,9 +2798,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.119" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8eddb61f0697cc3989c5d64b452f5488e2b8a60fd7d5076a3045076ffef8cb0" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index 58dfbde..b399f9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ cfg-if = "1.0.0" clap = { version = "4.5.8", optional = true, features = ["derive"] } # ipc -serde_json = { version = "1.0.119", optional = true } +serde_json = { version = "1.0.120", optional = true } # http reqwest = { version = "0.12.5", default-features = false, features = ["default-tls", "http2"], optional = true } From 81df87b6a9c874e5538bd5abc6cc0925e1e72c12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 13 Jul 2024 18:07:51 +0000 Subject: [PATCH 05/18] build(deps): bump serde from 1.0.203 to 1.0.204 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.203 to 1.0.204. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.203...v1.0.204) --- updated-dependencies: - dependency-name: serde dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d0b353b..f12bd4e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2767,18 +2767,18 @@ checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed" [[package]] name = "serde" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.203" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index b399f9a..c274422 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -98,7 +98,7 @@ tracing-error = { version = "0.2.0" , default-features = false } tracing-appender = "0.2.3" strip-ansi-escapes = "0.2.0" color-eyre = "0.6.3" -serde = { version = "1.0.203", features = ["derive"] } +serde = { version = "1.0.204", features = ["derive"] } indexmap = "2.2.6" dirs = "5.0.1" walkdir = "2.5.0" From b4484d6e4ec5f56768576680961e7f3b94220a9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:39:19 +0000 Subject: [PATCH 06/18] build(deps): bump clap from 4.5.8 to 4.5.9 Bumps [clap](https://github.com/clap-rs/clap) from 4.5.8 to 4.5.9. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/clap_complete-v4.5.8...v4.5.9) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- Cargo.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f12bd4e..7bf409a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -456,9 +456,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" +checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" dependencies = [ "clap_builder", "clap_derive", @@ -466,9 +466,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.8" +version = "4.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" +checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" dependencies = [ "anstream", "anstyle", diff --git a/Cargo.toml b/Cargo.toml index c274422..1bf2e87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -113,7 +113,7 @@ ctrlc = "3.4.2" cfg-if = "1.0.0" # cli -clap = { version = "4.5.8", optional = true, features = ["derive"] } +clap = { version = "4.5.9", optional = true, features = ["derive"] } # ipc serde_json = { version = "1.0.120", optional = true } From c82ff6815caaeb469084cf6ef99a3c13ae78c112 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 Jul 2024 14:39:48 +0000 Subject: [PATCH 07/18] build(deps): bump gtk-layer-shell from 0.8.0 to 0.8.1 Bumps [gtk-layer-shell](https://github.com/pentamassiv/gtk-layer-shell-gir) from 0.8.0 to 0.8.1. - [Commits](https://github.com/pentamassiv/gtk-layer-shell-gir/commits) --- updated-dependencies: - dependency-name: gtk-layer-shell dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f12bd4e..e5a3dd2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1234,9 +1234,9 @@ dependencies = [ [[package]] name = "gtk-layer-shell" -version = "0.8.0" +version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19fd93acba7b8ea8918fc564843a22cd1eeffe234b85a8c7d5732c611a425bb0" +checksum = "adb41643070b55cdda5a4a10a338520cff4345395e342b754c02f341e4107383" dependencies = [ "bitflags 2.4.0", "gdk", diff --git a/Cargo.toml b/Cargo.toml index c274422..3bd3952 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -81,7 +81,7 @@ schema = ["dep:schemars"] [dependencies] # core gtk = "0.18.1" -gtk-layer-shell = "0.8.0" +gtk-layer-shell = "0.8.1" glib = "0.18.5" tokio = { version = "1.38.0", features = [ "macros", From 172e0ad4114f349a6d4dec42947e941c5fafa6cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:10:59 +0000 Subject: [PATCH 08/18] build(deps): bump tokio from 1.38.0 to 1.38.1 Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.38.0 to 1.38.1. - [Release notes](https://github.com/tokio-rs/tokio/releases) - [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.38.0...tokio-1.38.1) --- updated-dependencies: - dependency-name: tokio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ccc615..ac449a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3202,9 +3202,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.0" +version = "1.38.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" +checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" dependencies = [ "backtrace", "bytes", diff --git a/Cargo.toml b/Cargo.toml index 5ea9985..0722ca7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ schema = ["dep:schemars"] gtk = "0.18.1" gtk-layer-shell = "0.8.1" glib = "0.18.5" -tokio = { version = "1.38.0", features = [ +tokio = { version = "1.38.1", features = [ "macros", "rt-multi-thread", "time", From 5a3eaf90c4d42f021c6ac2dc4dc140e3c6db1fd2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 18:13:01 +0000 Subject: [PATCH 09/18] build(deps): bump openssl from 0.10.64 to 0.10.66 in the cargo group Bumps the cargo group with 1 update: [openssl](https://github.com/sfackler/rust-openssl). Updates `openssl` from 0.10.64 to 0.10.66 - [Release notes](https://github.com/sfackler/rust-openssl/releases) - [Commits](https://github.com/sfackler/rust-openssl/compare/openssl-v0.10.64...openssl-v0.10.66) --- updated-dependencies: - dependency-name: openssl dependency-type: indirect dependency-group: cargo ... Signed-off-by: dependabot[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3ccc615..d18abb9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2083,9 +2083,9 @@ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "openssl" -version = "0.10.64" +version = "0.10.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95a0481286a310808298130d22dd1fef0fa571e05a8f44ec801801e84b216b1f" +checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" dependencies = [ "bitflags 2.4.0", "cfg-if", @@ -2115,9 +2115,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.101" +version = "0.9.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dda2b0f344e78efc2facf7d195d098df0dd72151b26ab98da807afc26c198dff" +checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", From 0db255b98cc4627b093a079c103ee6d6cea90c5f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:50:51 +0000 Subject: [PATCH 10/18] build(deps): bump serde_json from 1.0.120 to 1.0.121 Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.120 to 1.0.121. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.120...v1.0.121) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Cargo.lock | 5 +++-- Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 928dd0b..7fa1c7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2798,11 +2798,12 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.120" +version = "1.0.121" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" +checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" dependencies = [ "itoa", + "memchr", "ryu", "serde", ] diff --git a/Cargo.toml b/Cargo.toml index 0722ca7..8886b58 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -116,7 +116,7 @@ cfg-if = "1.0.0" clap = { version = "4.5.9", optional = true, features = ["derive"] } # ipc -serde_json = { version = "1.0.120", optional = true } +serde_json = { version = "1.0.121", optional = true } # http reqwest = { version = "0.12.5", default-features = false, features = ["default-tls", "http2"], optional = true } From 03cb384e2b3a3303ccbf12d931e8717161f9eac9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Jul 2024 14:51:14 +0000 Subject: [PATCH 11/18] build(deps): bump lua-src from 546.0.2 to 547.0.0 Bumps [lua-src](https://github.com/khvzak/lua-src-rs) from 546.0.2 to 547.0.0. - [Commits](https://github.com/khvzak/lua-src-rs/compare/v546.0.2...v547.0.0) --- updated-dependencies: - dependency-name: lua-src dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 928dd0b..8efd981 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1780,9 +1780,9 @@ dependencies = [ [[package]] name = "lua-src" -version = "546.0.2" +version = "547.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da0daa7eee611a4c30c8f5ee31af55266e26e573971ba9336d2993e2da129b2" +checksum = "1edaf29e3517b49b8b746701e5648ccb5785cde1c119062cbabbc5d5cd115e42" dependencies = [ "cc", ] diff --git a/Cargo.toml b/Cargo.toml index 0722ca7..770f72e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ serde_json = { version = "1.0.120", optional = true } reqwest = { version = "0.12.5", default-features = false, features = ["default-tls", "http2"], optional = true } # cairo -lua-src = { version = "546.0.2", optional = true } +lua-src = { version = "547.0.0", optional = true } mlua = { version = "0.9.9", optional = true, features = ["luajit"] } cairo-rs = { version = "0.18.5", optional = true, features = ["png"] } From 461bee8847590e769df186a2f24ab2ce957568f7 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Fri, 28 Jun 2024 23:23:18 +0100 Subject: [PATCH 12/18] fix(bar): do not add start/center/end containers if empty --- src/bar.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/bar.rs b/src/bar.rs index 2e9e7d2..4914755 100644 --- a/src/bar.rs +++ b/src/bar.rs @@ -78,10 +78,6 @@ impl Bar { let center = create_container("center", orientation); let end = create_container("end", orientation); - content.add(&start); - content.set_center_widget(Some(¢er)); - content.pack_end(&end, false, false, 0); - window.add(&content); window.connect_destroy_event(|_, _| { @@ -273,16 +269,22 @@ impl Bar { let popup = Rc::new(popup); if let Some(modules) = config.start { + self.content.add(&self.start); + let info = info!(ModuleLocation::Left); add_modules(&self.start, modules, &info, &self.ironbar, &popup)?; } if let Some(modules) = config.center { + self.content.set_center_widget(Some(&self.center)); + let info = info!(ModuleLocation::Center); add_modules(&self.center, modules, &info, &self.ironbar, &popup)?; } if let Some(modules) = config.end { + self.content.pack_end(&self.end, false, true, 0); + let info = info!(ModuleLocation::Right); add_modules(&self.end, modules, &info, &self.ironbar, &popup)?; } From 6e43c7ae0cce4b8c6dfe2f74756574195b944abe Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sat, 3 Aug 2024 16:14:03 +0100 Subject: [PATCH 13/18] build: update deps --- Cargo.lock | 114 +++++++++++++++++++++++++++++++++++++---------------- Cargo.toml | 16 +++++--- 2 files changed, 89 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f1b3756..0ca4c1c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -435,6 +435,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + [[package]] name = "cfg_aliases" version = "0.2.1" @@ -456,9 +462,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" +checksum = "0fbb260a053428790f3de475e304ff84cdbc4face759ea7a3e64c1edd938a7fc" dependencies = [ "clap_builder", "clap_derive", @@ -466,9 +472,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.9" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" +checksum = "64b17d7ea74e9f833c7dbf2cbe4fb12ff26783eda4782a8975b72f895c9b4d99" dependencies = [ "anstream", "anstyle", @@ -478,9 +484,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.8" +version = "4.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2bac35c6dafb060fd4d275d9a4ffae97917c13a6327903a8be2153cd964f7085" +checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" dependencies = [ "heck 0.5.0", "proc-macro2", @@ -616,11 +622,11 @@ dependencies = [ [[package]] name = "ctrlc" -version = "3.4.2" +version = "3.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b467862cc8610ca6fc9a1532d7777cee0804e678ab45410897b9396495994a0b" +checksum = "672465ae37dc1bc6380a6547a8883d5dd397b0f1faaad4f265726cc7042a5345" dependencies = [ - "nix 0.27.1", + "nix 0.28.0", "windows-sys 0.52.0", ] @@ -676,6 +682,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derivative" version = "2.2.0" @@ -1348,9 +1363,9 @@ dependencies = [ [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" [[package]] name = "hex" @@ -1547,9 +1562,9 @@ checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" [[package]] name = "indexmap" -version = "2.2.6" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +checksum = "de3fc2e30ba82dd1b3911c8de1ffc143c74a914a14e99514d7637e3099df5ea0" dependencies = [ "equivalent", "hashbrown", @@ -1591,7 +1606,7 @@ version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ - "hermit-abi 0.3.1", + "hermit-abi 0.3.9", "libc", "windows-sys 0.48.0", ] @@ -1637,6 +1652,7 @@ dependencies = [ "swayipc-async", "sysinfo", "system-tray", + "time", "tokio", "tracing", "tracing-appender", @@ -1862,6 +1878,18 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "mio" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4569e456d394deccd22ce1c1913e6ea0e54519f577285001215d33557431afe4" +dependencies = [ + "hermit-abi 0.3.9", + "libc", + "wasi", + "windows-sys 0.52.0", +] + [[package]] name = "mlua" version = "0.9.9" @@ -1969,12 +1997,13 @@ dependencies = [ [[package]] name = "nix" -version = "0.27.1" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053" +checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4" dependencies = [ "bitflags 2.4.0", "cfg-if", + "cfg_aliases 0.1.1", "libc", ] @@ -1986,7 +2015,7 @@ checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" dependencies = [ "bitflags 2.4.0", "cfg-if", - "cfg_aliases", + "cfg_aliases 0.2.1", "libc", ] @@ -2012,7 +2041,7 @@ dependencies = [ "kqueue", "libc", "log", - "mio", + "mio 0.8.11", "walkdir", "windows-sys 0.48.0", ] @@ -2036,6 +2065,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-derive" version = "0.3.3" @@ -2308,6 +2343,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.17" @@ -2479,9 +2520,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.5" +version = "1.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" dependencies = [ "aho-corasick", "memchr", @@ -2798,9 +2839,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.121" +version = "1.0.122" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ab380d7d9f22ef3f21ad3e6c1ebe8e4fc7a2000ccba2e4d71fc96f15b2cb609" +checksum = "784b6203951c57ff748476b126ccb5e8e2959a5c19e5c617ab1956be3dbc68da" dependencies = [ "itoa", "memchr", @@ -3161,11 +3202,14 @@ dependencies = [ [[package]] name = "time" -version = "0.3.20" +version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890" +checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ + "deranged", "itoa", + "num-conv", + "powerfmt", "serde", "time-core", "time-macros", @@ -3173,16 +3217,17 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.0" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" -version = "0.2.8" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36" +checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ + "num-conv", "time-core", ] @@ -3203,28 +3248,27 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.38.1" +version = "1.39.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb2caba9f80616f438e09748d5acda951967e1ea58508ef53d9c6402485a46df" +checksum = "daa4fb1bc778bd6f04cbfc4bb2d06a7396a8f299dc33ea1900cedaa316f467b1" dependencies = [ "backtrace", "bytes", "libc", - "mio", - "num_cpus", + "mio 1.0.1", "pin-project-lite", "signal-hook-registry", "socket2 0.5.5", "tokio-macros", "tracing", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] name = "tokio-macros" -version = "2.3.0" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a" +checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote 1.0.35", diff --git a/Cargo.toml b/Cargo.toml index c35cb66..3c76797 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ schema = ["dep:schemars"] gtk = "0.18.1" gtk-layer-shell = "0.8.1" glib = "0.18.5" -tokio = { version = "1.38.1", features = [ +tokio = { version = "1.39.2", features = [ "macros", "rt-multi-thread", "time", @@ -99,7 +99,7 @@ tracing-appender = "0.2.3" strip-ansi-escapes = "0.2.0" color-eyre = "0.6.3" serde = { version = "1.0.204", features = ["derive"] } -indexmap = "2.2.6" +indexmap = "2.3.0" dirs = "5.0.1" walkdir = "2.5.0" notify = { version = "6.1.1", default-features = false } @@ -109,14 +109,14 @@ smithay-client-toolkit = { version = "0.18.1", default-features = false, feature "calloop", ] } universal-config = { version = "0.5.0", default-features = false } -ctrlc = "3.4.2" +ctrlc = "3.4.4" cfg-if = "1.0.0" # cli -clap = { version = "4.5.9", optional = true, features = ["derive"] } +clap = { version = "4.5.13", optional = true, features = ["derive"] } # ipc -serde_json = { version = "1.0.121", optional = true } +serde_json = { version = "1.0.122", optional = true } # http reqwest = { version = "0.12.5", default-features = false, features = ["default-tls", "http2"], optional = true } @@ -155,10 +155,14 @@ futures-util = { version = "0.3.30", optional = true } # shared futures-lite = { version = "2.3.0", optional = true } # workspaces, upower -regex = { version = "1.10.5", default-features = false, features = [ +regex = { version = "1.10.6", default-features = false, features = [ "std", ], optional = true } # music, sys_info zbus = { version = "3.15.2", default-features = false, features = ["tokio"], optional = true } # notifications, upower # schema schemars = { version = "0.8.21", optional = true } + +# -- PATCH -- +# temp fix for tracing-appender/time +time = "0.3.36" \ No newline at end of file From fb6ae42f3bcc7ad35066e1182e617c739a8cfa8a Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 4 Aug 2024 11:47:02 +0100 Subject: [PATCH 14/18] fix: crash due to clipboard fd incorrectly closed --- src/clients/wayland/wlr_data_control/offer.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/clients/wayland/wlr_data_control/offer.rs b/src/clients/wayland/wlr_data_control/offer.rs index 73f06f6..f140db1 100644 --- a/src/clients/wayland/wlr_data_control/offer.rs +++ b/src/clients/wayland/wlr_data_control/offer.rs @@ -1,13 +1,13 @@ use super::manager::DataControlDeviceManagerState; use crate::lock; use nix::fcntl::OFlag; -use nix::unistd::{close, pipe2}; +use nix::unistd::pipe2; use smithay_client_toolkit::data_device_manager::data_offer::DataOfferError; use smithay_client_toolkit::data_device_manager::ReadPipe; use std::ops::DerefMut; -use std::os::fd::{AsFd, AsRawFd}; +use std::os::fd::AsFd; use std::sync::{Arc, Mutex}; -use tracing::{trace, warn}; +use tracing::trace; use wayland_client::{Connection, Dispatch, Proxy, QueueHandle}; use wayland_protocols_wlr::data_control::v1::client::zwlr_data_control_offer_v1::{ Event, ZwlrDataControlOfferV1, @@ -178,9 +178,5 @@ pub unsafe fn receive( offer.receive(mime_type, writefd.as_fd()); - if let Err(err) = close(writefd.as_raw_fd()) { - warn!("Failed to close write pipe: {}", err); - } - Ok(ReadPipe::from(readfd)) } From 6d0fe4c8ace9c8a4136fb65c9ff9cdb04e9b6408 Mon Sep 17 00:00:00 2001 From: Reinout Meliesie Date: Sat, 10 Feb 2024 17:12:07 +0100 Subject: [PATCH 15/18] feat: add networkmanager module --- Cargo.lock | 44 +++++++++ Cargo.toml | 10 +- docs/Compiling.md | 1 + docs/_Sidebar.md | 1 + docs/modules/Network-Manager.md | 77 +++++++++++++++ src/clients/mod.rs | 16 +++ src/clients/networkmanager.rs | 169 ++++++++++++++++++++++++++++++++ src/config/mod.rs | 6 ++ src/modules/mod.rs | 4 + src/modules/networkmanager.rs | 88 +++++++++++++++++ 10 files changed, 414 insertions(+), 2 deletions(-) create mode 100644 docs/modules/Network-Manager.md create mode 100644 src/clients/networkmanager.rs create mode 100644 src/modules/networkmanager.rs diff --git a/Cargo.lock b/Cargo.lock index 0ca4c1c..a35ec61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -755,6 +755,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "discard" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" + [[package]] name = "dlib" version = "0.5.2" @@ -1021,6 +1027,22 @@ dependencies = [ "syn 2.0.48", ] +[[package]] +name = "futures-signals" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b175f2f6600dd81d92d20cf10872b03ea9df6b2513ca7f672341260dacb1ab2" +dependencies = [ + "discard", + "futures-channel", + "futures-core", + "futures-util", + "gensym", + "log", + "pin-project", + "serde", +] + [[package]] name = "futures-sink" version = "0.3.30" @@ -1119,6 +1141,18 @@ dependencies = [ "version_check", ] +[[package]] +name = "gensym" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "913dce4c5f06c2ea40fc178c06f777ac89fc6b1383e90c254fafb1abe4ba3c82" +dependencies = [ + "proc-macro2", + "quote 1.0.35", + "syn 2.0.48", + "uuid", +] + [[package]] name = "getrandom" version = "0.2.9" @@ -1629,6 +1663,7 @@ dependencies = [ "ctrlc", "dirs", "futures-lite 2.3.0", + "futures-signals", "futures-util", "glib", "gtk", @@ -3610,6 +3645,15 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" +dependencies = [ + "getrandom", +] + [[package]] name = "valuable" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 3c76797..988dfc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ default = [ "ipc", "launcher", "music+all", + "network_manager", "notifications", "sys_info", "tray", @@ -61,6 +62,8 @@ music = ["regex"] "music+mpris" = ["music", "mpris"] "music+mpd" = ["music", "mpd-utils"] +network_manager = ["futures-lite", "futures-signals", "zbus"] + notifications = ["zbus"] sys_info = ["sysinfo", "regex"] @@ -136,6 +139,9 @@ chrono = { version = "0.4.38", optional = true, default-features = false, featur mpd-utils = { version = "0.2.1", optional = true } mpris = { version = "2.0.1", optional = true } +# network_manager +futures-signals = { version = "0.3.33", optional = true } + # sys_info sysinfo = { version = "0.29.11", optional = true } @@ -154,11 +160,11 @@ hyprland = { version = "0.4.0-alpha.2", features = ["silent"], optional = true } futures-util = { version = "0.3.30", optional = true } # shared -futures-lite = { version = "2.3.0", optional = true } # workspaces, upower +futures-lite = { version = "2.3.0", optional = true } # network_manager, upower, workspaces regex = { version = "1.10.6", default-features = false, features = [ "std", ], optional = true } # music, sys_info -zbus = { version = "3.15.2", default-features = false, features = ["tokio"], optional = true } # notifications, upower +zbus = { version = "3.15.2", default-features = false, features = ["tokio"], optional = true } # network_manager, notifications, upower # schema schemars = { version = "0.8.21", optional = true } diff --git a/docs/Compiling.md b/docs/Compiling.md index 6112885..7a9a3e8 100644 --- a/docs/Compiling.md +++ b/docs/Compiling.md @@ -93,6 +93,7 @@ cargo build --release --no-default-features \ | music+all | Enables the `music` module with support for all player types. | | music+mpris | Enables the `music` module with MPRIS support. | | music+mpd | Enables the `music` module with MPD support. | +| network_manager | Enables the `network_manager` module. | | notifications | Enables the `notiications` module. | | sys_info | Enables the `sys_info` module. | | tray | Enables the `tray` module. | diff --git a/docs/_Sidebar.md b/docs/_Sidebar.md index 471971c..ffad835 100644 --- a/docs/_Sidebar.md +++ b/docs/_Sidebar.md @@ -32,6 +32,7 @@ - [Label](label) - [Launcher](launcher) - [Music](music) +- [Network Manager](network-manager) - [Notifications](notifications) - [Script](script) - [Sys_Info](sys-info) diff --git a/docs/modules/Network-Manager.md b/docs/modules/Network-Manager.md new file mode 100644 index 0000000..6dfadae --- /dev/null +++ b/docs/modules/Network-Manager.md @@ -0,0 +1,77 @@ +Displays the current network connection state of NetworkManager. +Supports wired ethernet, wifi, cellular data and VPN connections among others. + +> [!NOTE] +> This module is currently a basic skeleton implementation and only offers the most basic functionality currently. +> It uses NetworkManager's so-called primary connection, +> and therefore inherits its limitation of only being able to display the "top-level" connection. +> For example, if we have a VPN connection over a wifi connection it will only display the former, +> until it is disconnected, at which point it will display the latter. +> A solution to this is currently in the works. + +## Configuration + +> Type: `network_manager` + +| Name | Type | Default | Description | +|-------------|-----------|---------|-------------------------| +| `icon_size` | `integer` | `24` | Size to render icon at. | + +
+ JSON + + ```json + { + "end": [ + { + "type": "network_manager", + "icon_size": 32 + } + ] + } + ``` +
+ +
+ TOML + + ```toml + [[end]] + type = "network_manager" + icon_size = 32 + ``` +
+ +
+ YAML + + ```yaml + end: + - type: "network_manager" + icon_size: 32 + ``` +
+ +
+ Corn + + ```corn + { + end = [ + { + type = "network_manager" + icon_size = 32 + } + ] + } + ``` +
+ +## Styling + +| Selector | Description | +|--------------------------|----------------------------------| +| `.network_manager` | NetworkManager widget container. | +| `.network_manager .icon` | NetworkManager widget icon. | + +For more information on styling, please see the [styling guide](styling-guide). diff --git a/src/clients/mod.rs b/src/clients/mod.rs index b44f0df..ebe2bda 100644 --- a/src/clients/mod.rs +++ b/src/clients/mod.rs @@ -12,6 +12,8 @@ pub mod compositor; pub mod lua; #[cfg(feature = "music")] pub mod music; +#[cfg(feature = "network_manager")] +pub mod networkmanager; #[cfg(feature = "notifications")] pub mod swaync; #[cfg(feature = "tray")] @@ -35,6 +37,8 @@ pub struct Clients { lua: Option>, #[cfg(feature = "music")] music: std::collections::HashMap>, + #[cfg(feature = "network_manager")] + network_manager: Option>, #[cfg(feature = "notifications")] notifications: Option>, #[cfg(feature = "tray")] @@ -96,6 +100,18 @@ impl Clients { .clone() } + #[cfg(feature = "network_manager")] + pub fn network_manager(&mut self) -> ClientResult { + match &self.network_manager { + Some(client) => Ok(client.clone()), + None => { + let client = networkmanager::create_client()?; + self.network_manager = Some(client.clone()); + Ok(client) + } + } + } + #[cfg(feature = "notifications")] pub fn notifications(&mut self) -> ClientResult { let client = match &self.notifications { diff --git a/src/clients/networkmanager.rs b/src/clients/networkmanager.rs new file mode 100644 index 0000000..79b1f45 --- /dev/null +++ b/src/clients/networkmanager.rs @@ -0,0 +1,169 @@ +use std::sync::Arc; + +use color_eyre::Result; +use futures_signals::signal::{Mutable, MutableSignalCloned}; +use tracing::error; +use zbus::blocking::fdo::PropertiesProxy; +use zbus::blocking::Connection; +use zbus::{ + dbus_proxy, + names::InterfaceName, + zvariant::{ObjectPath, Str}, +}; + +use crate::{register_fallible_client, spawn_blocking}; + +const DBUS_BUS: &str = "org.freedesktop.NetworkManager"; +const DBUS_PATH: &str = "/org/freedesktop/NetworkManager"; +const DBUS_INTERFACE: &str = "org.freedesktop.NetworkManager"; + +#[derive(Debug)] +pub struct Client { + client_state: Mutable, + interface_name: InterfaceName<'static>, + dbus_connection: Connection, + props_proxy: PropertiesProxy<'static>, +} + +#[derive(Clone, Debug)] +pub enum ClientState { + WiredConnected, + WifiConnected, + CellularConnected, + VpnConnected, + WifiDisconnected, + Offline, + Unknown, +} + +#[dbus_proxy( + default_service = "org.freedesktop.NetworkManager", + interface = "org.freedesktop.NetworkManager", + default_path = "/org/freedesktop/NetworkManager" +)] +trait NetworkManagerDbus { + #[dbus_proxy(property)] + fn active_connections(&self) -> Result>; + + #[dbus_proxy(property)] + fn devices(&self) -> Result>; + + #[dbus_proxy(property)] + fn networking_enabled(&self) -> Result; + + #[dbus_proxy(property)] + fn primary_connection(&self) -> Result; + + #[dbus_proxy(property)] + fn primary_connection_type(&self) -> Result; + + #[dbus_proxy(property)] + fn wireless_enabled(&self) -> Result; +} + +impl Client { + fn new() -> Result { + let client_state = Mutable::new(ClientState::Unknown); + let dbus_connection = Connection::system()?; + let interface_name = InterfaceName::from_static_str(DBUS_INTERFACE)?; + let props_proxy = PropertiesProxy::builder(&dbus_connection) + .destination(DBUS_BUS)? + .path(DBUS_PATH)? + .build()?; + + Ok(Self { + client_state, + interface_name, + dbus_connection, + props_proxy, + }) + } + + fn run(&self) -> Result<()> { + let proxy = NetworkManagerDbusProxyBlocking::new(&self.dbus_connection)?; + + let mut primary_connection = proxy.primary_connection()?; + let mut primary_connection_type = proxy.primary_connection_type()?; + let mut wireless_enabled = proxy.wireless_enabled()?; + + self.client_state.set(determine_state( + &primary_connection, + &primary_connection_type, + wireless_enabled, + )); + + for change in self.props_proxy.receive_properties_changed()? { + let args = change.args()?; + if args.interface_name != self.interface_name { + continue; + } + + let changed_props = args.changed_properties; + let mut relevant_prop_changed = false; + + if changed_props.contains_key("PrimaryConnection") { + primary_connection = proxy.primary_connection()?; + relevant_prop_changed = true; + } + if changed_props.contains_key("PrimaryConnectionType") { + primary_connection_type = proxy.primary_connection_type()?; + relevant_prop_changed = true; + } + if changed_props.contains_key("WirelessEnabled") { + wireless_enabled = proxy.wireless_enabled()?; + relevant_prop_changed = true; + } + + if relevant_prop_changed { + self.client_state.set(determine_state( + &primary_connection, + &primary_connection_type, + wireless_enabled, + )); + } + } + + Ok(()) + } + + pub fn subscribe(&self) -> MutableSignalCloned { + self.client_state.signal_cloned() + } +} + +pub fn create_client() -> Result> { + let client = Arc::new(Client::new()?); + { + let client = client.clone(); + spawn_blocking(move || { + if let Err(error) = client.run() { + error!("{}", error); + }; + }); + } + Ok(client) +} + +fn determine_state( + primary_connection: &str, + primary_connection_type: &str, + wireless_enabled: bool, +) -> ClientState { + if primary_connection == "/" { + if wireless_enabled { + ClientState::WifiDisconnected + } else { + ClientState::Offline + } + } else { + match primary_connection_type { + "802-3-ethernet" | "adsl" | "pppoe" => ClientState::WiredConnected, + "802-11-olpc-mesh" | "802-11-wireless" | "wifi-p2p" => ClientState::WifiConnected, + "cdma" | "gsm" | "wimax" => ClientState::CellularConnected, + "vpn" | "wireguard" => ClientState::VpnConnected, + _ => ClientState::Unknown, + } + } +} + +register_fallible_client!(Client, network_manager); diff --git a/src/config/mod.rs b/src/config/mod.rs index e277bac..6f7bfab 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -16,6 +16,8 @@ use crate::modules::label::LabelModule; use crate::modules::launcher::LauncherModule; #[cfg(feature = "music")] use crate::modules::music::MusicModule; +#[cfg(feature = "network_manager")] +use crate::modules::networkmanager::NetworkManagerModule; #[cfg(feature = "notifications")] use crate::modules::notifications::NotificationsModule; use crate::modules::script::ScriptModule; @@ -60,6 +62,8 @@ pub enum ModuleConfig { Launcher(Box), #[cfg(feature = "music")] Music(Box), + #[cfg(feature = "network_manager")] + NetworkManager(Box), #[cfg(feature = "notifications")] Notifications(Box), Script(Box), @@ -103,6 +107,8 @@ impl ModuleConfig { Self::Launcher(module) => create!(module), #[cfg(feature = "music")] Self::Music(module) => create!(module), + #[cfg(feature = "network_manager")] + Self::NetworkManager(module) => create!(module), #[cfg(feature = "notifications")] Self::Notifications(module) => create!(module), Self::Script(module) => create!(module), diff --git a/src/modules/mod.rs b/src/modules/mod.rs index 2a15252..ef9ccce 100644 --- a/src/modules/mod.rs +++ b/src/modules/mod.rs @@ -36,6 +36,8 @@ pub mod label; pub mod launcher; #[cfg(feature = "music")] pub mod music; +#[cfg(feature = "network_manager")] +pub mod networkmanager; #[cfg(feature = "notifications")] pub mod notifications; pub mod script; @@ -285,6 +287,8 @@ pub trait ModuleFactory { let id = Ironbar::unique_id(); let common = module.take_common(); + debug!("adding module {} (id: {})", TModule::name(), id); + let (ui_tx, ui_rx) = mpsc::channel::>(64); let (controller_tx, controller_rx) = mpsc::channel::(64); diff --git a/src/modules/networkmanager.rs b/src/modules/networkmanager.rs new file mode 100644 index 0000000..6235b51 --- /dev/null +++ b/src/modules/networkmanager.rs @@ -0,0 +1,88 @@ +use color_eyre::Result; +use futures_lite::StreamExt; +use futures_signals::signal::SignalExt; +use gtk::prelude::ContainerExt; +use gtk::{Box as GtkBox, Image, Orientation}; +use serde::Deserialize; +use tokio::sync::mpsc::Receiver; + +use crate::clients::networkmanager::{Client, ClientState}; +use crate::config::CommonConfig; +use crate::gtk_helpers::IronbarGtkExt; +use crate::image::ImageProvider; +use crate::modules::{Module, ModuleInfo, ModuleParts, ModuleUpdateEvent, WidgetContext}; +use crate::{glib_recv, module_impl, send_async, spawn}; + +#[derive(Debug, Deserialize, Clone)] +#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))] +pub struct NetworkManagerModule { + #[serde(default = "default_icon_size")] + icon_size: i32, + + #[serde(flatten)] + pub common: Option, +} + +const fn default_icon_size() -> i32 { + 24 +} + +impl Module for NetworkManagerModule { + type SendMessage = ClientState; + type ReceiveMessage = (); + + module_impl!("network_manager"); + + fn spawn_controller( + &self, + _: &ModuleInfo, + context: &WidgetContext, + _: Receiver<()>, + ) -> Result<()> { + let client = context.try_client::()?; + let mut client_signal = client.subscribe().to_stream(); + let widget_transmitter = context.tx.clone(); + + spawn(async move { + while let Some(state) = client_signal.next().await { + send_async!(widget_transmitter, ModuleUpdateEvent::Update(state)); + } + }); + + Ok(()) + } + + fn into_widget( + self, + context: WidgetContext, + info: &ModuleInfo, + ) -> Result> { + let container = GtkBox::new(Orientation::Horizontal, 0); + let icon = Image::new(); + icon.add_class("icon"); + container.add(&icon); + + let icon_theme = info.icon_theme.clone(); + + let initial_icon_name = "content-loading-symbolic"; + ImageProvider::parse(initial_icon_name, &icon_theme, false, self.icon_size) + .map(|provider| provider.load_into_image(icon.clone())); + + let widget_receiver = context.subscribe(); + glib_recv!(widget_receiver, state => { + let icon_name = match state { + ClientState::WiredConnected => "network-wired-symbolic", + ClientState::WifiConnected => "network-wireless-symbolic", + ClientState::CellularConnected => "network-cellular-symbolic", + ClientState::VpnConnected => "network-vpn-symbolic", + ClientState::WifiDisconnected => "network-wireless-acquiring-symbolic", + ClientState::Offline => "network-wireless-disabled-symbolic", + ClientState::Unknown => "dialog-question-symbolic", + }; + ImageProvider::parse(icon_name, &icon_theme, false, self.icon_size) + .map(|provider| provider.load_into_image(icon.clone())); + }); + + Ok(ModuleParts::new(container, None)) + } +} From f819aec259cfe418f050c57eb51a236a95039b57 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 4 Aug 2024 13:46:12 +0100 Subject: [PATCH 16/18] fix(notifications): client broken by recent refactor Fixes #674 --- src/clients/swaync/mod.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/clients/swaync/mod.rs b/src/clients/swaync/mod.rs index 495040b..9b5c116 100644 --- a/src/clients/swaync/mod.rs +++ b/src/clients/swaync/mod.rs @@ -10,11 +10,12 @@ use zbus::export::ordered_stream::OrderedStreamExt; use zbus::zvariant::Type; #[derive(Debug, Clone, Copy, Type, Deserialize)] +#[allow(dead_code)] pub struct Event { pub count: u32, pub dnd: bool, pub cc_open: bool, - // pub inhibited: bool, + pub inhibited: bool, } type GetSubscribeData = (bool, bool, u32, bool); @@ -22,12 +23,12 @@ type GetSubscribeData = (bool, bool, u32, bool); /// Converts the data returned from /// `get_subscribe_data` into an event for convenience. impl From for Event { - fn from((dnd, cc_open, count, _inhibited): (bool, bool, u32, bool)) -> Self { + fn from((dnd, cc_open, count, inhibited): (bool, bool, u32, bool)) -> Self { Self { count, dnd, cc_open, - // inhibited, + inhibited, } } } From df1b131cc8a2c2e06410ec9ae3c6e3575618dbd9 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 4 Aug 2024 16:08:00 +0100 Subject: [PATCH 17/18] ci(nix flake): bump update step version --- .github/workflows/update-nix-flake-lock.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-nix-flake-lock.yml b/.github/workflows/update-nix-flake-lock.yml index 9c6777a..fe96be6 100644 --- a/.github/workflows/update-nix-flake-lock.yml +++ b/.github/workflows/update-nix-flake-lock.yml @@ -1,4 +1,4 @@ -name: update-nix-flake-lock +name: Update Nix Flake lock on: workflow_dispatch: # allows manual triggering schedule: @@ -19,7 +19,7 @@ jobs: access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} - name: Update flake.lock - uses: DeterminateSystems/update-flake-lock@v15 + uses: DeterminateSystems/update-flake-lock@v23 with: pr-title: "Update flake.lock" # Title of PR to be created pr-labels: | # Labels to be set on the PR From 8b806bb5627f64314452e915db8638ee86040c5c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sun, 4 Aug 2024 15:11:01 +0000 Subject: [PATCH 18/18] flake.lock: Update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Flake lock file updates: • Updated input 'crane': 'github:ipetkov/crane/480dff0be03dac0e51a8dfc26e882b0d123a450e?narHash=sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8%3D' (2024-05-29) → 'github:ipetkov/crane/852a59f9672c3413d75bca2b3e9cb4c661cacfc3?narHash=sha256-lcut8uZMSa80z%2BaWpxg%2B9nM8BKWtpU59rtcpMXtHd1Q%3D' (2024-08-03) • Updated input 'naersk': 'github:nix-community/naersk/fa19d8c135e776dc97f4dcca08656a0eeb28d5c0?narHash=sha256-oIs5EF%2B6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY%3D' (2024-05-30) → 'github:nix-community/naersk/3fb418eaf352498f6b6c30592e3beb63df42ef11?narHash=sha256-r/xppY958gmZ4oTfLiHN0ZGuQ%2BRSTijDblVgVLFi1mw%3D' (2024-07-23) • Updated input 'naersk/nixpkgs': 'github:NixOS/nixpkgs/6132b0f6e344ce2fe34fc051b72fb46e34f668e0?narHash=sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY%3D' (2024-05-30) → 'github:NixOS/nixpkgs/81610abc161d4021b29199aa464d6a1a521e0cc9?narHash=sha256-TcXjLVNd3VeH1qKPH335Tc4RbFDbZQX%2Bd7rqnDUoRaY%3D' (2024-08-02) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/ad57eef4ef0659193044870c731987a6df5cf56b?narHash=sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs%3D' (2024-05-29) → 'github:nixos/nixpkgs/d04953086551086b44b6f3c6b7eeb26294f207da?narHash=sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo%3D' (2024-08-02) • Updated input 'rust-overlay': 'github:oxalica/rust-overlay/2a7b53172ed08f856b8382d7dcfd36a4e0cbd866?narHash=sha256-/3sxIe7MZqF/jw1RTQCSmgTjwVod43mmrk84m50MJQ4%3D' (2024-05-31) → 'github:oxalica/rust-overlay/27ec296d93cb4b2d03e8cbd019b1b4cde8c34280?narHash=sha256-cWD5pCs9AYb%2B512/yCx9D0Pl5KcmyuXHeJpsDw/D1vs%3D' (2024-08-04) • Removed input 'rust-overlay/flake-utils' • Removed input 'rust-overlay/flake-utils/systems' --- flake.lock | 64 +++++++++++++----------------------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/flake.lock b/flake.lock index b304159..66f2c10 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1717025063, - "narHash": "sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8=", + "lastModified": 1722704454, + "narHash": "sha256-lcut8uZMSa80z+aWpxg+9nM8BKWtpU59rtcpMXtHd1Q=", "owner": "ipetkov", "repo": "crane", - "rev": "480dff0be03dac0e51a8dfc26e882b0d123a450e", + "rev": "852a59f9672c3413d75bca2b3e9cb4c661cacfc3", "type": "github" }, "original": { @@ -20,34 +20,16 @@ "type": "github" } }, - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1705309234, - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "naersk": { "inputs": { "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1717067539, - "narHash": "sha256-oIs5EF+6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY=", + "lastModified": 1721727458, + "narHash": "sha256-r/xppY958gmZ4oTfLiHN0ZGuQ+RSTijDblVgVLFi1mw=", "owner": "nix-community", "repo": "naersk", - "rev": "fa19d8c135e776dc97f4dcca08656a0eeb28d5c0", + "rev": "3fb418eaf352498f6b6c30592e3beb63df42ef11", "type": "github" }, "original": { @@ -58,11 +40,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717112898, - "narHash": "sha256-7R2ZvOnvd9h8fDd65p0JnB7wXfUvreox3xFdYWd1BnY=", + "lastModified": 1722640603, + "narHash": "sha256-TcXjLVNd3VeH1qKPH335Tc4RbFDbZQX+d7rqnDUoRaY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6132b0f6e344ce2fe34fc051b72fb46e34f668e0", + "rev": "81610abc161d4021b29199aa464d6a1a521e0cc9", "type": "github" }, "original": { @@ -72,11 +54,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1716948383, - "narHash": "sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs=", + "lastModified": 1722630782, + "narHash": "sha256-hMyG9/WlUi0Ho9VkRrrez7SeNlDzLxalm9FwY7n/Noo=", "owner": "nixos", "repo": "nixpkgs", - "rev": "ad57eef4ef0659193044870c731987a6df5cf56b", + "rev": "d04953086551086b44b6f3c6b7eeb26294f207da", "type": "github" }, "original": { @@ -96,17 +78,16 @@ }, "rust-overlay": { "inputs": { - "flake-utils": "flake-utils", "nixpkgs": [ "nixpkgs" ] }, "locked": { - "lastModified": 1717121863, - "narHash": "sha256-/3sxIe7MZqF/jw1RTQCSmgTjwVod43mmrk84m50MJQ4=", + "lastModified": 1722738111, + "narHash": "sha256-cWD5pCs9AYb+512/yCx9D0Pl5KcmyuXHeJpsDw/D1vs=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "2a7b53172ed08f856b8382d7dcfd36a4e0cbd866", + "rev": "27ec296d93cb4b2d03e8cbd019b1b4cde8c34280", "type": "github" }, "original": { @@ -114,21 +95,6 @@ "repo": "rust-overlay", "type": "github" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root",