Skip to content

Commit

Permalink
New better everything! πŸŽ‰
Browse files Browse the repository at this point in the history
Happy birthday Willow! πŸŽ‚
  • Loading branch information
owenthewizard committed May 24, 2019
1 parent 2642386 commit 7417fd7
Show file tree
Hide file tree
Showing 21 changed files with 1,065 additions and 463 deletions.
Binary file added .github/blur-0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/blur-10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/blur-25.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .github/invert.png
Binary file not shown.
Binary file removed .github/no-invert.png
Binary file not shown.
207 changes: 126 additions & 81 deletions Cargo.lock

Large diffs are not rendered by default.

58 changes: 22 additions & 36 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,49 +1,35 @@
[package]
name = "i3lockr"
version = "0.1.2"
description = "Distort a screenshot and run i3lock"
version = "1.0.0"
license = "MIT OR Apache-2.0"
edition = "2018"
repository = "https://github.com/owenthewizard/i3lockr"
keywords = ["i3", "i3lock", "i3lockr", "i3lock-color", "lock"]
authors = ["Owen Walpole <[email protected]>"]
description = "Distort a screenshot and run i3lock"
publish = false
repository = "https://github.com/owenthewizard/i3lockr"
readme = "README.md"
keywords = ["i3lockr", "i3lock", "i3lock-fancy", "blur", "i3lock-color" ]
categories = ["command-line-utilities", "multimedia::images"]
edition = "2018"

[dependencies]
#font-loader = "0.7.0"
libc = "0.2.46"

[dependencies.clap]
version = "2.32.0"
default-features = false
features = ["yaml"]

#[dependencies.structopt]
#version = "0.2.14"
#default-features = false
libc = "0.2" # should be same as xcb
num_cpus = "1"

[dependencies.image]
version = "0.21.0"
[dependencies.structopt]
version = "0.2"
default-features = false
features = ["png_codec"]

[dependencies.xcb]
version = "0.8.2"
default-features = false
features = ["randr"]
version = "0.8"
features = ["randr", "shm"]

[dependencies.xcb-util]
version = "0.2.0"
default-features = false
features = ["image"]
[build-dependencies]
cc = "1"

[profile.release]
codegen-units = 1
lto = "thin"

[profile.bench]
codegen-units = 1
lto = "thin"
[features]
suggestions = ["structopt/suggestions"]
color = ["structopt/color"]
default = ["suggestions", "color"]

[profile.dev]
opt-level = 2
[profile.release]
lto = true
codegen-units=1
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,59 +2,63 @@

Distort a screenshot and run `i3lock`.

## Quick Start [[Documentation]](USAGE.md)
## Quick start [[Documentation]](USAGE.md)

Signed binary releases are availible [here](https://github.com/owenthewizard/i3lockr/releases).
Signed binary releases are availible on the [releases page](https://github.com/owenthewizard/i3lockr/releases).

Or build it yourself:
```bash
git clone --depth=1 git://github.com/owenthewizard/i3lockr.git && cd i3lockr
cargo build --release
sudo strip -s target/release/i3lockr /usr/local/bin/i3lockr
i3lockr --invert -- --nofork --noempty # or your favorite args
cargo build --release # you may adjust features here
sudo strip -s target/release/i3lockr -o /usr/local/bin/i3lockr
i3lockr --blur 25 -- --nofork --ignore-empty-password # use your favorite args
```

## Screenshots

Without `--invert`
![screenshot without --invert](.github/no-invert.png)
Without `--blur`
![screenshot without blur](.github/blur-0)

With `--invert`
![screenshot with --invert](.github/invert.png)
With `--blur=10`
![screenshot with blur 10](.github/blur-10)

With the default options on a 1080p monitor, `i3lockr` takes less than half a second to run!
With `--blur=25`
![screenshot with blur 25](.github/blur-25)

`i3lockr` (since v1.0.0) is incredibly fast at all blur levels, try timing it yourself with `time`.

## Important Notes

The exit status of `i3lockr` is not reliable!
That means that `i3lockr && systemctl suspend` may not lock the screen if there was an error.
`i3lockr` always exits with `EXIT_SUCCESS`. This means that commands such as `i3lockr && systemctl suspend` may not lock the screen if there was an error.

### Coding Style

Obey `rustfmt` and Rust 2018 conventions.

## Contributing

Pull requests are always welcome. See [TODO](TODO.md).
Pull requests are always welcome.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed under the terms of both the MIT License and the Apache License (Version 2.0).

## Versioning

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Changes are documented in the [Changelog](CHANGELOG.md).

See the [tags on this repository](https://github.com/owenthewizard/i3lockr/tags) for available releases.
See the [tags](https://github.com/owenthewizard/i3lockr/tags) for available releases.

## Authors

See [the list of contributors](https://github.com/owenthewizard/i3lockr/contributors).

## License

`i3lockr` is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See [LICENSE-APACHE](LICENSE-APACHE.md) and [LICENSE-MIT](LICENSE-MIT.md) for details.

## Acknowledgments

* [i3lock-fancy](https://github.com/meskarune/i3lock-fancy) by Dolores Portalatin for inspiration.
* [Padlock Icon](padlock.svg) made by [Chanut](https://www.flaticon.com/authors/chanut) from [Flaticon](https://www.flaticon.com) is licensed by [CC 3.0 BY](https://creativecommons.org/licenses/by/3.0/).
* [i3lock](https://github.com/i3/i3lock) by [Michael Stapelberg](https://github.com/stapelberg) and [contributers](https://github.com/i3/i3lock/graphs/contributors)
* [i3lock-fancy](https://github.com/meskarune/i3lock-fancy) by [Dolores Portalatin](https://github.com/meskarune) for inspiration.
* [Martin DΓΈrum](https://github.com/mortie) for contributions to `i3lock` that made this possible.
5 changes: 0 additions & 5 deletions TODO.md

This file was deleted.

28 changes: 14 additions & 14 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
See the help:

```
i3lockr v0.1.0 (unknown-branch@unknown-commit)
i3lockr 1.0.0
Owen Walpole <[email protected]>
Distort a screenshot and run i3lock
USAGE:
i3lockr [FLAGS] [OPTIONS] [i3lock]...
FLAGS:
-h, --help Prints help information
--invert Draw the lock image as an invert mask on the background, i.e. invert every pixel on the background
where the same pixel on the lock image has >50% alpha
-V, --version Prints version information
-v, --verbose Print how long each step takes, among other things. Always enabled in debug builds.
-h, --help Prints help information
--invert Interpret the icon as a mask, inverting masked pixels [NYI] on the screenshot. Try it to see an
example.
--one-icon Only place one icon. Default is to place an icon on each monitor. [NYI]
-V, --version Prints version information
OPTIONS:
-d, --dark <dark> Darkens image by an amount [default: -36]
-g, --gravity <gravity> Text position [default: south] [possible values: north, east, south, west]
-i, --iter <iter> Number of blur iterations [default: 1]
-l, --lock <lock> Path to lock image
-f, --scale <scale> Scale factor for faux-blur. Divisor of 1, so 5 == 20% [default: 2]
-s, --strength <strength> Blur strength [default: 3]
-t, --text <text> Text to draw on the screen [UNINPLEMENTED] [default: ]
-i, --icon <file.png> Path to icon to overlay on screenshot. [NYI]
-u, --position <coords|center> Icon placement, "center" to center, [NYI] "x, y" (from top-left), or "-x,-y" (from
bottom-right). Has no effect without --icon. Example: "(945, -20)" [default:
Center]
-b, --blur <radius> Blur strength. Example: 10
ARGS:
<i3lock>... Args to pass to i3lock
<i3lock>... Arguments to pass to i3lock. '--' must be used. Example: "-- --nofork --ignore-empty-password"
```

[default.png](default.png) is embedded into the executable at build-time as the default lock image.
Items marked `[NYI]` are `Not Yet Implemented` and may function partially or not at all.
53 changes: 41 additions & 12 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,52 @@
use std::env;
use std::path::Path;
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};

fn main() {
println!("cargo:rustc-env=GIT_BRANCH=unknown-branch");
println!("cargo:rustc-env=GIT_HASH=unknown-commit");
if let Ok(output) = Command::new("git")
.args(&["rev-parse", "--abbrev-ref", "HEAD"])
// Build C code for stackblur and statically link
let c_src = Path::new("src").join("C");
cc::Build::new()
.file(c_src.join("stackblur.c"))
.include(c_src)
.compile("stackblur");
//

// Export build target, build time, and git commit
println!(
"cargo:rustc-env=TARGET={}",
env::var("TARGET").unwrap_or("Unknown Target".to_owned())
);

let mut git_branch = "Unknown Branch".to_owned();
let mut git_commit = "Unknown Commit".to_owned();

if let Ok(out) = Command::new("git")
.args(vec!["rev-parse", "--abbrev-ref", "HEAD"])
.output()
{
if output.status.success() {
let git_branch = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_BRANCH={}", git_branch);
if !out.stdout.is_empty() {
git_branch = String::from_utf8(out.stdout).unwrap_or("Unknown Branch".to_owned());
}
}
if let Ok(output) = Command::new("git").args(&["rev-parse", "HEAD"]).output() {
if output.status.success() {
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash.get(0..7).unwrap());

if let Ok(out) = Command::new("git")
.args(vec!["rev-parse", "--short", "HEAD"])
.output()
{
if !out.stdout.is_empty() {
git_commit = String::from_utf8(out.stdout).unwrap_or("Unknown Commit".to_owned());
}
}

// TODO: clap gen shell completion & manpages
println!("cargo:rustc-env=GIT_BRANCH={}", git_branch);
println!("cargo:rustc-env=GIT_COMMIT={}", git_commit);
println!(
"cargo:rustc-env=TIME={}",
SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_secs()
);
//
}
Binary file removed default.png
Binary file not shown.
Loading

0 comments on commit 7417fd7

Please sign in to comment.