diff --git a/Cargo.lock b/Cargo.lock index 73fd8fe..5cd2638 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,6 +80,11 @@ name = "gcc" version = "0.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "lazy_static" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "libc" version = "0.2.50" @@ -176,6 +181,14 @@ name = "rustc-demangle" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "schedule_recv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.42" @@ -188,9 +201,10 @@ dependencies = [ [[package]] name = "upcheck" -version = "0.1.1" +version = "0.1.2" dependencies = [ "notify-rust 3.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "schedule_recv 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -224,6 +238,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum error-chain 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9435d864e017c3c6afeac1654189b06cdb491cf2ff73dbf0d73b0f292f42ff8" "checksum error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "07e791d3be96241c77c43846b665ef1384606da2cd2a48730abe606a12906e02" "checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" +"checksum lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73" "checksum libc 0.2.50 (registry+https://github.com/rust-lang/crates.io-index)" = "aab692d7759f5cd8c859e169db98ae5b52c924add2af5fbbca11d12fefb567c1" "checksum libdbus-sys 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "18cb88963258d00f4962205dbb5933d82780d9962c8c8a064b651d2ad7189210" "checksum mac-notification-sys 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a3639b6caa2db7443e5df80e12c450982f77fc3c140f53d6e48be91f965ea66" @@ -237,6 +252,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c" "checksum redox_syscall 0.1.51 (registry+https://github.com/rust-lang/crates.io-index)" = "423e376fffca3dfa06c9e9790a9ccd282fafb3cc6e6397d01dbf64f9bacc6b85" "checksum rustc-demangle 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "adacaae16d02b6ec37fdc7acfcddf365978de76d1983d3ee22afc260e1ca9619" +"checksum schedule_recv 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca1520cf9d3182329ceb57b9a6b37eb68fe94f5d46c0be4aa2d2a522ec3d40eb" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" diff --git a/Cargo.toml b/Cargo.toml index 49bd8a9..d28e912 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,9 @@ [package] name = "upcheck" -version = "0.1.1" +version = "0.1.2" authors = ["Eduard Toloza "] edition = "2018" [dependencies] -notify-rust = "^3" +notify-rust = "3.5.0" +schedule_recv = "0.1.0" diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD index 9236bfb..e5abc8e 100644 --- a/archlinux/PKGBUILD +++ b/archlinux/PKGBUILD @@ -1,8 +1,8 @@ # Maintainer: Eduard Toloza pkgname=upcheck -pkgver=0.1.1 -pkgrel=3 +pkgver=0.1.2 +pkgrel=1 pkgdesc='Checker for ArchLinux available updates and send it via notify-rust.' arch=('x86_64') url='https://gitlab.com/edu4rdshl/upcheck' @@ -13,9 +13,8 @@ sha512sums=('208443c757528396e82980bf31654f5d1802abcd090422a2ceff7bfbfb512e5173f package() { cd "${pkgname}-${pkgver}" - install -dm 755 "${pkgdir}/usr/lib/systemd/user/" install -Dm 755 bin/"${pkgname}" "${pkgdir}/usr/bin/${pkgname}" install -Dm 755 README.md "${pkgdir}/usr/share/doc/${pkgname}/README" - cp "${pkgname}".{service,timer} "${pkgdir}/usr/lib/systemd/user/" + install -Dm 644 "${pkgname}".service "${pkgdir}/usr/lib/systemd/user/${pkgname}.service" } diff --git a/bin/upcheck b/bin/upcheck index df3c873..92c5211 100755 Binary files a/bin/upcheck and b/bin/upcheck differ diff --git a/src/main.rs b/src/main.rs index dac0358..845a585 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,45 @@ // Crate for notifications extern crate notify_rust; +extern crate schedule_recv; use notify_rust::Notification; +use std::env; use std::path::Path; use std::process::Command; fn main() { - upcheck(); + let args: Vec = env::args().collect(); + if args.len() == 2 { + let execution_time: u32 = args[1] + .trim() + .parse() + .expect("Error, execution time argument can not be converted in a valid number."); + + println!( + "You are going to check updates every {} minute(s).", + execution_time + ); + + // Execution time need to be miliseconds + let execution_time = execution_time * 60000; + let tick = schedule_recv::periodic_ms(execution_time); + loop { + tick.recv().unwrap(); + upcheck(); + } + } else { + println!( + " + Usage: + + upcheck