summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMica White <botahamec@outlook.com>2026-09-05 21:10:34 -0400
committerMica White <botahamec@outlook.com>2026-09-05 21:10:34 -0400
commitdca1f88823691c6f86ce7141b2eb0c8c88f62cd8 (patch)
tree2d3f6153818a3420c9131cf710b6ec1cedec5eb4
parent1897aa4c604a0d9ab81f84dbff687b7f42bc1f0f (diff)
Reduce battery consumption when offline
-rw-r--r--Cargo.toml6
-rw-r--r--scripts/git-autosave.service2
-rw-r--r--src/bin/git-autosave-daemon.rs4
3 files changed, 9 insertions, 3 deletions
diff --git a/Cargo.toml b/Cargo.toml
index eba9476..c283e8a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,3 +21,9 @@ hostname = "0.4"
inquire = "0.9"
auth-git2 = "0.6"
ping = "0.7"
+
+[profile.release]
+opt-level = 3
+strip = false
+panic = "abort"
+lto = true
diff --git a/scripts/git-autosave.service b/scripts/git-autosave.service
index 926859f..20cca4d 100644
--- a/scripts/git-autosave.service
+++ b/scripts/git-autosave.service
@@ -7,7 +7,7 @@ Type=exec
SyslogIdentifier=git-autosave
Restart=always
-ExecStart=/usr/bin/git autosave-daemon
+ExecStart=/usr/bin/env git-autosave-daemon
[Install]
WantedBy=default.target
diff --git a/src/bin/git-autosave-daemon.rs b/src/bin/git-autosave-daemon.rs
index d9af1e5..fa6725e 100644
--- a/src/bin/git-autosave-daemon.rs
+++ b/src/bin/git-autosave-daemon.rs
@@ -31,7 +31,7 @@ fn push_queue(
loop {
while ping::new("8.8.8.8".parse().unwrap())
.socket_type(ping::SocketType::DGRAM)
- .timeout(Duration::from_secs(60))
+ .timeout(Duration::from_secs(5))
.ttl(128)
.send()
.is_err()
@@ -46,7 +46,7 @@ fn push_queue(
"There is no Internet connection, so pushes to the repository have been queued"
);
}
- std::thread::yield_now();
+ std::thread::sleep(Duration::from_secs(60));
}
while let Ok(workdir) = consumer.try_recv() {