prs_lib/util/env.rs
1use std::env;
2
3/// Check whether we're in a Wayland environment
4#[cfg(all(feature = "tomb", target_os = "linux"))]
5pub fn is_wayland() -> bool {
6 has_non_empty_env("WAYLAND_DISPLAY")
7}
8
9/// Check whether `GPG_TTY` is set.
10pub fn has_gpg_tty() -> bool {
11 has_non_empty_env("GPG_TTY")
12}
13
14/// Check if an environment variable is set and is not empty.
15pub fn has_non_empty_env(env: &str) -> bool {
16 env::var_os(env).map(|v| !v.is_empty()).unwrap_or(false)
17}