chore: print error info about failed daemon connection

This commit is contained in:
Ilya Zlobintsev
2023-11-25 15:35:07 +02:00
parent 2009007c6b
commit 030e827378
10 changed files with 33 additions and 28 deletions

16
Cargo.lock generated
View File

@@ -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",
]

View File

@@ -1,6 +1,6 @@
[package]
name = "lact-cli"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
[dependencies]

View File

@@ -1,6 +1,6 @@
[package]
name = "lact-client"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
[dependencies]

View File

@@ -1,6 +1,6 @@
[package]
name = "lact-daemon"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
[features]

View File

@@ -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"

View File

@@ -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)

View File

@@ -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)))
}
}
}

View File

@@ -1,6 +1,6 @@
[package]
name = "lact-schema"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
[features]

View File

@@ -1,6 +1,6 @@
[package]
name = "lact"
version = "0.5.0"
version = "0.5.1"
edition = "2021"
[features]

View File

@@ -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: