mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Fix rogcc not closing when run-in-background
This commit is contained in:
@@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file.
|
||||
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 - 4.5.0]
|
||||
## [Unreleased - 4.5.0-RC5]
|
||||
### Added
|
||||
- intofy watches on:
|
||||
- `charge_control_end_threshold`
|
||||
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
### Changed
|
||||
- Use loops to ensure that mutex is gained for LED changes.
|
||||
- asusctl now uses tokio for async runtime. This helps simplify some code.
|
||||
- Properly fix notifs used in rog-control-center
|
||||
### Breaking
|
||||
- DBUS: all charge control methods renamed to:
|
||||
- `ChargeControlEndThreshold`
|
||||
|
||||
69
Cargo.lock
generated
69
Cargo.lock
generated
@@ -47,9 +47,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "arboard"
|
||||
version = "3.1.1"
|
||||
version = "3.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6702f4a0b562d352aa3d0e22d4142ea9241c44faa27635bb9d87047a08837d4d"
|
||||
checksum = "d6041616acea41d67c4a984709ddab1587fd0b10efe5cc563fee954d2f011854"
|
||||
dependencies = [
|
||||
"clipboard-win",
|
||||
"log",
|
||||
@@ -77,7 +77,7 @@ checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
|
||||
|
||||
[[package]]
|
||||
name = "asusctl"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"daemon",
|
||||
"gif",
|
||||
@@ -318,18 +318,18 @@ checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.12.2"
|
||||
version = "1.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5aec14f5d4e6e3f927cd0c81f72e5710d95ee9019fbeb4b3021193867491bfd8"
|
||||
checksum = "aaa3a8d9a1ca92e282c96a32d6511b695d7d994d1d102ba85d279f9b2756947f"
|
||||
dependencies = [
|
||||
"bytemuck_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck_derive"
|
||||
version = "1.2.1"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1b9e1f5fa78f69496407a27ae9ed989e3c3b072310286f5ef385525e4cbc24a9"
|
||||
checksum = "5fe233b960f12f8007e3db2d136e3cb1c291bfd7396e384ee76025fc1a3932b4"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -592,7 +592,7 @@ checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
|
||||
|
||||
[[package]]
|
||||
name = "daemon"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"async-trait",
|
||||
"concat-idents",
|
||||
@@ -616,7 +616,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "daemon-user"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
"rog_anime",
|
||||
@@ -767,7 +767,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "eframe"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -788,7 +788,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"epaint",
|
||||
@@ -799,7 +799,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui-winit"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"arboard",
|
||||
"egui",
|
||||
@@ -813,7 +813,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "egui_glow"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"egui",
|
||||
@@ -827,7 +827,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
@@ -892,7 +892,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.19.0"
|
||||
source = "git+https://github.com/emilk/egui#4d1e858a52ec5d4b4f243065774b3ad95413a5e2"
|
||||
source = "git+https://github.com/flukejones/egui#f17fd2d2e47efc08b00fb2bda3529fed22e3a711"
|
||||
dependencies = [
|
||||
"ab_glyph",
|
||||
"ahash",
|
||||
@@ -1732,15 +1732,6 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num_threads"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
version = "0.2.4"
|
||||
@@ -1917,9 +1908,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.16"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
|
||||
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
@@ -2029,9 +2020,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.6.0"
|
||||
version = "1.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b"
|
||||
checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a"
|
||||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
@@ -2040,9 +2031,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.27"
|
||||
version = "0.6.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
|
||||
checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848"
|
||||
|
||||
[[package]]
|
||||
name = "remove_dir_all"
|
||||
@@ -2055,7 +2046,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog-control-center"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"daemon",
|
||||
"dirs",
|
||||
@@ -2080,7 +2071,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog_anime"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"gif",
|
||||
"glam",
|
||||
@@ -2096,7 +2087,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog_aura"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -2107,7 +2098,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog_dbus"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"rog_anime",
|
||||
"rog_aura",
|
||||
@@ -2120,7 +2111,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog_platform"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"concat-idents",
|
||||
"inotify",
|
||||
@@ -2137,7 +2128,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rog_profiles"
|
||||
version = "4.5.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
@@ -2537,12 +2528,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.16"
|
||||
version = "0.3.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fab5c8b9980850e06d92ddbe3ab839c062c801f3927c0fb8abd6fc8e918fbca"
|
||||
checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"num_threads",
|
||||
"serde",
|
||||
"time-core",
|
||||
]
|
||||
|
||||
@@ -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.0-rc4"
|
||||
version = "4.5.0-rc5"
|
||||
|
||||
[workspace.dependencies]
|
||||
async-trait = "^0.1"
|
||||
@@ -48,7 +48,7 @@ opt-level = 3
|
||||
panic = "abort"
|
||||
|
||||
[profile.dev]
|
||||
debug = false
|
||||
debug = true
|
||||
opt-level = 1
|
||||
|
||||
[profile.bench]
|
||||
|
||||
@@ -325,8 +325,8 @@ impl AuraEffect {
|
||||
&self.mode
|
||||
}
|
||||
|
||||
pub fn mode_name(&self) -> String {
|
||||
(<&str>::from(&self.mode)).to_string()
|
||||
pub fn mode_name(&self) -> &str {
|
||||
<&str>::from(&self.mode)
|
||||
}
|
||||
|
||||
pub fn mode_num(&self) -> u8 {
|
||||
|
||||
@@ -8,8 +8,8 @@ edition = "2021"
|
||||
mocking = []
|
||||
|
||||
[dependencies]
|
||||
egui = { git = "https://github.com/emilk/egui" }
|
||||
eframe= { git = "https://github.com/emilk/egui" }
|
||||
egui = { git = "https://github.com/flukejones/egui" }
|
||||
eframe= { git = "https://github.com/flukejones/egui" }
|
||||
#eframe= { git = "https://github.com/emilk/egui", default-features = false, features = ["dark-light", "default_fonts", "wgpu"] }
|
||||
|
||||
daemon = { path = "../daemon" }
|
||||
|
||||
@@ -103,7 +103,7 @@ impl<'a> RogApp<'a> {
|
||||
}
|
||||
|
||||
impl<'a> eframe::App for RogApp<'a> {
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Called each time the UI needs repainting, which may be many times per second.
|
||||
/// Put your widgets into a `SidePanel`, `TopPanel`, `CentralPanel`, `Window` or `Area`.
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
let Self {
|
||||
|
||||
@@ -10,6 +10,7 @@ pub enum Error {
|
||||
ConfigLockFail,
|
||||
XdgVars,
|
||||
Zbus(zbus::Error),
|
||||
Notification(notify_rust::error::Error)
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
@@ -22,6 +23,7 @@ impl fmt::Display for Error {
|
||||
Error::ConfigLockFail => write!(f, "Failed to lock user config"),
|
||||
Error::XdgVars => write!(f, "XDG environment vars appear unset"),
|
||||
Error::Zbus(err) => write!(f, "Error: {}", err),
|
||||
Error::Notification(err) => write!(f, "Notification Error: {}", err),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,3 +47,9 @@ impl From<zbus::Error> for Error {
|
||||
Error::Zbus(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<notify_rust::error::Error> for Error {
|
||||
fn from(err: notify_rust::error::Error) -> Self {
|
||||
Error::Notification(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn on_tmp_dir_exists() -> Result<TempDir, std::io::Error> {
|
||||
// If the app is running this ends up stacked on top of SHOWING_GUI
|
||||
ipc_file.write_all(&[SHOW_GUI])?;
|
||||
// tiny sleep to give the app a chance to respond
|
||||
sleep(Duration::from_millis(10));
|
||||
sleep(Duration::from_millis(100));
|
||||
ipc_file.read(&mut buf).ok();
|
||||
|
||||
// First entry is the actual state
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
use eframe::NativeOptions;
|
||||
use rog_aura::layouts::KeyLayout;
|
||||
use rog_control_center::{
|
||||
error::Result,
|
||||
config::Config, get_ipc_file, notify::start_notifications, on_tmp_dir_exists,
|
||||
page_states::PageDataStates, print_versions, startup_error::AppErrorShow, RogApp,
|
||||
RogDbusClientBlocking, SHOWING_GUI, SHOW_GUI,
|
||||
};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
|
||||
use std::{
|
||||
fs::OpenOptions,
|
||||
@@ -18,12 +21,12 @@ const DATA_DIR: &str = "/usr/share/rog-gui/";
|
||||
const DATA_DIR: &str = env!("CARGO_MANIFEST_DIR");
|
||||
const BOARD_NAME: &str = "/sys/class/dmi/id/board_name";
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
fn main() -> Result<()> {
|
||||
print_versions();
|
||||
|
||||
let native_options = eframe::NativeOptions {
|
||||
vsync: false,
|
||||
decorated: false,
|
||||
vsync: true,
|
||||
decorated: true,
|
||||
transparent: false,
|
||||
min_window_size: Some(egui::vec2(840.0, 600.0)),
|
||||
max_window_size: Some(egui::vec2(840.0, 600.0)),
|
||||
@@ -75,6 +78,51 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
})
|
||||
.unwrap_or_else(|_| KeyLayout::ga401_layout());
|
||||
|
||||
// tmp-dir must live to the end of program life
|
||||
let _tmp_dir = match tempfile::Builder::new()
|
||||
.prefix("rog-gui")
|
||||
.rand_bytes(0)
|
||||
.tempdir()
|
||||
{
|
||||
Ok(tmp) => tmp,
|
||||
Err(_) => on_tmp_dir_exists().unwrap(),
|
||||
};
|
||||
|
||||
let states = setup_page_state_and_notifs(layout.clone(), &config, native_options.clone(), &dbus).unwrap();
|
||||
|
||||
loop {
|
||||
dbg!();
|
||||
if !start_closed {
|
||||
start_app(states.clone(), native_options.clone())?;
|
||||
}
|
||||
dbg!();
|
||||
|
||||
let config = Config::load().unwrap();
|
||||
if !config.run_in_background {
|
||||
break;
|
||||
}
|
||||
|
||||
if config.run_in_background {
|
||||
let mut buf = [0u8; 4];
|
||||
// blocks until it is read, typically the read will happen after a second
|
||||
// process writes to the IPC (so there is data to actually read)
|
||||
if get_ipc_file().unwrap().read(&mut buf).is_ok() && buf[0] == SHOW_GUI {
|
||||
start_closed = false;
|
||||
dbg!();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
dbg!();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn setup_page_state_and_notifs(
|
||||
keyboard_layout: KeyLayout,
|
||||
config: &Config,
|
||||
native_options: NativeOptions,
|
||||
dbus: &RogDbusClientBlocking,
|
||||
) -> Result<PageDataStates> {
|
||||
// Cheap method to alert to notifications rather than spinning a thread for each
|
||||
// This is quite different when done in a retained mode app
|
||||
let charge_notified = Arc::new(AtomicBool::new(false));
|
||||
@@ -95,68 +143,42 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
notifs_enabled.clone(),
|
||||
)?;
|
||||
|
||||
// tmp-dir must live to the end of program life
|
||||
let _tmp_dir = match tempfile::Builder::new()
|
||||
.prefix("rog-gui")
|
||||
.rand_bytes(0)
|
||||
.tempdir()
|
||||
{
|
||||
Ok(tmp) => tmp,
|
||||
Err(_) => on_tmp_dir_exists().unwrap(),
|
||||
};
|
||||
|
||||
loop {
|
||||
let states = {
|
||||
let supported = match dbus.proxies().supported().supported_functions() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
eframe::run_native(
|
||||
"ROG Control Center",
|
||||
native_options.clone(),
|
||||
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
|
||||
);
|
||||
return Ok(());
|
||||
}
|
||||
};
|
||||
|
||||
PageDataStates::new(
|
||||
layout.clone(),
|
||||
notifs_enabled.clone(),
|
||||
charge_notified.clone(),
|
||||
bios_notified.clone(),
|
||||
aura_notified.clone(),
|
||||
anime_notified.clone(),
|
||||
profiles_notified.clone(),
|
||||
fans_notified.clone(),
|
||||
&supported,
|
||||
&dbus,
|
||||
)?
|
||||
};
|
||||
|
||||
if !start_closed {
|
||||
let mut ipc_file = get_ipc_file().unwrap();
|
||||
ipc_file.write_all(&[SHOWING_GUI]).unwrap();
|
||||
let supported = match dbus.proxies().supported().supported_functions() {
|
||||
Ok(s) => s,
|
||||
Err(e) => {
|
||||
eframe::run_native(
|
||||
"ROG Control Center",
|
||||
native_options.clone(),
|
||||
Box::new(move |cc| {
|
||||
Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap())
|
||||
}),
|
||||
native_options,
|
||||
Box::new(move |_| Box::new(AppErrorShow::new(e.to_string()))),
|
||||
);
|
||||
SupportedFunctions::default()
|
||||
}
|
||||
};
|
||||
|
||||
let config = Config::load().unwrap();
|
||||
if !config.run_in_background {
|
||||
break;
|
||||
}
|
||||
PageDataStates::new(
|
||||
keyboard_layout,
|
||||
notifs_enabled.clone(),
|
||||
charge_notified.clone(),
|
||||
bios_notified.clone(),
|
||||
aura_notified.clone(),
|
||||
anime_notified.clone(),
|
||||
profiles_notified.clone(),
|
||||
fans_notified.clone(),
|
||||
&supported,
|
||||
&dbus,
|
||||
)
|
||||
}
|
||||
|
||||
let mut buf = [0u8; 4];
|
||||
// blocks until it is read, typically the read will happen after a second
|
||||
// process writes to the IPC (so there is data to actually read)
|
||||
if get_ipc_file().unwrap().read(&mut buf).is_ok() && buf[0] == SHOW_GUI {
|
||||
start_closed = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fn start_app(
|
||||
states: PageDataStates,
|
||||
native_options: NativeOptions,
|
||||
) -> Result<()> {
|
||||
let mut ipc_file = get_ipc_file().unwrap();
|
||||
ipc_file.write_all(&[SHOWING_GUI]).unwrap();
|
||||
eframe::run_native(
|
||||
"ROG Control Center",
|
||||
native_options,
|
||||
Box::new(move |cc| Box::new(RogApp::new(Config::load().unwrap(), states, cc).unwrap())),
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ use std::{
|
||||
};
|
||||
use supergfxctl::pci_device::GfxPower;
|
||||
use zbus::export::futures_util::StreamExt;
|
||||
use crate::error::Result;
|
||||
|
||||
const NOTIF_HEADER: &str = "ROG Control";
|
||||
|
||||
@@ -76,7 +77,7 @@ pub fn start_notifications(
|
||||
profiles_notified: Arc<AtomicBool>,
|
||||
_fans_notified: Arc<AtomicBool>,
|
||||
notifs_enabled: Arc<AtomicBool>,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
) -> Result<()> {
|
||||
let last_notification: SharedHandle = Arc::new(Mutex::new(None));
|
||||
|
||||
let executor = Executor::new();
|
||||
@@ -101,7 +102,7 @@ pub fn start_notifications(
|
||||
last_notification,
|
||||
notifs_enabled,
|
||||
[overdrive],
|
||||
"BIOS Panel Overdrive",
|
||||
"Panel Overdrive enabled:",
|
||||
do_notification
|
||||
);
|
||||
|
||||
@@ -154,6 +155,18 @@ pub fn start_notifications(
|
||||
do_notification
|
||||
);
|
||||
|
||||
recv_notif!(
|
||||
executor,
|
||||
PowerProxy,
|
||||
receive_notify_mains_online,
|
||||
bios_notified,
|
||||
last_notification,
|
||||
notifs_enabled,
|
||||
[on],
|
||||
"AC Power power is",
|
||||
ac_power_notification
|
||||
);
|
||||
|
||||
// Profile notif
|
||||
recv_notif!(
|
||||
executor,
|
||||
@@ -261,7 +274,7 @@ where
|
||||
.summary(NOTIF_HEADER)
|
||||
.body(&format!("{message} {data}"))
|
||||
.timeout(2000)
|
||||
.hint(Hint::Resident(true))
|
||||
//.hint(Hint::Resident(true))
|
||||
.hint(Hint::Category("device".into()));
|
||||
|
||||
notif
|
||||
@@ -270,17 +283,25 @@ where
|
||||
fn do_notification<T>(
|
||||
message: &str,
|
||||
data: &T,
|
||||
) -> Result<NotificationHandle, notify_rust::error::Error>
|
||||
) -> Result<NotificationHandle>
|
||||
where
|
||||
T: Display,
|
||||
{
|
||||
base_notification(message, data).show()
|
||||
Ok(base_notification(message, data).show()?)
|
||||
}
|
||||
|
||||
fn ac_power_notification(
|
||||
message: &str,
|
||||
on: &bool,
|
||||
) -> Result<NotificationHandle> {
|
||||
let data = if *on { "plugged".to_string() } else { "unplugged".to_string() };
|
||||
Ok(base_notification(message, &data).show()?)
|
||||
}
|
||||
|
||||
fn do_thermal_notif(
|
||||
message: &str,
|
||||
profile: &Profile,
|
||||
) -> Result<NotificationHandle, notify_rust::error::Error> {
|
||||
) -> Result<NotificationHandle> {
|
||||
let icon = match profile {
|
||||
Profile::Balanced => "asus_notif_yellow",
|
||||
Profile::Performance => "asus_notif_red",
|
||||
@@ -288,5 +309,5 @@ fn do_thermal_notif(
|
||||
};
|
||||
let profile: &str = (*profile).into();
|
||||
let mut notif = base_notification(message, &profile.to_uppercase());
|
||||
notif.icon(icon).show()
|
||||
Ok(notif.icon(icon).show()?)
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ impl AnimeState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PageDataStates {
|
||||
pub keyboard_layout: KeyLayout,
|
||||
pub notifs_enabled: Arc<AtomicBool>,
|
||||
|
||||
@@ -16,7 +16,7 @@ impl<'a> RogApp<'a> {
|
||||
} = self;
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Experimental application for asusd");
|
||||
ui.heading("Base settings");
|
||||
|
||||
egui::ScrollArea::vertical().show(ui, |ui| {
|
||||
ui.spacing_mut().item_spacing = egui::vec2(8.0, 10.0);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use egui::{vec2, Align2, Button, FontId, Id, Rect, RichText, Sense, Vec2};
|
||||
use egui::{vec2, Align2, FontId, Id, Sense};
|
||||
|
||||
use crate::{RogApp, VERSION};
|
||||
|
||||
@@ -27,20 +27,20 @@ impl<'a> RogApp<'a> {
|
||||
let height = titlebar_rect.height();
|
||||
// Paint the title:
|
||||
ui.painter().text(
|
||||
titlebar_rect.center_top() + vec2(0.0, height / 2.0),
|
||||
Align2::CENTER_CENTER,
|
||||
format!("ROG Control Center v{}", VERSION),
|
||||
titlebar_rect.right_top() + vec2(0.0, height / 2.0),
|
||||
Align2::RIGHT_CENTER,
|
||||
format!("v{}", VERSION),
|
||||
FontId::proportional(height - 2.0),
|
||||
text_color,
|
||||
);
|
||||
// Add the close button:
|
||||
let close_response = ui.put(
|
||||
Rect::from_min_size(titlebar_rect.right_top(), Vec2::splat(height)),
|
||||
Button::new(RichText::new("❌").size(height - 4.0)).frame(false),
|
||||
);
|
||||
if close_response.clicked() {
|
||||
frame.close();
|
||||
}
|
||||
// // Add the close button:
|
||||
// let close_response = ui.put(
|
||||
// Rect::from_min_size(titlebar_rect.right_top(), Vec2::splat(height)),
|
||||
// Button::new(RichText::new("❌").size(height - 4.0)).frame(false),
|
||||
// );
|
||||
// if close_response.clicked() {
|
||||
// frame.close();
|
||||
// }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user