~whynothugo/shotman

699ddce56a4ef3c3c031f1ca522d099baa98d109 — Hugo Osvaldo Barrera 1 year, 3 months ago 220603d
Replace 'chrono' with 'time'

This trims the dependency tree a bit and yields the same results. This
might break targets like Android, but that's really not in scope for a
Wayland-specific tool.
3 files changed, 49 insertions(+), 215 deletions(-)

M Cargo.lock
M Cargo.toml
M src/main.rs
M Cargo.lock => Cargo.lock +32 -208
@@ 9,15 9,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"

[[package]]
name = "android_system_properties"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311"
dependencies = [
 "libc",
]

[[package]]
name = "anyhow"
version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 47,12 38,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"

[[package]]
name = "bumpalo"
version = "3.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba"

[[package]]
name = "calloop"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 79,18 64,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"

[[package]]
name = "chrono"
version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
dependencies = [
 "iana-time-zone",
 "num-integer",
 "num-traits",
 "winapi",
]

[[package]]
name = "clap"
version = "4.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 137,16 110,6 @@ dependencies = [
]

[[package]]
name = "codespan-reporting"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e"
dependencies = [
 "termcolor",
 "unicode-width",
]

[[package]]
name = "colored"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 158,12 121,6 @@ dependencies = [
]

[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"

[[package]]
name = "crc32fast"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 173,50 130,6 @@ dependencies = [
]

[[package]]
name = "cxx"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d1075c37807dcf850c379432f0df05ba52cc30f279c5cfc43cc221ce7f8579"
dependencies = [
 "cc",
 "cxxbridge-flags",
 "cxxbridge-macro",
 "link-cplusplus",
]

[[package]]
name = "cxx-build"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5044281f61b27bc598f2f6647d480aed48d2bf52d6eb0b627d84c0361b17aa70"
dependencies = [
 "cc",
 "codespan-reporting",
 "once_cell",
 "proc-macro2",
 "quote",
 "scratch",
 "syn",
]

[[package]]
name = "cxxbridge-flags"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "61b50bc93ba22c27b0d31128d2d130a0a6b3d267ae27ef7e4fae2167dfe8781c"

[[package]]
name = "cxxbridge-macro"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39e61fda7e62115119469c7b3591fd913ecca96fb766cfd3f2e2502ab7bc87a5"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
]

[[package]]
name = "dlib"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 358,30 271,6 @@ dependencies = [
]

[[package]]
name = "iana-time-zone"
version = "0.1.53"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765"
dependencies = [
 "android_system_properties",
 "core-foundation-sys",
 "iana-time-zone-haiku",
 "js-sys",
 "wasm-bindgen",
 "winapi",
]

[[package]]
name = "iana-time-zone-haiku"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca"
dependencies = [
 "cxx",
 "cxx-build",
]

[[package]]
name = "io-lifetimes"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 419,15 308,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"

[[package]]
name = "js-sys"
version = "0.3.60"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47"
dependencies = [
 "wasm-bindgen",
]

[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 450,15 330,6 @@ dependencies = [
]

[[package]]
name = "link-cplusplus"
version = "1.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecd207c9c713c34f95a097a5b029ac2ce6010530c7b49d7fea24d977dede04f5"
dependencies = [
 "cc",
]

[[package]]
name = "linux-raw-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 558,22 429,12 @@ dependencies = [
]

[[package]]
name = "num-integer"
version = "0.1.45"
name = "num_threads"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [
 "autocfg",
 "num-traits",
]

[[package]]
name = "num-traits"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
dependencies = [
 "autocfg",
 "libc",
]

[[package]]


@@ 696,12 557,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294"

[[package]]
name = "scratch"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddccb15bcce173023b3fedd9436f882a0739b8dfb45e4f6b6002bee5929f61b2"

[[package]]
name = "serde"
version = "1.0.152"
source = "registry+https://github.com/rust-lang/crates.io-index"


@@ 738,7 593,6 @@ version = "0.1.0"
dependencies = [
 "anyhow",
 "calloop",
 "chrono",
 "clap",
 "futures",
 "itertools",


@@ 752,6 606,7 @@ dependencies = [
 "simple_logger",
 "smithay-client-toolkit",
 "thiserror",
 "time",
 "wayland-client",
 "wayland-protocols",
 "wayland-protocols-wlr",


@@ 878,82 733,51 @@ dependencies = [
]

[[package]]
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"

[[package]]
name = "unicode-width"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"

[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"

[[package]]
name = "version_check"
version = "0.9.4"
name = "time"
version = "0.3.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
checksum = "cd0cbfecb4d19b5ea75bb31ad904eb5b9fa13f21079c3b92017ebdf4999a5890"
dependencies = [
 "itoa",
 "libc",
 "num_threads",
 "serde",
 "time-core",
 "time-macros",
]

[[package]]
name = "wasm-bindgen"
version = "0.2.83"
name = "time-core"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268"
dependencies = [
 "cfg-if",
 "wasm-bindgen-macro",
]
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"

[[package]]
name = "wasm-bindgen-backend"
version = "0.2.83"
name = "time-macros"
version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142"
checksum = "fd80a657e71da814b8e5d60d3374fc6d35045062245d80224748ae522dd76f36"
dependencies = [
 "bumpalo",
 "log",
 "once_cell",
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-shared",
 "time-core",
]

[[package]]
name = "wasm-bindgen-macro"
version = "0.2.83"
name = "unicode-ident"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810"
dependencies = [
 "quote",
 "wasm-bindgen-macro-support",
]
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"

[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.83"
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c"
dependencies = [
 "proc-macro2",
 "quote",
 "syn",
 "wasm-bindgen-backend",
 "wasm-bindgen-shared",
]
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"

[[package]]
name = "wasm-bindgen-shared"
version = "0.2.83"
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"

[[package]]
name = "wayland-backend"

M Cargo.toml => Cargo.toml +1 -1
@@ 33,7 33,6 @@ smithay-client-toolkit = { git = "https://github.com/Smithay/client-toolkit.git"
png = "0.17.5"
memmap2 = "0.5.7"
itertools = "0.10.3"
chrono = { version = "0.4.22", default-features = false, features = ["clock"] }
thiserror = "1.0.32"
rustix = { version = "0.36.0-rc1", features = ["fs"] }
anyhow = "1.0.62"


@@ 45,3 44,4 @@ serde_json = "1.0.85"
nom = "7.1.1"
futures = { version = "0.3.25", default-features = false, features = ["std"] }
calloop = { version = "0.10.3", features = ["executor"] }
time = { version = "0.3.20", default-features = false, features = ["formatting", "local-offset", "macros"] }

M src/main.rs => src/main.rs +16 -6
@@ 10,7 10,6 @@ use std::thread;

use anyhow::{bail, Context};
use calloop::futures::{executor, Scheduler};
use chrono::Local;
use clap::Parser;
use cli::{Cli, RequestedTarget};
use futures::channel::oneshot::{self, Canceled};


@@ 24,6 23,8 @@ use smithay_client_toolkit::seat::keyboard::{keysyms, KeyboardData, KeyboardHand
use smithay_client_toolkit::{
    delegate_keyboard, delegate_output, delegate_registry, registry_handlers,
};
use time::format_description::FormatItem;
use time::OffsetDateTime;
use wayland_client::delegate_noop;
use wayland_client::event_created_child;
use wayland_client::globals::{registry_queue_init, GlobalList};


@@ 59,7 60,9 @@ mod slurp;
mod sway;

const BORDER_WIDTH: u8 = 2;
const FILENAME_FMT: &str = "Screenshot.from.%Y-%m-%d.at.%H_%M_%S%.f.png";
const FILENAME_FMT: &[FormatItem] = time::macros::format_description!(
    "Screenshot.from.[year]-[month]-[day].at.[hour]_[minute]_[second].[subsecond digits:9].png"
);

/// Returns the directory in which screenshots are to be saved.
/// Follows a best-effort fallback pattern.


@@ 84,6 87,14 @@ fn screenshots_directory() -> anyhow::Result<PathBuf> {
    }
}

fn screenshot_filepath() -> anyhow::Result<PathBuf> {
    let filename = OffsetDateTime::now_local()
        .context("Error obtaning local time")?
        .format(FILENAME_FMT)
        .context("Error formatting current time")?;
    Ok(screenshots_directory()?.join(filename))
}

/// The target we want to screenshot.
///
/// For the moment, windows are converted to the region they occupy. This will change in future


@@ 423,9 434,8 @@ impl State {

        let mut outputs = Vec::new();
        let shot_filepath = {
            match screenshots_directory() {
                Ok(dir) => {
                    let filepath = dir.join(format!("{}", Local::now().format(FILENAME_FMT)));
            match screenshot_filepath() {
                Ok(filepath) => {
                    let file = OpenOptions::new()
                        .write(true)
                        .create_new(true)


@@ 435,7 445,7 @@ impl State {
                    FileState::Created(filepath)
                }
                Err(e) => {
                    error!("No usable directory. Screenshot will not be saved: {}.", e);
                    error!("Failed to resolve path for file. Not saving png: {}.", e);
                    FileState::Deleted
                }
            }