mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
chore: print error info about failed daemon connection
This commit is contained in:
16
Cargo.lock
generated
16
Cargo.lock
generated
@@ -1156,6 +1156,7 @@ checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown 0.12.3",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1166,7 +1167,6 @@ checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown 0.14.2",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1197,7 +1197,7 @@ checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
|
||||
|
||||
[[package]]
|
||||
name = "lact"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lact-cli",
|
||||
@@ -1208,7 +1208,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lact-cli"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lact-client",
|
||||
@@ -1217,7 +1217,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lact-client"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"lact-schema",
|
||||
@@ -1229,7 +1229,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lact-daemon"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bincode",
|
||||
@@ -1251,7 +1251,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lact-gui"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"gtk4",
|
||||
@@ -1264,11 +1264,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lact-schema"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"amdgpu-sysfs",
|
||||
"clap",
|
||||
"indexmap 2.1.0",
|
||||
"indexmap 1.9.3",
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact-cli"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact-client"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact-daemon"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact-gui"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
authors = ["Ilya Zlobintsev <ilya.zl@protonmail.com>"]
|
||||
edition = "2021"
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(self) -> anyhow::Result<()> {
|
||||
pub fn run(self, connection_err: Option<anyhow::Error>) -> anyhow::Result<()> {
|
||||
self.application
|
||||
.connect_activate(clone!(@strong self as app => move |_| {
|
||||
app.window.set_application(Some(&app.application));
|
||||
@@ -151,13 +151,17 @@ impl App {
|
||||
app.window.show();
|
||||
|
||||
if app.daemon_client.embedded {
|
||||
let text = "Could not connect to daemon, running in embedded mode. \n\
|
||||
Please make sure the lactd service is running. \n\
|
||||
Using embedded mode, you will not be able to change any settings. \n\
|
||||
\n\
|
||||
To enable the daemon, run the following command:";
|
||||
let error_text = connection_err.as_ref().map(|err| {
|
||||
format!("Error info: {err:#}\n\n")
|
||||
}).unwrap_or_default();
|
||||
|
||||
let text_label = Label::new(Some(text));
|
||||
let text = format!("Could not connect to daemon, running in embedded mode. \n\
|
||||
Please make sure the lactd service is running. \n\
|
||||
Using embedded mode, you will not be able to change any settings. \n\n\
|
||||
{error_text}\
|
||||
To enable the daemon, run the following command:");
|
||||
|
||||
let text_label = Label::new(Some(&text));
|
||||
let enable_label = Entry::builder()
|
||||
.text("sudo systemctl enable --now lactd")
|
||||
.editable(false)
|
||||
|
||||
@@ -21,17 +21,17 @@ pub fn run(args: GuiArgs) -> anyhow::Result<()> {
|
||||
return Err(anyhow!("Cannot initialize GTK: {err}"));
|
||||
}
|
||||
|
||||
let connection = create_connection()?;
|
||||
let (connection, connection_err) = create_connection()?;
|
||||
let app = App::new(connection);
|
||||
|
||||
app.run()
|
||||
app.run(connection_err)
|
||||
}
|
||||
|
||||
fn create_connection() -> anyhow::Result<DaemonClient> {
|
||||
fn create_connection() -> anyhow::Result<(DaemonClient, Option<anyhow::Error>)> {
|
||||
match DaemonClient::connect() {
|
||||
Ok(connection) => Ok(connection),
|
||||
Ok(connection) => Ok((connection, None)),
|
||||
Err(err) => {
|
||||
info!("could not connect to socket: {err}");
|
||||
info!("could not connect to socket: {err:#}");
|
||||
info!("using a local daemon");
|
||||
|
||||
let (server_stream, client_stream) = UnixStream::pair()?;
|
||||
@@ -42,7 +42,8 @@ fn create_connection() -> anyhow::Result<DaemonClient> {
|
||||
}
|
||||
});
|
||||
|
||||
DaemonClient::from_stream(client_stream, true)
|
||||
let client = DaemonClient::from_stream(client_stream, true)?;
|
||||
Ok((client, Some(err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact-schema"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "lact"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2021"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -3,7 +3,7 @@ metadata:
|
||||
description: AMDGPU control utility
|
||||
arch: x86_64
|
||||
license: MIT
|
||||
version: 0.5.0
|
||||
version: 0.5.1
|
||||
maintainer: ilya-zlobintsev
|
||||
url: https://github.com/ilya-zlobintsev/lact
|
||||
source:
|
||||
|
||||
Reference in New Issue
Block a user