Skip to content

Commit

Permalink
UPDATED: ADDED: NOTIFICATIONS
Browse files Browse the repository at this point in the history
  • Loading branch information
amar-laksh committed Oct 3, 2017
1 parent 4b8f507 commit accb46d
Show file tree
Hide file tree
Showing 6 changed files with 228 additions and 41 deletions.
204 changes: 204 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ authors = ["Amar L. <amar.lakshya@xaviers.edu.in>"]
clap = "2.26.0"
opencv = "0.2.3"
shells = "0.2.0"
notify-rust = "3"
29 changes: 0 additions & 29 deletions PKGBUILD

This file was deleted.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ It's a nifty commandline rust tool to make you sit slightly away from your scree
- Rust
- Cargo
- *NIX
- notify-osd
- libnotify

# INSTALL

Expand All @@ -17,8 +19,8 @@ It's a nifty commandline rust tool to make you sit slightly away from your scree

For help:

`workstation -h`
`workstation -h`

Example usage:

`workstation 3500 2`
`workstation 3500 2`
5 changes: 0 additions & 5 deletions makefile

This file was deleted.

24 changes: 19 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
extern crate shells;
extern crate opencv;
extern crate clap;
extern crate notify_rust;

use clap::{Arg, App};
use opencv::*;
use notify_rust::Notification;
use std::time::Instant;
use std::time::Duration;

Expand Down Expand Up @@ -42,7 +45,7 @@ fn run(rect: i32, timeout: i64) -> Result<(),String> {
, core::Size{ width:0, height:0 }));
if faces.len() != 0 {
area = faces[0].width * faces[0].height;
println!("Area: {:?}, rect: {:?}", area, rect);
//println!("Area: {:?}, rect: {:?}", area, rect);
if area >= rect {
sh!("echo 0 > \
/sys/class/backlight/intel_backlight/brightness");
Expand All @@ -53,12 +56,17 @@ fn run(rect: i32, timeout: i64) -> Result<(),String> {
}
} else {
// println!("NO FACE FOUND...WAITING TO LOCK.");

let now = Instant::now();
let mut elapsed;
let mut sec = 0;
let mut still_faces =
::opencv::types::VectorOfRect::new();
let mut saved = 0;
Notification::new()
.summary("workstation")
.body(&format!("The system is locking in {} seconds", timeout))
.show().unwrap();
while sec <= timeout {
elapsed = now.elapsed();
sec = (
Expand Down Expand Up @@ -124,14 +132,20 @@ fn main() {
let matches = App::new("workstation")
.version("0.1.0")
.author("Amar L. <amar.lakshya@xaviers.edu.in>")
.about(r#"helps you at the workstation by keeping you
far from screen and locks system when you are
away, among other things."#)
.about(
r#"helps you at the workstation by keeping you
far from screen and locks system when you are
away, among other things."#
)
.arg(Arg::with_name("rect")
.required(true)
.takes_value(true)
.index(1)
.help("size of rectangle for screen dimming"))
.help(
r#"size of rectangle for screen dimming;
the larger the rectangle the closer to the
screen the trigger happens"#
))
.arg(Arg::with_name("timeout")
.required(true)
.takes_value(true)
Expand Down

0 comments on commit accb46d

Please sign in to comment.