aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock62
-rw-r--r--Cargo.toml1
-rw-r--r--src/utils.rs32
3 files changed, 22 insertions, 73 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 043d3a1f..45e0599d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -697,15 +697,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "740bb192a8e2d1350119916954f4409ee7f62f149b536911eeb78ba5a20526bf"
[[package]]
-name = "deranged"
-version = "0.3.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f32d04922c60427da6f9fef14d042d9edddef64cb9d4ce0d64d0685fbeb1fd3"
-dependencies = [
- "powerfmt",
-]
-
-[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1171,12 +1162,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c"
[[package]]
-name = "itoa"
-version = "1.0.9"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38"
-
-[[package]]
name = "jni"
version = "0.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1548,7 +1533,6 @@ dependencies = [
"serde",
"smithay",
"smithay-drm-extras",
- "time",
"tracing",
"tracing-subscriber",
"tracy-client",
@@ -1632,15 +1616,6 @@ dependencies = [
]
[[package]]
-name = "num_threads"
-version = "0.1.6"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
-dependencies = [
- "libc",
-]
-
-[[package]]
name = "objc-sys"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1824,12 +1799,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b559898e0b4931ed2d3b959ab0c2da4d99cc644c4b0b1a35b4d344027f474023"
[[package]]
-name = "powerfmt"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391"
-
-[[package]]
name = "ppv-lite86"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2448,37 +2417,6 @@ dependencies = [
]
[[package]]
-name = "time"
-version = "0.3.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c4a34ab300f2dee6e562c10a046fc05e358b29f9bf92277f30c3c8d82275f6f5"
-dependencies = [
- "deranged",
- "itoa",
- "libc",
- "num_threads",
- "powerfmt",
- "serde",
- "time-core",
- "time-macros",
-]
-
-[[package]]
-name = "time-core"
-version = "0.1.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3"
-
-[[package]]
-name = "time-macros"
-version = "0.2.15"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4ad70d68dba9e1f8aceda7aa6711965dfec1cac869f311a51bd08b3a2ccbce20"
-dependencies = [
- "time-core",
-]
-
-[[package]]
name = "toml"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index a3704ed6..1f228785 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -26,7 +26,6 @@ portable-atomic = { version = "1.5.0", default-features = false, features = ["fl
profiling = "1.0.11"
sd-notify = "0.4.1"
serde = { version = "1.0.189", features = ["derive"] }
-time = { version = "0.3.30", features = ["formatting", "local-offset", "macros"] }
tracing-subscriber = { version = "0.3.17", features = ["env-filter"] }
tracing = { version = "0.1.40", features = ["max_level_trace", "release_max_level_debug"] }
tracy-client = { version = "0.16.3", default-features = false }
diff --git a/src/utils.rs b/src/utils.rs
index 80f5a0a1..134112dc 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,15 +1,16 @@
use std::ffi::OsStr;
use std::io::{self, Write};
+use std::os::unix::prelude::OsStrExt;
use std::os::unix::process::CommandExt;
use std::path::PathBuf;
use std::process::{Command, Stdio};
+use std::ptr::null_mut;
use std::time::Duration;
-use anyhow::Context;
+use anyhow::{ensure, Context};
use directories::UserDirs;
use smithay::reexports::rustix::time::{clock_gettime, ClockId};
use smithay::utils::{Logical, Point, Rectangle};
-use time::OffsetDateTime;
pub fn get_monotonic_time() -> Duration {
let ts = clock_gettime(ClockId::Monotonic);
@@ -29,16 +30,27 @@ pub fn make_screenshot_path() -> anyhow::Result<PathBuf> {
});
path.push("Screenshots");
+ let mut buf = [0u8; 256];
+ let name;
unsafe {
- // are you kidding me
- time::util::local_offset::set_soundness(time::util::local_offset::Soundness::Unsound);
- };
+ let time = libc::time(null_mut());
+ ensure!(time != -1, "error in time()");
+
+ let tm = libc::localtime(&time);
+ ensure!(!tm.is_null(), "error in localtime()");
+
+ let format = b"Screenshot from %Y-%m-%d %H-%M-%S.png\0";
+ let rv = libc::strftime(
+ buf.as_mut_ptr().cast(),
+ buf.len(),
+ format.as_ptr().cast(),
+ tm,
+ );
+ ensure!(rv != 0, "error formatting time");
+
+ name = OsStr::from_bytes(&buf[..rv]);
+ }
- let now = OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc());
- let desc = time::macros::format_description!(
- "Screenshot from [year]-[month]-[day] [hour]-[minute]-[second].png"
- );
- let name = now.format(desc).context("error formatting time")?;
path.push(name);
Ok(path)