mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: add support for disabling overdrive
This commit is contained in:
parent
422343315d
commit
292c94a9c4
@ -130,6 +130,7 @@ impl DaemonClient {
|
||||
|
||||
request_plain!(get_system_info, SystemInfo, SystemInfo);
|
||||
request_plain!(enable_overdrive, EnableOverdrive, String);
|
||||
request_plain!(disable_overdrive, DisableOverdrive, String);
|
||||
request_plain!(generate_debug_snapshot, GenerateSnapshot, String);
|
||||
request_with_id!(get_device_info, DeviceInfo, DeviceInfo);
|
||||
request_with_id!(get_device_stats, DeviceStats, DeviceStats);
|
||||
|
@ -118,6 +118,7 @@ async fn handle_request<'a>(request: Request<'a>, handler: &'a Handler) -> anyho
|
||||
ok_response(handler.set_enabled_power_states(id, kind, states).await?)
|
||||
}
|
||||
Request::EnableOverdrive => ok_response(system::enable_overdrive()?),
|
||||
Request::DisableOverdrive => ok_response(system::disable_overdrive()?),
|
||||
Request::GenerateSnapshot => ok_response(handler.generate_snapshot()?),
|
||||
Request::ConfirmPendingConfig(command) => {
|
||||
ok_response(handler.confirm_pending_config(command)?)
|
||||
|
@ -5,6 +5,7 @@ use std::{
|
||||
fs::{self, File, Permissions},
|
||||
io::Write,
|
||||
os::unix::prelude::PermissionsExt,
|
||||
path::Path,
|
||||
process::Command,
|
||||
};
|
||||
use tracing::{info, warn};
|
||||
@ -70,6 +71,22 @@ pub fn enable_overdrive() -> anyhow::Result<String> {
|
||||
Ok(message)
|
||||
}
|
||||
|
||||
pub fn disable_overdrive() -> anyhow::Result<String> {
|
||||
if Path::new(MODULE_CONF_PATH).exists() {
|
||||
fs::remove_file(MODULE_CONF_PATH).context("Could not remove module config file")?;
|
||||
match regenerate_initramfs() {
|
||||
Ok(initramfs_type) => Ok(format!(
|
||||
"Initramfs was successfully regenerated (detected type {initramfs_type:?})"
|
||||
)),
|
||||
Err(err) => Ok(format!("{err:#}")),
|
||||
}
|
||||
} else {
|
||||
Err(anyhow!(
|
||||
"Overclocking was not enabled through LACT (file at {MODULE_CONF_PATH} does not exist)"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn read_current_mask() -> anyhow::Result<u64> {
|
||||
let ppfeaturemask = fs::read_to_string(PP_FEATURE_MASK_PATH)?;
|
||||
let ppfeaturemask = ppfeaturemask
|
||||
|
@ -1,6 +1,6 @@
|
||||
use gtk::prelude::*;
|
||||
use gtk::*;
|
||||
use lact_client::schema::DeviceListEntry;
|
||||
use lact_client::schema::{DeviceListEntry, SystemInfo};
|
||||
use pango::EllipsizeMode;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -11,7 +11,7 @@ pub struct Header {
|
||||
}
|
||||
|
||||
impl Header {
|
||||
pub fn new() -> Self {
|
||||
pub fn new(system_info: &SystemInfo) -> Self {
|
||||
let container = HeaderBar::new();
|
||||
container.set_show_title_buttons(true);
|
||||
|
||||
@ -27,6 +27,13 @@ impl Header {
|
||||
Some("app.generate-debug-snapshot"),
|
||||
);
|
||||
|
||||
if system_info.amdgpu_overdrive_enabled == Some(true) {
|
||||
menu.append(
|
||||
Some("Disable overclocking support"),
|
||||
Some("app.disable-overdrive"),
|
||||
)
|
||||
}
|
||||
|
||||
let menu_button = MenuButton::builder()
|
||||
.icon_name("open-menu-symbolic")
|
||||
.menu_model(&menu)
|
||||
|
@ -43,7 +43,12 @@ impl App {
|
||||
#[cfg(not(feature = "adw"))]
|
||||
let application = Application::new(Some(APP_ID), ApplicationFlags::default());
|
||||
|
||||
let header = Header::new();
|
||||
let system_info_buf = daemon_client
|
||||
.get_system_info()
|
||||
.expect("Could not fetch system info");
|
||||
let system_info = system_info_buf.inner().expect("Invalid system info buffer");
|
||||
|
||||
let header = Header::new(&system_info);
|
||||
let window = ApplicationWindow::builder()
|
||||
.title("LACT")
|
||||
.default_width(600)
|
||||
@ -51,18 +56,13 @@ impl App {
|
||||
.icon_name(APP_ID)
|
||||
.build();
|
||||
|
||||
window.set_titlebar(Some(&header.container));
|
||||
|
||||
let system_info_buf = daemon_client
|
||||
.get_system_info()
|
||||
.expect("Could not fetch system info");
|
||||
let system_info = system_info_buf.inner().expect("Invalid system info buffer");
|
||||
|
||||
if system_info.version != GUI_VERSION {
|
||||
let err = anyhow!("Version mismatch between GUI and daemon ({GUI_VERSION} vs {})! Make sure you have restarted the service if you have updated LACT.", system_info.version);
|
||||
show_error(&window, err);
|
||||
}
|
||||
|
||||
window.set_titlebar(Some(&header.container));
|
||||
|
||||
let root_stack = RootStack::new(system_info, daemon_client.embedded);
|
||||
|
||||
header.set_switcher_stack(&root_stack.container);
|
||||
@ -173,7 +173,13 @@ impl App {
|
||||
}))
|
||||
.build();
|
||||
|
||||
app.application.add_action_entries([snapshot_action]);
|
||||
let disable_overdive_action = ActionEntry::builder("disable-overdrive")
|
||||
.activate(clone!(@strong app => move |_, _, _| {
|
||||
app.disable_overclocking()
|
||||
}))
|
||||
.build();
|
||||
|
||||
app.application.add_action_entries([snapshot_action, disable_overdive_action]);
|
||||
|
||||
app.start_stats_update_loop(current_gpu_id);
|
||||
|
||||
@ -557,6 +563,37 @@ impl App {
|
||||
}));
|
||||
}
|
||||
|
||||
fn disable_overclocking(&self) {
|
||||
let dialog = MessageDialog::builder()
|
||||
.title("Disable Overclocking")
|
||||
.use_markup(true)
|
||||
.text("The overclocking functionality in the driver will now be turned off. (Note: the LACT window might hang)")
|
||||
.message_type(MessageType::Info)
|
||||
.buttons(ButtonsType::Ok)
|
||||
.transient_for(&self.window)
|
||||
.build();
|
||||
|
||||
dialog.run_async(clone!(@strong self as app => move |diag, _| {
|
||||
diag.hide();
|
||||
match app.daemon_client.disable_overdrive().and_then(|buffer| buffer.inner()) {
|
||||
Ok(msg) => {
|
||||
let success_dialog = MessageDialog::builder()
|
||||
.title("Success")
|
||||
.text(format!("Overclocking successfully disabled. A system reboot is required to apply the changes.\nSystem message: {msg}"))
|
||||
.message_type(MessageType::Info)
|
||||
.buttons(ButtonsType::Ok)
|
||||
.build();
|
||||
success_dialog.run_async(move |diag, _| {
|
||||
diag.hide();
|
||||
});
|
||||
}
|
||||
Err(err) => {
|
||||
show_error(&app.window, err);
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
fn ask_confirmation(&self, gpu_id: String, mut delay: u64) {
|
||||
let text = confirmation_text(delay);
|
||||
let dialog = MessageDialog::builder()
|
||||
|
@ -61,6 +61,7 @@ pub enum Request<'a> {
|
||||
states: Vec<u8>,
|
||||
},
|
||||
EnableOverdrive,
|
||||
DisableOverdrive,
|
||||
GenerateSnapshot,
|
||||
ConfirmPendingConfig(ConfirmCommand),
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user