forked from michael/leanshot
use DISPLAY environment variable
This commit is contained in:
parent
5b7e0c98a7
commit
ee9f00284d
3 changed files with 6 additions and 2 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1,3 +1,5 @@
|
||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler32"
|
name = "adler32"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
|
|
|
@ -4,7 +4,7 @@ description = "Screenshot capture for Linux."
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
repository = "https://github.com/iptq/leanshot"
|
repository = "https://github.com/iptq/leanshot"
|
||||||
license-file = "LICENSE"
|
license-file = "LICENSE"
|
||||||
authors = ["Michael Zhang <failed.down@gmail.com>"]
|
authors = ["Michael Zhang <iptq@protonmail.com>"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [".", "imlib2", "imlib2/imlib2-sys", "xlib"]
|
members = [".", "imlib2", "imlib2/imlib2-sys", "xlib"]
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::env;
|
||||||
|
|
||||||
use imlib2::{self, Image as Image2};
|
use imlib2::{self, Image as Image2};
|
||||||
use xlib::{Display, Visual, Window};
|
use xlib::{Display, Visual, Window};
|
||||||
|
|
||||||
|
@ -12,7 +14,7 @@ pub struct GUI {
|
||||||
|
|
||||||
impl GUI {
|
impl GUI {
|
||||||
pub fn new() -> Result<Self, ScreenshotError> {
|
pub fn new() -> Result<Self, ScreenshotError> {
|
||||||
let display = Display::connect(":0")?;
|
let display = Display::connect(env::var("DISPLAY").unwrap_or_else(|_| ":0".to_owned()))?;
|
||||||
Ok(GUI { display })
|
Ok(GUI { display })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue