diff --git a/Cargo.lock b/Cargo.lock index 960d3be..dba527e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,3 +1,5 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. [[package]] name = "adler32" version = "1.0.3" diff --git a/Cargo.toml b/Cargo.toml index 900d8ef..80f1fd9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ description = "Screenshot capture for Linux." version = "0.3.3" repository = "https://github.com/iptq/leanshot" license-file = "LICENSE" -authors = ["Michael Zhang "] +authors = ["Michael Zhang "] [workspace] members = [".", "imlib2", "imlib2/imlib2-sys", "xlib"] diff --git a/src/gui.rs b/src/gui.rs index 669deac..5c99f7f 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -1,3 +1,5 @@ +use std::env; + use imlib2::{self, Image as Image2}; use xlib::{Display, Visual, Window}; @@ -12,7 +14,7 @@ pub struct GUI { impl GUI { pub fn new() -> Result { - let display = Display::connect(":0")?; + let display = Display::connect(env::var("DISPLAY").unwrap_or_else(|_| ":0".to_owned()))?; Ok(GUI { display }) }