Compare commits

...

13 Commits
4.5.5 ... 4.5.8

Author SHA1 Message Date
Luke D. Jones
067738b94f Fix pipeline 2022-12-28 21:34:16 +13:00
Luke D. Jones
29b22cd18e Fix incorrect stop/start order of nvidia-powerd on AC plug/unplug 2022-12-28 21:30:29 +13:00
Luke D. Jones
c2aa81bfe3 asusd: fixing a blocking op 2022-12-25 22:22:52 +13:00
Luke D. Jones
8dcb209026 ROGCC: Don't notify user if changing to same mux mode 2022-12-10 21:42:52 +13:00
Luke D. Jones
bdb6c5b2ff Prep 4.5.6 release 2022-12-10 21:08:52 +13:00
Luke D. Jones
a318fbceec asusd: check if nvidia-powerd enabled before toggling 2022-12-10 21:05:27 +13:00
Luke D. Jones
8feacf863a asusd: Very basic support for running a command on AC/Battery switching 2022-12-10 20:51:00 +13:00
Luke D. Jones
0c62582515 ROGCC: Very basic support for running a command on AC/Battery switching 2022-12-10 20:17:45 +13:00
Luke D. Jones
3c575e4d2a ROGCC: Minor correction to tray menu 2022-12-10 19:37:20 +13:00
Luke D. Jones
dbfd73da5e ROGCC: Better handle the use of GPU MUX without supergfxd 2022-12-10 19:30:30 +13:00
Luke D. Jones
b1ee449b97 Adjust profile task to help TUF laptops notify 2022-12-09 10:03:45 +13:00
Luke D. Jones
245c035dc9 Fix tasks not always running correctly on boot/sleep/wake/shutdown 2022-12-08 20:12:55 +13:00
Luke D. Jones
07daa0df61 Fix: ROGCC: show option for LED notifications 2022-12-08 16:27:00 +13:00
25 changed files with 759 additions and 296 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
vendor.tar.xz
cargo-config
.idea
vendor
vendor-*
vendor_*
.vscode-ctags

View File

@@ -17,7 +17,7 @@ cache:
- target/release/.cargo-lock
before_script:
- apt-get update -qq && apt-get install -y -qq libudev-dev libgtk-3-dev grep
- apt-get update -qq && apt-get install -y -qq libudev-dev libgtk-3-dev grep llvm clang libclang-dev
stages:
- format

View File

@@ -5,7 +5,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
## [v4.5.8]
### Changed
- Fix incorrect stop/start order of nvidia-powerd on AC plug/unplug
## [v4.5.7]
### Changed
- ROGCC: Don't notify user if changing to same mux mode
- asusd: don't block on systemd-unit change: removes all shoddy external command calls in favour of async dbus calls
## [v4.5.6]
### Changed
- Fix tasks not always running correctly on boot/sleep/wake/shutdown by finishing the move to async
- Change how the profile/fan change task monitors changes due to TUF laptops behaving slightly different
- ROGCC: Better handle the use of GPU MUX without supergfxd
- ROGCC: Track if reboot required when not using supergfxd
- Add env var for logging levels to daemon and gui (`RUST_LOG=<error|warn|info|debug|trace>`)
- ROGCC: Very basic support for running a command on AC/Battery switching, this is in config at `~/.config/rog/rog-control-center.cfg`, and for now must be edited by hand and ROGCC restarted (run ROGCC in BG to use effectively)
+ Run ROGCC from terminal to see errors of the AC/Battery command
+ Support for editing via ROGCC GUI will come in future
+ This is ideal for userspace tasks
- asusd: Very basic support for running a command on AC/Battery switching, this is in config at `/etc/asusd/asusd.conf`. A restart of asusd is not required if edited.
+ This is ideal for tasks that require root access (BE SAFE!)
- The above AC/Battery commands are probably best set to run a script for more complex tasks
- asusd: check if nvidia-powerd enabled before toggling
## [v4.5.5]
### Changed
- remove an unwrap() causing panic on main ROGCC thread
## [v4.5.4]

257
Cargo.lock generated
View File

@@ -91,7 +91,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf6ccdb167abbf410dcb915cabd428929d7f6a04980b54a11f26a39f1c7f7107"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"once_cell",
"version_check",
]
@@ -149,7 +149,7 @@ checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6"
[[package]]
name = "asusctl"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"daemon",
"gif",
@@ -265,7 +265,7 @@ dependencies = [
"async-lock",
"autocfg",
"blocking",
"cfg-if",
"cfg-if 1.0.0",
"event-listener",
"futures-lite",
"libc",
@@ -349,6 +349,26 @@ version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b7e4c2464d97fe331d41de9d5db0def0a96f4d823b8b32a2efd503578988973"
[[package]]
name = "bindgen"
version = "0.54.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36"
dependencies = [
"bitflags",
"cexpr",
"cfg-if 0.1.10",
"clang-sys",
"lazy_static",
"lazycell",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@@ -490,6 +510,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom 5.1.2",
]
[[package]]
name = "cfg-expr"
version = "0.11.0"
@@ -499,6 +528,12 @@ dependencies = [
"smallvec",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
@@ -520,6 +555,16 @@ dependencies = [
"libc",
]
[[package]]
name = "clang-sys"
version = "0.29.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a"
dependencies = [
"glob",
"libc",
]
[[package]]
name = "clipboard-win"
version = "4.4.2"
@@ -674,7 +719,7 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@@ -683,7 +728,7 @@ version = "0.8.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@@ -727,7 +772,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]]
name = "daemon"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"async-trait",
"concat-idents",
@@ -743,6 +788,7 @@ dependencies = [
"serde_derive",
"serde_json",
"sysfs-class",
"systemd-zbus",
"tokio",
"toml",
"zbus",
@@ -750,7 +796,7 @@ dependencies = [
[[package]]
name = "daemon-user"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"dirs",
"rog_anime",
@@ -869,7 +915,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"dirs-sys-next",
]
@@ -930,10 +976,18 @@ dependencies = [
"wio",
]
[[package]]
name = "ecolor"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"bytemuck",
]
[[package]]
name = "eframe"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"bytemuck",
"egui",
@@ -953,8 +1007,8 @@ dependencies = [
[[package]]
name = "egui"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"accesskit",
"ahash",
@@ -965,8 +1019,8 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"accesskit_winit",
"arboard",
@@ -980,8 +1034,8 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"bytemuck",
"egui",
@@ -994,8 +1048,8 @@ dependencies = [
[[package]]
name = "emath"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"bytemuck",
]
@@ -1023,16 +1077,36 @@ dependencies = [
"byteorder",
]
[[package]]
name = "enumflags2"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0"
dependencies = [
"enumflags2_derive 0.6.4",
]
[[package]]
name = "enumflags2"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e75d4cd21b95383444831539909fbb14b9dc3fdceb2a6f5d36577329a1f55ccb"
dependencies = [
"enumflags2_derive",
"enumflags2_derive 0.7.4",
"serde",
]
[[package]]
name = "enumflags2_derive"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "enumflags2_derive"
version = "0.7.4"
@@ -1080,13 +1154,14 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.19.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#bb2cb764e48829f865312c5934efdab2169737ae"
version = "0.20.0"
source = "git+https://github.com/flukejones/egui?branch=wayland_dark_theme#056fd4bd1ed8c48c035e6b75111cfa8087634934"
dependencies = [
"ab_glyph",
"ahash",
"atomic_refcell",
"bytemuck",
"ecolor",
"emath",
"nohash-hasher",
"parking_lot",
@@ -1414,7 +1489,7 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"libc",
"wasi",
]
@@ -1524,6 +1599,12 @@ dependencies = [
"system-deps",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "glow"
version = "0.11.2"
@@ -1538,9 +1619,9 @@ dependencies = [
[[package]]
name = "glutin"
version = "0.30.2"
version = "0.30.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0282c380a3adb52ae095e5847cc575c6bf79d296dcbf333e00be4a3fca07235e"
checksum = "524d807cd49a0c56a53ef9a6738cd15e7c8c4e9d37a3b7fdb3c250c1cd5bf7a3"
dependencies = [
"bitflags",
"cfg_aliases",
@@ -1554,7 +1635,7 @@ dependencies = [
"objc",
"once_cell",
"raw-window-handle 0.5.0",
"wayland-sys 0.30.0",
"wayland-sys 0.30.1",
"windows-sys 0.36.1",
"x11-dl",
]
@@ -1763,7 +1844,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",
@@ -1847,6 +1928,12 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libappindicator"
version = "0.7.1"
@@ -1883,7 +1970,7 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"winapi",
]
@@ -1931,7 +2018,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
]
[[package]]
@@ -2107,7 +2194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [
"bitflags",
"cfg-if",
"cfg-if 1.0.0",
"libc",
"memoffset 0.6.5",
]
@@ -2120,7 +2207,7 @@ checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [
"autocfg",
"bitflags",
"cfg-if",
"cfg-if 1.0.0",
"libc",
"memoffset 0.6.5",
"pin-utils",
@@ -2133,7 +2220,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46a58d1d356c6597d08cde02c2f09d785b09e28711837b1ed667dc652c08a694"
dependencies = [
"bitflags",
"cfg-if",
"cfg-if 1.0.0",
"libc",
"memoffset 0.7.1",
"pin-utils",
@@ -2146,6 +2233,16 @@ version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"memchr",
"version_check",
]
[[package]]
name = "nom"
version = "7.1.1"
@@ -2340,7 +2437,7 @@ version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"libc",
"redox_syscall",
"smallvec",
@@ -2353,6 +2450,12 @@ version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1"
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.2.0"
@@ -2422,7 +2525,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748"
dependencies = [
"autocfg",
"cfg-if",
"cfg-if 1.0.0",
"libc",
"log",
"wepoll-ffi",
@@ -2593,7 +2696,7 @@ dependencies = [
[[package]]
name = "rog-control-center"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"daemon",
"dirs",
@@ -2605,7 +2708,6 @@ dependencies = [
"log",
"nix 0.26.1",
"notify-rust",
"once_cell",
"png_pong",
"rog_anime",
"rog_aura",
@@ -2624,7 +2726,7 @@ dependencies = [
[[package]]
name = "rog_anime"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"gif",
"glam",
@@ -2634,12 +2736,13 @@ dependencies = [
"serde",
"serde_derive",
"sysfs-class",
"uhid-virt",
"zbus",
]
[[package]]
name = "rog_aura"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"serde",
"serde_derive",
@@ -2650,7 +2753,7 @@ dependencies = [
[[package]]
name = "rog_dbus"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"rog_anime",
"rog_aura",
@@ -2661,7 +2764,7 @@ dependencies = [
[[package]]
name = "rog_platform"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"concat-idents",
"inotify",
@@ -2677,7 +2780,7 @@ dependencies = [
[[package]]
name = "rog_profiles"
version = "4.5.5"
version = "4.5.8"
dependencies = [
"serde",
"serde_derive",
@@ -2695,6 +2798,12 @@ dependencies = [
"libusb1-sys",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
version = "0.3.3"
@@ -2853,11 +2962,17 @@ version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f04293dc80c3993519f2d7f6f511707ee7094fe0c6d3406feb330cdb3540eba3"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"cpufeatures",
"digest",
]
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "signal-hook"
version = "0.3.14"
@@ -2999,7 +3114,7 @@ dependencies = [
[[package]]
name = "supergfxctl"
version = "5.0.2"
source = "git+https://gitlab.com/asus-linux/supergfxctl.git#fa022efb54b752a3672a64c640bd7aebeb842e05"
source = "git+https://gitlab.com/asus-linux/supergfxctl.git#387e115a0f338662be313627308201405039d116"
dependencies = [
"log",
"logind-zbus",
@@ -3046,6 +3161,16 @@ dependencies = [
"version-compare",
]
[[package]]
name = "systemd-zbus"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abba675e441b13248eaf74f1acfacf64adc7b5c030f2f3ff66cc7e02b9a0c417"
dependencies = [
"serde",
"zbus",
]
[[package]]
name = "tauri-winrt-notification"
version = "0.1.0"
@@ -3063,7 +3188,7 @@ version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"fastrand",
"libc",
"redox_syscall",
@@ -3125,7 +3250,7 @@ dependencies = [
"arrayref",
"arrayvec 0.5.2",
"bytemuck",
"cfg-if",
"cfg-if 1.0.0",
"png",
"safe_arch",
"tiny-skia-path",
@@ -3207,7 +3332,7 @@ version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"pin-project-lite",
"tracing-attributes",
"tracing-core",
@@ -3283,6 +3408,26 @@ dependencies = [
"winapi",
]
[[package]]
name = "uhid-virt"
version = "0.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e317bfbb0281bb799f4802d62261a798443a88df4352f302269ad32b4cfc822"
dependencies = [
"enumflags2 0.6.4",
"libc",
"uhidrs-sys",
]
[[package]]
name = "uhidrs-sys"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfcc3b1a199338bcfe0e64b3c427ffab84514e7b23f9402d7fef9b38c0a9916e"
dependencies = [
"bindgen",
]
[[package]]
name = "unicode-bidi"
version = "0.3.8"
@@ -3374,7 +3519,7 @@ version = "0.2.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"wasm-bindgen-macro",
]
@@ -3399,7 +3544,7 @@ version = "0.4.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d"
dependencies = [
"cfg-if",
"cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",
@@ -3509,9 +3654,9 @@ dependencies = [
[[package]]
name = "wayland-sys"
version = "0.30.0"
version = "0.30.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bcdbc325d8a78a9f49dcb77b39e92656e93b3f69eb4d60245f2116ec4bb0a97"
checksum = "96b2a02ac608e07132978689a6f9bf4214949c85998c247abadd4f4129b1aa06"
dependencies = [
"dlib",
"lazy_static",
@@ -3857,7 +4002,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
dependencies = [
"nom",
"nom 7.1.1",
]
[[package]]
@@ -3868,9 +4013,9 @@ checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3"
[[package]]
name = "zbus"
version = "3.6.1"
version = "3.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbaaf011914a4f69a9ec6361225d8440be69673bda9c888275da99c6e8aad03f"
checksum = "938ea6da98c75c2c37a86007bd17fd8e208cbec24e086108c87ece98e9edec0d"
dependencies = [
"async-broadcast",
"async-channel",
@@ -3883,7 +4028,7 @@ dependencies = [
"byteorder",
"derivative",
"dirs",
"enumflags2",
"enumflags2 0.7.5",
"event-listener",
"futures-core",
"futures-sink",
@@ -3907,9 +4052,9 @@ dependencies = [
[[package]]
name = "zbus_macros"
version = "3.6.1"
version = "3.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a64de32c103d3a845f37adf0f46397d6346c8d48028e218db44dcde981733880"
checksum = "45066039ebf3330820e495e854f8b312abb68f0a39e97972d092bd72e8bb3e8e"
dependencies = [
"proc-macro-crate",
"proc-macro2",
@@ -3936,7 +4081,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56f8c89c183461e11867ded456db252eae90874bc6769b7adbea464caa777e51"
dependencies = [
"byteorder",
"enumflags2",
"enumflags2 0.7.5",
"libc",
"serde",
"static_assertions",

View File

@@ -2,7 +2,7 @@
members = ["asusctl", "daemon", "daemon-user", "rog-platform", "rog-dbus", "rog-anime", "rog-aura", "rog-profiles", "rog-control-center"]
[workspace.package]
version = "4.5.5"
version = "4.5.8"
[workspace.dependencies]
async-trait = "^0.1"

View File

@@ -44,3 +44,5 @@ toml.workspace = true
sysfs-class.workspace = true # used for backlight control and baord ID
concat-idents.workspace = true
systemd-zbus = "*"

View File

@@ -7,11 +7,12 @@ use std::path::PathBuf;
pub static CONFIG_PATH: &str = "/etc/asusd/asusd.conf";
#[derive(Deserialize, Serialize, Default)]
#[serde(default)]
pub struct Config {
/// Save charge limit for restoring on boot
pub bat_charge_limit: u8,
pub panel_od: bool,
pub ac_command: String,
pub bat_command: String,
}
impl Config {
@@ -19,6 +20,8 @@ impl Config {
Config {
bat_charge_limit: 100,
panel_od: false,
ac_command: String::new(),
bat_command: String::new(),
}
}
@@ -37,6 +40,8 @@ impl Config {
config = Self::new();
} else if let Ok(data) = serde_json::from_str(&buf) {
config = data;
} else if let Ok(data) = serde_json::from_str::<Config455>(&buf) {
config = data.into();
} else {
warn!(
"Could not deserialise {}.\nWill rename to {}-old and recreate config",
@@ -81,3 +86,22 @@ impl Config {
.unwrap_or_else(|err| error!("Could not write config: {}", err));
}
}
#[derive(Deserialize, Serialize, Default)]
#[serde(default)]
pub struct Config455 {
/// Save charge limit for restoring on boot
pub bat_charge_limit: u8,
pub panel_od: bool,
}
impl From<Config455> for Config {
fn from(c: Config455) -> Self {
Self {
bat_charge_limit: c.bat_charge_limit,
panel_od: c.panel_od,
ac_command: String::new(),
bat_command: String::new(),
}
}
}

View File

@@ -166,28 +166,32 @@ impl crate::CtrlTask for CtrlAnimeZbus {
self.create_sys_event_tasks(
// Loop is required to try an attempt to get the mutex *without* blocking
// other threads - it is possible to end up with deadlocks otherwise.
move || loop {
if let Some(lock) = inner1.try_lock() {
move || {
let inner1 = inner1.clone();
async move {
let lock = inner1.lock().await;
run_action(true, lock, inner1.clone());
break;
}
},
move || loop {
if let Some(lock) = inner2.try_lock() {
run_action(false, lock, inner2.clone());
break;
move || {
let inner2 = inner2.clone();
async move {
let lock = inner2.lock().await;
run_action(true, lock, inner2.clone());
}
},
move || loop {
if let Some(lock) = inner3.try_lock() {
move || {
let inner3 = inner3.clone();
async move {
let lock = inner3.lock().await;
run_action(true, lock, inner3.clone());
break;
}
},
move || loop {
if let Some(lock) = inner4.try_lock() {
run_action(false, lock, inner4.clone());
break;
move || {
let inner4 = inner4.clone();
async move {
let lock = inner4.lock().await;
run_action(true, lock, inner4.clone());
}
},
)

View File

@@ -262,28 +262,32 @@ impl CtrlTask for CtrlKbdLedZbus {
self.create_sys_event_tasks(
// Loop so that we do aquire the lock but also don't block other
// threads (prevents potential deadlocks)
move || loop {
if let Some(lock) = inner1.try_lock() {
move || {
let inner1 = inner1.clone();
async move {
let lock = inner1.lock().await;
load_save(true, lock);
break;
}
},
move || loop {
if let Some(lock) = inner2.try_lock() {
move || {
let inner2 = inner2.clone();
async move {
let lock = inner2.lock().await;
load_save(false, lock);
break;
}
},
move || loop {
if let Some(lock) = inner3.try_lock() {
load_save(true, lock);
break;
}
},
move || loop {
if let Some(lock) = inner4.try_lock() {
move || {
let inner3 = inner3.clone();
async move {
let lock = inner3.lock().await;
load_save(false, lock);
}
},
move || {
let inner4 = inner4.clone();
async move {
let lock = inner4.lock().await;
load_save(false, lock);
break;
}
},
)

View File

@@ -319,7 +319,8 @@ impl CtrlPlatform {
task_watch_item!(panel_od platform);
task_watch_item!(dgpu_disable platform);
task_watch_item!(egpu_enable platform);
task_watch_item!(gpu_mux_mode platform);
// NOTE: see note further below
//task_watch_item!(gpu_mux_mode platform);
}
#[async_trait]
@@ -332,10 +333,12 @@ impl CtrlTask for CtrlPlatform {
let platform1 = self.clone();
let platform2 = self.clone();
self.create_sys_event_tasks(
move || {},
move || async { {} },
move || {
info!("CtrlRogBios reloading panel_od");
if let Some(lock) = platform1.config.try_lock() {
let platform1 = platform1.clone();
async move {
info!("CtrlRogBios reloading panel_od");
let lock = platform1.config.lock().await;
if platform1.platform.has_panel_od() {
platform1
.set_panel_overdrive(lock.panel_od)
@@ -347,10 +350,12 @@ impl CtrlTask for CtrlPlatform {
}
}
},
move || {},
move || async { {} },
move || {
info!("CtrlRogBios reloading panel_od");
if let Some(lock) = platform2.config.try_lock() {
let platform2 = platform2.clone();
async move {
info!("CtrlRogBios reloading panel_od");
let lock = platform2.config.lock().await;
if platform2.platform.has_panel_od() {
platform2
.set_panel_overdrive(lock.panel_od)
@@ -368,7 +373,9 @@ impl CtrlTask for CtrlPlatform {
self.watch_panel_od(signal_ctxt.clone()).await?;
self.watch_dgpu_disable(signal_ctxt.clone()).await?;
self.watch_egpu_enable(signal_ctxt.clone()).await?;
self.watch_gpu_mux_mode(signal_ctxt.clone()).await?;
// NOTE: Can't have this as a watch because on a write to it, it reverts back to booted-with value
// as it does not actually change until reboot.
//self.watch_gpu_mux_mode(signal_ctxt.clone()).await?;
Ok(())
}

View File

@@ -1,12 +1,13 @@
use crate::systemd::{do_systemd_unit_action, SystemdUnitAction};
use crate::{config::Config, error::RogError, GetSupported};
use crate::{task_watch_item, CtrlTask};
use async_trait::async_trait;
use log::{info, warn};
use log::{error, info, warn};
use rog_platform::power::AsusPower;
use rog_platform::supported::ChargeSupportedFunctions;
use std::process::Command;
use std::sync::Arc;
use std::time::Duration;
use systemd_zbus::{ManagerProxy as SystemdProxy, Mode, UnitFileState};
use tokio::time::sleep;
use zbus::dbus_interface;
use zbus::export::futures_util::lock::Mutex;
@@ -152,58 +153,58 @@ impl CtrlTask for CtrlPower {
}
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> {
let conn = zbus::Connection::system().await?;
let sysd1 = SystemdProxy::new(&conn).await?;
let sysd2 = sysd1.clone();
let sysd3 = sysd1.clone();
let power1 = self.clone();
let power2 = self.clone();
self.create_sys_event_tasks(
move || {},
move || async {},
move || {
info!("CtrlCharge reloading charge limit");
if let Some(lock) = power1.config.try_lock() {
power1
let power = power1.clone();
let sysd = sysd1.clone();
async move {
info!("CtrlCharge reloading charge limit");
let lock = power.config.lock().await;
power
.set(lock.bat_charge_limit)
.map_err(|err| {
warn!("CtrlCharge: set_limit {}", err);
err
})
.ok();
}
if let Ok(value) = power1.power.get_online() {
let action = if value == 1 {
SystemdUnitAction::Restart
} else {
SystemdUnitAction::Stop
};
if do_systemd_unit_action(action, NVIDIA_POWERD).is_ok() {
info!("CtrlPower task: did {action:?} on {NVIDIA_POWERD}");
if let Ok(value) = power.power.get_online() {
do_nvidia_powerd_action(&sysd, value == 1).await;
}
}
},
move || {},
move || async {},
move || {
info!("CtrlCharge reloading charge limit");
if let Some(lock) = power2.config.try_lock() {
power2
let power = power2.clone();
let sysd = sysd2.clone();
async move {
info!("CtrlCharge reloading charge limit");
let lock = power.config.lock().await;
power
.set(lock.bat_charge_limit)
.map_err(|err| {
warn!("CtrlCharge: set_limit {}", err);
err
})
.ok();
}
if let Ok(value) = power2.power.get_online() {
let action = if value == 1 {
SystemdUnitAction::Restart
} else {
SystemdUnitAction::Stop
};
if do_systemd_unit_action(action, NVIDIA_POWERD).is_ok() {
info!("CtrlPower task: did {action:?} on {NVIDIA_POWERD}");
if let Ok(value) = power.power.get_online() {
do_nvidia_powerd_action(&sysd, value == 1).await;
}
}
},
)
.await;
let config = self.config.clone();
self.watch_charge_control_end_threshold(signal_ctxt.clone())
.await?;
@@ -214,18 +215,36 @@ impl CtrlTask for CtrlPower {
if let Ok(value) = ctrl.power.get_online() {
if online != value {
online = value;
let action = if value == 1 {
SystemdUnitAction::Restart
} else {
SystemdUnitAction::Stop
};
if do_systemd_unit_action(action, NVIDIA_POWERD).is_ok() {
info!("CtrlPower task: did {action:?} on {NVIDIA_POWERD}");
}
do_nvidia_powerd_action(&sysd3, value == 1).await;
Self::notify_mains_online(&signal_ctxt, value == 1)
.await
.unwrap();
let mut config = config.lock().await;
config.read();
let mut prog: Vec<&str> = Vec::new();
if value == 1 {
// AC ONLINE
prog = config.ac_command.split_whitespace().collect();
} else if value == 0 {
// BATTERY
prog = config.bat_command.split_whitespace().collect();
}
if prog.len() > 1 {
let mut cmd = Command::new(prog[0]);
for arg in prog.iter().skip(1) {
cmd.arg(*arg);
}
if let Err(e) = cmd.spawn() {
if value == 1 {
error!("AC power command error: {e}");
} else {
error!("Battery power command error: {e}");
}
}
}
}
}
// The inotify doesn't pick up events when the kernel changes internal value
@@ -237,3 +256,23 @@ impl CtrlTask for CtrlPower {
Ok(())
}
}
async fn do_nvidia_powerd_action(proxy: &SystemdProxy<'_>, ac_on: bool) {
if let Ok(res) = proxy.get_unit_file_state(NVIDIA_POWERD).await {
if res == UnitFileState::Enabled {
if ac_on {
proxy
.start_unit(NVIDIA_POWERD, Mode::Replace)
.await
.map_err(|e| error!("Error stopping {NVIDIA_POWERD}, {e:?}"))
.ok();
} else {
proxy
.stop_unit(NVIDIA_POWERD, Mode::Replace)
.await
.map_err(|e| error!("Error stopping {NVIDIA_POWERD}, {e:?}"))
.ok();
}
}
}
}

View File

@@ -200,8 +200,36 @@ impl CtrlTask for ProfileZbus {
}
async fn create_tasks(&self, signal_ctxt: SignalContext<'static>) -> Result<(), RogError> {
// let ctrl = self.0.clone();
// let mut watch = self.0.lock().await.platform.monitor_platform_profile()?;
// let sig_ctx = signal_ctxt.clone();
// tokio::spawn(async move {
// let mut buffer = [0; 32];
// watch
// .event_stream(&mut buffer)
// .unwrap()
// .for_each(|_| async {
// let mut lock = ctrl.lock().await;
// let new_profile = Profile::get_active_profile().unwrap();
// if new_profile != lock.config.active_profile {
// lock.config.active_profile = new_profile;
// lock.write_profile_curve_to_platform().unwrap();
// lock.save_config();
// }
// Self::notify_profile(&sig_ctx, lock.config.active_profile)
// .await
// .ok();
// })
// .await;
// });
let ctrl = self.0.clone();
let mut watch = self.0.lock().await.platform.monitor_platform_profile()?;
let mut watch = self
.0
.lock()
.await
.platform
.monitor_throttle_thermal_policy()?;
tokio::spawn(async move {
let mut buffer = [0; 32];
@@ -210,13 +238,15 @@ impl CtrlTask for ProfileZbus {
.unwrap()
.for_each(|_| async {
let mut lock = ctrl.lock().await;
let new_profile = Profile::get_active_profile().unwrap();
let new_thermal = lock.platform.get_throttle_thermal_policy().unwrap();
let new_profile = Profile::from_throttle_thermal_policy(new_thermal);
if new_profile != lock.config.active_profile {
lock.config.active_profile = new_profile;
lock.write_profile_curve_to_platform().unwrap();
lock.save_config();
Profile::set_profile(lock.config.active_profile).unwrap();
}
Self::notify_profile(&signal_ctxt.clone(), lock.config.active_profile)
Self::notify_profile(&signal_ctxt, lock.config.active_profile)
.await
.ok();
})

View File

@@ -7,7 +7,6 @@ use std::time::Duration;
use ::zbus::export::futures_util::lock::Mutex;
use ::zbus::Connection;
use daemon::ctrl_anime::CtrlAnime;
use log::LevelFilter;
use log::{error, info, warn};
use tokio::time::sleep;
use zbus::SignalContext;
@@ -33,9 +32,9 @@ static PROFILE_CONFIG_PATH: &str = "/etc/asusd/profile.conf";
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut logger = env_logger::Builder::new();
logger
.parse_default_env()
.target(env_logger::Target::Stdout)
.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args()))
.filter(None, LevelFilter::Info)
.init();
let is_service = match env::var_os("IS_SERVICE") {

View File

@@ -14,16 +14,16 @@ pub mod ctrl_profiles;
/// Laptop matching to determine capabilities
pub mod laptops;
pub mod systemd;
/// Fetch all supported functions for the laptop
pub mod ctrl_supported;
pub mod error;
use std::future::Future;
use crate::error::RogError;
use async_trait::async_trait;
use log::warn;
use log::{debug, warn};
use logind_zbus::manager::ManagerProxy;
use zbus::{export::futures_util::StreamExt, zvariant::ObjectPath, Connection, SignalContext};
@@ -134,13 +134,31 @@ pub trait CtrlTask {
///
/// The closures can potentially block, so execution time should be the minimal possible
/// such as save a variable.
async fn create_sys_event_tasks(
async fn create_sys_event_tasks<
Fut1,
Fut2,
Fut3,
Fut4,
F1: Send + 'static,
F2: Send + 'static,
F3: Send + 'static,
F4: Send + 'static,
>(
&self,
mut on_sleep: impl FnMut() + Send + 'static,
mut on_wake: impl FnMut() + Send + 'static,
mut on_shutdown: impl FnMut() + Send + 'static,
mut on_boot: impl FnMut() + Send + 'static,
) {
mut on_sleep: F1,
mut on_wake: F2,
mut on_shutdown: F3,
mut on_boot: F4,
) where
F1: FnMut() -> Fut1,
F2: FnMut() -> Fut2,
F3: FnMut() -> Fut3,
F4: FnMut() -> Fut4,
Fut1: Future<Output = ()> + Send,
Fut2: Future<Output = ()> + Send,
Fut3: Future<Output = ()> + Send,
Fut4: Future<Output = ()> + Send,
{
let connection = Connection::system()
.await
.expect("Controller could not create dbus connection");
@@ -154,9 +172,11 @@ pub trait CtrlTask {
while let Some(event) = notif.next().await {
if let Ok(args) = event.args() {
if args.start {
on_sleep();
debug!("Doing on_sleep()");
on_sleep().await;
} else if !args.start() {
on_wake();
debug!("Doing on_wake()");
on_wake().await;
}
}
}
@@ -172,9 +192,11 @@ pub trait CtrlTask {
while let Some(event) = notif.next().await {
if let Ok(args) = event.args() {
if args.start {
on_shutdown();
debug!("Doing on_shutdown()");
on_shutdown().await;
} else if !args.start() {
on_boot();
debug!("Doing on_boot()");
on_boot().await;
}
}
}

View File

@@ -1,90 +0,0 @@
use std::process::Command;
use crate::error::RogError;
/// An action for `systemctl`
#[derive(Debug, Copy, Clone)]
pub enum SystemdUnitAction {
Stop,
Start,
Restart,
}
impl From<SystemdUnitAction> for &str {
fn from(s: SystemdUnitAction) -> Self {
match s {
SystemdUnitAction::Stop => "stop",
SystemdUnitAction::Start => "start",
SystemdUnitAction::Restart => "restart",
}
}
}
#[derive(Debug, Copy, Clone)]
pub enum SystemdUnitState {
Active,
Inactive,
}
impl From<SystemdUnitState> for &str {
fn from(s: SystemdUnitState) -> Self {
match s {
SystemdUnitState::Active => "active",
SystemdUnitState::Inactive => "inactive",
}
}
}
/// Change the state of a systemd unit. Blocks while running command.
pub fn do_systemd_unit_action(action: SystemdUnitAction, unit: &str) -> Result<(), RogError> {
let mut cmd = Command::new("systemctl");
cmd.arg(<&str>::from(action));
cmd.arg(unit);
let status = cmd
.status()
.map_err(|err| RogError::Command(format!("{:?}", cmd), err))?;
if !status.success() {
let msg = format!("systemctl {action:?} {unit} failed: {status:?}",);
return Err(RogError::SystemdUnitAction(msg));
}
Ok(())
}
/// Get systemd unit state. Blocks while command is run.
pub fn is_systemd_unit_state(state: SystemdUnitState, unit: &str) -> Result<bool, RogError> {
let mut cmd = Command::new("systemctl");
cmd.arg("is-active");
cmd.arg(unit);
let output = cmd
.output()
.map_err(|err| RogError::Command(format!("{:?}", cmd), err))?;
if output.stdout.starts_with(<&str>::from(state).as_bytes()) {
return Ok(true);
}
Ok(false)
}
/// Wait for a systemd unit to change to `state`. Checks state every 250ms for 3 seconds. Blocks while running wait.
pub fn wait_systemd_unit_state(state: SystemdUnitState, unit: &str) -> Result<(), RogError> {
let mut cmd = Command::new("systemctl");
cmd.arg("is-active");
cmd.arg(unit);
let mut count = 0;
while count <= (4 * 3) {
// 3 seconds max
let output = cmd
.output()
.map_err(|err| RogError::Command(format!("{:?}", cmd), err))?;
if output.stdout.starts_with(<&str>::from(state).as_bytes()) {
return Ok(());
}
// fine to block here, nobody doing shit now
std::thread::sleep(std::time::Duration::from_millis(250));
count += 1;
}
Err(RogError::SystemdUnitWaitTimeout(<&str>::from(state).into()))
}

View File

@@ -6,6 +6,7 @@ Before=multi-user.target
[Service]
Environment=IS_SERVICE=1
Environment=RUST_LOG="info"
ExecStartPre=/bin/sleep 2
ExecStart=/usr/bin/asusd
Restart=on-failure

View File

@@ -31,3 +31,5 @@ glam.workspace = true
zbus = { workspace = true, optional = true }
sysfs-class = { workspace = true, optional = true }
uhid-virt = "^0.0.5"

View File

@@ -10,7 +10,7 @@ mocking = []
[dependencies]
egui = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
eframe= { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
eframe = { git = "https://github.com/flukejones/egui", branch = "wayland_dark_theme" }
libappindicator = "0.7" # Tray icon
gtk = "0.15.5"
@@ -22,7 +22,6 @@ rog_aura = { path = "../rog-aura" }
rog_profiles = { path = "../rog-profiles" }
rog_platform = { path = "../rog-platform" }
supergfxctl = { git = "https://gitlab.com/asus-linux/supergfxctl.git", default-features = false }
#supergfxctl = { path = "../../supergfxctl", default-features = false }
log.workspace = true
env_logger.workspace = true
@@ -40,5 +39,3 @@ png_pong.workspace = true
nix = "^0.26.1"
tempfile = "3.3.0"
once_cell = "1.10.0"

View File

@@ -4,7 +4,6 @@ use std::{
fs::{create_dir, OpenOptions},
io::{Read, Write},
};
//use log::{error, info, warn};
use crate::{error::Error, update_and_notify::EnabledNotifications};
@@ -12,11 +11,13 @@ const CFG_DIR: &str = "rog";
const CFG_FILE_NAME: &str = "rog-control-center.cfg";
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct Config {
pub run_in_background: bool,
pub startup_in_background: bool,
pub ac_command: String,
pub bat_command: String,
pub enable_notifications: bool,
// This field must be last
pub enabled_notifications: EnabledNotifications,
}
@@ -27,6 +28,8 @@ impl Default for Config {
startup_in_background: false,
enable_notifications: true,
enabled_notifications: EnabledNotifications::default(),
ac_command: String::new(),
bat_command: String::new(),
}
}
}
@@ -67,6 +70,9 @@ impl Config {
} else if let Ok(data) = toml::from_str::<Config>(&buf) {
info!("Loaded config file {path:?}");
return Ok(data);
} else if let Ok(data) = toml::from_str::<Config455>(&buf) {
info!("Loaded old v4.5.5 config file {path:?}");
return Ok(data.into());
}
}
Err(Error::ConfigLoadFail)
@@ -100,3 +106,24 @@ impl Config {
Ok(())
}
}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Config455 {
pub run_in_background: bool,
pub startup_in_background: bool,
pub enable_notifications: bool,
pub enabled_notifications: EnabledNotifications,
}
impl From<Config455> for Config {
fn from(c: Config455) -> Self {
Self {
run_in_background: c.run_in_background,
startup_in_background: c.startup_in_background,
enable_notifications: c.enable_notifications,
enabled_notifications: c.enabled_notifications,
ac_command: String::new(),
bat_command: String::new(),
}
}
}

View File

@@ -1,5 +1,5 @@
use eframe::{IconData, NativeOptions};
use log::{error, info, LevelFilter};
use log::{error, info};
use rog_aura::layouts::KeyLayout;
use rog_control_center::tray::init_tray;
use rog_control_center::update_and_notify::EnabledNotifications;
@@ -29,9 +29,9 @@ fn main() -> Result<()> {
print_versions();
let mut logger = env_logger::Builder::new();
logger
.parse_default_env()
.target(env_logger::Target::Stdout)
.format(|buf, record| writeln!(buf, "{}: {}", record.level(), record.args()))
.filter(None, LevelFilter::Info)
.init();
// start tokio
@@ -118,7 +118,7 @@ fn main() -> Result<()> {
Err(_) => on_tmp_dir_exists().unwrap(),
};
let states = setup_page_state_and_notifs(layout, enabled_notifications, &supported)?;
let states = setup_page_state_and_notifs(layout, enabled_notifications, &config, &supported)?;
init_tray(supported, states.clone());
@@ -153,6 +153,7 @@ fn main() -> Result<()> {
fn setup_page_state_and_notifs(
keyboard_layout: KeyLayout,
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
config: &Config,
supported: &SupportedFunctions,
) -> Result<Arc<Mutex<SystemState>>> {
let page_states = Arc::new(Mutex::new(SystemState::new(
@@ -161,7 +162,7 @@ fn setup_page_state_and_notifs(
supported,
)?));
start_notifications(page_states.clone(), enabled_notifications)?;
start_notifications(config, page_states.clone(), enabled_notifications)?;
Ok(page_states)
}

View File

@@ -4,6 +4,7 @@
use std::{
io::Write,
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{channel, Receiver},
Arc, Mutex,
},
@@ -21,7 +22,7 @@ use supergfxctl::{
zbus_proxy::DaemonProxyBlocking as GfxProxyBlocking,
};
use log::{debug, error, info, trace};
use log::{debug, error, info, trace, warn};
const TRAY_APP_ICON: &str = "rog-control-center";
const TRAY_LABEL: &str = "ROG Control Center";
@@ -241,7 +242,10 @@ impl ROGTray {
}
fn menu_add_gpu(&mut self, supported: &SupportedFunctions, current_mode: GfxMode) {
let set_mux_off = Arc::new(AtomicBool::new(false));
let gfx_dbus = self.gfx_proxy.clone();
let set_mux_off1 = set_mux_off.clone();
let mut gpu_menu = RadioGroup::new("Integrated", move |_| {
let mode = gfx_dbus
.mode()
@@ -259,9 +263,11 @@ impl ROGTray {
})
.ok();
}
set_mux_off1.store(true, Ordering::Relaxed);
});
let gfx_dbus = self.gfx_proxy.clone();
let set_mux_off1 = set_mux_off.clone();
gpu_menu.add("Hybrid", move |_| {
let mode = gfx_dbus
.mode()
@@ -279,7 +285,33 @@ impl ROGTray {
})
.ok();
}
set_mux_off1.store(true, Ordering::Relaxed);
});
if supported.rog_bios_ctrl.egpu_enable {
let set_mux_off1 = set_mux_off.clone();
let gfx_dbus = self.gfx_proxy.clone();
gpu_menu.add("eGPU", move |_| {
let mode = gfx_dbus
.mode()
.map_err(|e| {
error!("ROGTray: mode: {e}");
e
})
.unwrap_or(GfxMode::None);
if mode != GfxMode::Egpu {
gfx_dbus
.set_mode(&GfxMode::Egpu)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
set_mux_off1.store(true, Ordering::Relaxed);
});
}
let mut reboot_required = false;
if supported.rog_bios_ctrl.gpu_mux {
let gfx_dbus = self.bios_proxy.clone();
gpu_menu.add("Ultimate (Reboot required)", move |_| {
@@ -300,35 +332,95 @@ impl ROGTray {
.ok();
}
});
}
if supported.rog_bios_ctrl.egpu_enable {
let gfx_dbus = self.gfx_proxy.clone();
gpu_menu.add("eGPU", move |_| {
let mode = gfx_dbus
.mode()
if set_mux_off.load(Ordering::Relaxed) {
warn!("Selected non-dgpu mode, must set MUX to optimus");
self.bios_proxy
.set_gpu_mux_mode(GpuMode::Optimus)
.map_err(|e| {
error!("ROGTray: mode: {e}");
error!("ROGTray: set_mode: {e}");
e
})
.unwrap_or(GfxMode::None);
if mode != GfxMode::Egpu {
gfx_dbus
.set_mode(&GfxMode::Egpu)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
}
});
.ok();
}
if let Ok(mode) = self.bios_proxy.gpu_mux_mode() {
let mode = match mode {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
_ => GfxMode::Hybrid,
};
reboot_required = mode != current_mode;
}
}
let active = match current_mode {
GfxMode::AsusMuxDiscreet => "Discreet".to_owned(),
_ => current_mode.to_string(),
};
let reboot_required = if reboot_required {
"(Reboot required)"
} else {
""
};
self.add_radio_sub_menu(
&format!("GPU Mode: {current_mode}"),
&format!("GPU Mode: {active} {reboot_required}"),
active.as_str(),
&gpu_menu,
);
debug!("ROGTray: appended gpu menu");
}
fn menu_add_mux(&mut self, current_mode: GfxMode) {
let gfx_dbus = self.bios_proxy.clone();
let mut reboot_required = false;
if let Ok(mode) = gfx_dbus.gpu_mux_mode() {
let mode = match mode {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
_ => GfxMode::Hybrid,
};
reboot_required = mode != current_mode;
}
let mut gpu_menu = RadioGroup::new("Optimus", move |_| {
gfx_dbus
.set_gpu_mux_mode(GpuMode::Optimus)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
debug!("Setting GPU mode: {}", GpuMode::Optimus);
});
let gfx_dbus = self.bios_proxy.clone();
gpu_menu.add("Ultimate", move |_| {
gfx_dbus
.set_gpu_mux_mode(GpuMode::Discrete)
.map_err(|e| {
error!("ROGTray: set_mode: {e}");
e
})
.ok();
debug!("Setting GPU mode: {}", GpuMode::Discrete);
});
let active = match current_mode {
GfxMode::AsusMuxDiscreet => "Ultimate".to_owned(),
GfxMode::Hybrid => "Optimus".to_owned(),
_ => current_mode.to_string(),
};
debug!("Current active GPU mode: {}", active);
let reboot_required = if reboot_required {
"(Reboot required)"
} else {
""
};
self.add_radio_sub_menu(
&format!("GPU Mode: {active} {reboot_required}"),
active.as_str(),
&gpu_menu,
);
@@ -362,6 +454,8 @@ impl ROGTray {
self.menu_add_panel_od(supported, panel_od);
if has_supergfx {
self.menu_add_gpu(supported, current_gfx_mode);
} else if supported.rog_bios_ctrl.gpu_mux {
self.menu_add_mux(current_gfx_mode);
}
self.menu_update();
}
@@ -412,10 +506,19 @@ pub fn init_tray(
loop {
if let Ok(mut lock) = states.lock() {
if lock.tray_should_update {
// Supergfx ends up adding some complexity to handle if it isn't available
let current_gpu_mode = if lock.gfx_state.has_supergfx {
lock.gfx_state.mode
} else {
match lock.bios.dedicated_gfx {
GpuMode::Discrete => GfxMode::AsusMuxDiscreet,
_ => GfxMode::Hybrid,
}
};
tray.rebuild_and_update(
&supported,
has_supergfx,
lock.gfx_state.mode,
current_gpu_mode,
lock.power_state.charge_limit,
lock.bios.panel_overdrive,
);

View File

@@ -24,6 +24,9 @@ use zbus::export::futures_util::{future, StreamExt};
const NOTIF_HEADER: &str = "ROG Control";
static mut POWER_AC_CMD: Option<Command> = None;
static mut POWER_BAT_CMD: Option<Command> = None;
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struct EnabledNotifications {
@@ -54,7 +57,7 @@ impl Default for EnabledNotifications {
receive_notify_charge_control_end_threshold: true,
receive_notify_mains_online: false,
receive_notify_profile: true,
receive_notify_led: false,
receive_notify_led: true,
receive_power_states: false,
receive_notify_gfx: false,
receive_notify_gfx_status: false,
@@ -131,11 +134,36 @@ macro_rules! recv_notif {
type SharedHandle = Arc<Mutex<Option<NotificationHandle>>>;
pub fn start_notifications(
config: &Config,
page_states: Arc<Mutex<SystemState>>,
enabled_notifications: Arc<Mutex<EnabledNotifications>>,
) -> Result<()> {
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
// Setup the AC/BAT commands that will run on poweer status change
unsafe {
let prog: Vec<&str> = config.ac_command.split_whitespace().collect();
if prog.len() > 1 {
let mut cmd = Command::new(prog[0]);
for arg in prog.iter().skip(1) {
cmd.arg(*arg);
}
POWER_AC_CMD = Some(cmd);
}
}
unsafe {
let prog: Vec<&str> = config.bat_command.split_whitespace().collect();
if prog.len() > 1 {
let mut cmd = Command::new(prog[0]);
for arg in prog.iter().skip(1) {
cmd.arg(*arg);
}
POWER_BAT_CMD = Some(cmd);
}
}
// BIOS notif
recv_notif!(
RogBiosProxy,
@@ -185,18 +213,6 @@ pub fn start_notifications(
do_notification
);
recv_notif!(
RogBiosProxy,
receive_notify_gpu_mux_mode,
last_notification,
enabled_notifications,
page_states,
(bios.dedicated_gfx),
(mode),
"Reboot required. BIOS GPU MUX mode set to",
do_mux_notification
);
// Charge notif
recv_notif!(
PowerProxy,
@@ -277,6 +293,52 @@ pub fn start_notifications(
};
});
let page_states1 = page_states.clone();
let last_notification1 = last_notification.clone();
tokio::spawn(async move {
let conn = zbus::Connection::system()
.await
.map_err(|e| {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
e
})
.unwrap();
let proxy = RogBiosProxy::new(&conn)
.await
.map_err(|e| {
error!("zbus signal: receive_notify_gpu_mux_mode: {e}");
e
})
.unwrap();
let mut actual_mux_mode = GpuMode::Error;
if let Ok(mode) = proxy.gpu_mux_mode().await {
actual_mux_mode = mode;
}
if let Ok(mut p) = proxy.receive_notify_gpu_mux_mode().await {
info!("Started zbus signal thread: receive_power_states");
while let Some(e) = p.next().await {
if let Ok(out) = e.args() {
if out.mode == actual_mux_mode {
continue;
}
if let Ok(mut lock) = page_states1.lock() {
lock.bios.dedicated_gfx = out.mode;
lock.set_notified();
}
if let Ok(ref mut lock) = last_notification1.lock() {
if let Some(notif) = lock.take() {
notif.close();
}
}
do_mux_notification("Reboot required. BIOS GPU MUX mode set to", &out.mode)
.ok();
}
}
};
});
if let Ok(lock) = page_states.try_lock() {
use supergfxctl::pci_device::Device;
let dev = Device::find().unwrap_or_default();
@@ -401,8 +463,22 @@ where
fn ac_power_notification(message: &str, on: &bool) -> Result<NotificationHandle> {
let data = if *on {
unsafe {
if let Some(cmd) = POWER_AC_CMD.as_mut() {
if let Err(e) = cmd.spawn() {
error!("AC power command error: {e}");
}
}
}
"plugged".to_owned()
} else {
unsafe {
if let Some(cmd) = POWER_BAT_CMD.as_mut() {
if let Err(e) = cmd.spawn() {
error!("Battery power command error: {e}");
}
}
}
"unplugged".to_owned()
};
Ok(base_notification(message, &data).show()?)
@@ -456,10 +532,24 @@ where
}
/// Actual `GpuMode` unused as data is never correct until switched by reboot
fn do_mux_notification(message: &str, _: &GpuMode) -> Result<NotificationHandle> {
let mut notif = base_notification(message, &"");
fn do_mux_notification(message: &str, m: &GpuMode) -> Result<()> {
let mut notif = base_notification(message, &m.to_string());
notif.action("gnome-session-quit", "Reboot");
notif.urgency(Urgency::Critical);
notif.icon("system-reboot-symbolic");
notif.hint(Hint::Transient(true));
Ok(notif.show()?)
let handle = notif.show()?;
std::thread::spawn(|| {
handle.wait_for_action(|id| {
if id == "gnome-session-quit" {
let mut cmd = Command::new("gnome-session-quit");
cmd.arg("--reboot");
cmd.spawn().ok();
} else if id == "__closed" {
// TODO: cancel the switching
}
})
});
Ok(())
}

View File

@@ -12,7 +12,8 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
Default::default()
};
if ui
ui.label("Application settings");
let app_changed = ui
.checkbox(&mut config.run_in_background, "Run in Background")
.clicked()
|| ui
@@ -23,11 +24,19 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
&mut enabled_notifications.all_enabled,
"Enable Notifications",
)
.clicked()
.clicked();
ui.label("Notification settings");
let notif_changed = ui
.checkbox(
&mut enabled_notifications.receive_notify_gfx_status,
"Enable dGPU status notification",
)
.clicked()
|| ui
.checkbox(
&mut enabled_notifications.receive_notify_gfx_status,
"Enable dGPU status notification",
&mut enabled_notifications.receive_notify_led,
"Enable LED mode change notification",
)
.clicked()
|| ui
@@ -71,8 +80,9 @@ pub fn app_settings(config: &mut Config, states: &mut SystemState, ui: &mut Ui)
&mut enabled_notifications.receive_notify_post_boot_sound,
"Enable BIOS post sound notification",
)
.clicked()
{
.clicked();
if app_changed || notif_changed {
if let Ok(mut lock) = states.enabled_notifications.lock() {
// Replace inner content before save
*lock = enabled_notifications;

View File

@@ -93,6 +93,13 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
if supported.rog_bios_ctrl.gpu_mux {
let mut changed = false;
let mut dedicated_gfx = states.bios.dedicated_gfx;
let mut reboot_required = false;
if let Ok(mode) = states.asus_dbus.proxies().rog_bios().gpu_mux_mode() {
reboot_required = mode != states.bios.dedicated_gfx;
}
ui.group(|ui| {
ui.vertical(|ui| {
ui.horizontal_wrapped(|ui| ui.label("GPU MUX mode"));
@@ -100,19 +107,23 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
ui.horizontal_wrapped(|ui| {
changed = ui
.selectable_value(
&mut states.bios.dedicated_gfx,
&mut dedicated_gfx,
GpuMode::Discrete,
"Dedicated (Ultimate)",
)
.clicked()
|| ui
.selectable_value(
&mut states.bios.dedicated_gfx,
&mut dedicated_gfx,
GpuMode::Optimus,
"Optimus (Hybrid)",
)
.clicked();
});
if reboot_required {
ui.horizontal_wrapped(|ui| ui.heading("REBOOT REQUIRED"));
}
});
});
@@ -121,7 +132,7 @@ pub fn rog_bios_group(supported: &SupportedFunctions, states: &mut SystemState,
.asus_dbus
.proxies()
.rog_bios()
.set_gpu_mux_mode(states.bios.dedicated_gfx)
.set_gpu_mux_mode(dedicated_gfx)
.map_err(|err| {
states.error = Some(err.to_string());
})

View File

@@ -72,6 +72,14 @@ impl Profile {
file.write_all(<&str>::from(profile).as_bytes())?;
Ok(())
}
pub fn from_throttle_thermal_policy(num: u8) -> Self {
match num {
1 => Self::Performance,
2 => Self::Quiet,
_ => Self::Balanced,
}
}
}
impl Default for Profile {