mirror of
https://github.com/narrrl/proton-drive-linux.git
synced 2026-11-04 16:56:59 +01:00
updated ux
This commit is contained in:
1 parent
99e80a7206
commit
8e8d42ad3b
4 files changed
+253
-39
No files matched your search
@@ -57,9 +57,10 @@ impl AppDirs {
|
||||
let path = self.config_path();
|
||||
if path.exists()
|
||||
&& let Ok(content) = std::fs::read_to_string(&path)
|
||||
&& let Ok(config) = serde_json::from_str::<AppConfig>(&content) {
|
||||
return config;
|
||||
}
|
||||
&& let Ok(config) = serde_json::from_str::<AppConfig>(&content)
|
||||
{
|
||||
return config;
|
||||
}
|
||||
|
||||
let default_config = AppConfig::default();
|
||||
if let Ok(content) = serde_json::to_string_pretty(&default_config) {
|
||||
|
||||
@@ -32,6 +32,21 @@ fn systemctl(args: &[&str]) -> bool {
|
||||
ok
|
||||
}
|
||||
|
||||
/// Like [`systemctl`] but treats a non-zero exit as a plain `false` answer
|
||||
/// rather than a failure to log. For query verbs (`is-active`, `is-failed`)
|
||||
/// where "no" is the normal, expected result.
|
||||
fn systemctl_query(args: &[&str]) -> bool {
|
||||
Command::new("systemctl")
|
||||
.arg("--user")
|
||||
.args(args)
|
||||
.arg(SERVICE)
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.status()
|
||||
.map(|s| s.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
/// Enable the service so it survives reboots/logins and start it now. Called on
|
||||
/// successful login.
|
||||
pub fn enable_start() -> bool {
|
||||
@@ -44,6 +59,26 @@ pub fn stop() -> bool {
|
||||
systemctl(&["stop"])
|
||||
}
|
||||
|
||||
/// Restart the unit now. Used by a front-end "Retry" action when the mount has
|
||||
/// failed and the user wants to bring it back without re-logging-in.
|
||||
pub fn restart() -> bool {
|
||||
systemctl(&["restart"])
|
||||
}
|
||||
|
||||
/// Whether the unit currently reports `active` (running, or starting up).
|
||||
/// `systemctl is-active` exits 0 only while the unit is active, so a front-end
|
||||
/// can use this to tell "service still coming up" from "service is down".
|
||||
pub fn is_active() -> bool {
|
||||
systemctl_query(&["is-active"])
|
||||
}
|
||||
|
||||
/// Whether the unit is in the `failed` state. `systemctl is-failed` exits 0
|
||||
/// only when the unit has failed, letting a front-end show an actionable error
|
||||
/// (with Retry) rather than an indefinite "connecting…" spinner.
|
||||
pub fn is_failed() -> bool {
|
||||
systemctl_query(&["is-failed"])
|
||||
}
|
||||
|
||||
/// Disable the service so it no longer auto-starts, and stop it now. Called on
|
||||
/// logout.
|
||||
pub fn disable_stop() -> bool {
|
||||
|
||||
Reference in new issue
Block a user