Skip to content

armgit / Handy

Public Imported from GitHub
0

A free, open source, and extensible speech-to-text application that works completely offline.

fix(overlay): parse HANDY_NO_GTK_LAYER_SHELL as boolean (#1269)

Evgeny Khudoba11311bee0e50
diff --git a/src-tauri/src/overlay.rs b/src-tauri/src/overlay.rs
index 7ac9852d..f57f86b6 100644
--- a/src-tauri/src/overlay.rs
+++ b/src-tauri/src/overlay.rs
@@ -66,13 +66,27 @@ fn update_gtk_layer_shell_anchors(overlay_window: &tauri::webview::WebviewWindow
});
}
+/// Returns true when the environment variable is set to a truthy value
+/// (e.g. "1", "true", "yes", "on").
+/// "0", "false", "no", "off" and empty string are treated as falsy (case-insensitive).
+/// Returns false when the variable is not set.
+#[cfg(target_os = "linux")]
+fn env_flag_enabled(name: &str) -> bool {
+ match env::var(name) {
+ Ok(v) => !matches!(
+ v.trim().to_ascii_lowercase().as_str(),
+ "" | "0" | "false" | "no" | "off"
+ ),
+ Err(_) => false,
+ }
+}
+
/// Initializes GTK layer shell for Linux overlay window
/// Returns true if layer shell was successfully initialized, false otherwise
#[cfg(target_os = "linux")]
fn init_gtk_layer_shell(overlay_window: &tauri::webview::WebviewWindow) -> bool {
-
- if env::var("HANDY_NO_GTK_LAYER_SHELL").is_ok() {
- debug!("Skipping GTK layer shell init (HANDY_NO_GTK_LAYER_SHELL is set)");
+ if env_flag_enabled("HANDY_NO_GTK_LAYER_SHELL") {
+ debug!("Skipping GTK layer shell init (HANDY_NO_GTK_LAYER_SHELL is enabled)");
return false;
}