Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src-tauri/src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tauri::{AppHandle, Manager};
use tauri_plugin_clipboard_manager::ClipboardExt;

#[cfg(target_os = "linux")]
use crate::utils::{is_kde_wayland, is_wayland};
use crate::utils::{is_gnome_wayland, is_kde_wayland, is_wayland};

/// Pastes text using the clipboard: saves current content, writes text, sends paste keystroke, restores clipboard.
fn paste_via_clipboard(
Expand Down Expand Up @@ -83,9 +83,11 @@ fn paste_via_clipboard(
#[cfg(target_os = "linux")]
fn try_send_key_combo_linux(paste_method: &PasteMethod) -> Result<bool, String> {
if is_wayland() {
// Wayland: prefer wtype (but not on KDE), then dotool, then ydotool
// Wayland: prefer wtype (but not on KDE or GNOME), then dotool, then ydotool
// Note: wtype doesn't work on KDE (no zwp_virtual_keyboard_manager_v1 support)
if !is_kde_wayland() && is_wtype_available() {
// or on GNOME/Mutter (same reason — Mutter deliberately does not implement
// the virtual-keyboard-v1 protocol).
if !is_kde_wayland() && !is_gnome_wayland() && is_wtype_available() {
info!("Using wtype for key combo");
send_key_combo_via_wtype(paste_method)?;
return Ok(true);
Expand Down Expand Up @@ -166,7 +168,9 @@ fn try_direct_typing_linux(text: &str, preferred_tool: TypingTool) -> Result<boo
}
// Wayland: prefer wtype, then dotool, then ydotool
// Note: wtype doesn't work on KDE (no zwp_virtual_keyboard_manager_v1 support)
if !is_kde_wayland() && is_wtype_available() {
// or on GNOME/Mutter (same reason — Mutter deliberately does not implement
// the virtual-keyboard-v1 protocol).
if !is_kde_wayland() && !is_gnome_wayland() && is_wtype_available() {
info!("Using wtype for direct text input");
type_text_via_wtype(text)?;
return Ok(true);
Expand Down
14 changes: 14 additions & 0 deletions src-tauri/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ pub fn is_kde_plasma() -> bool {
pub fn is_kde_wayland() -> bool {
is_wayland() && is_kde_plasma()
}

/// Check if running on GNOME desktop environment
#[cfg(target_os = "linux")]
pub fn is_gnome() -> bool {
std::env::var("XDG_CURRENT_DESKTOP")
.map(|v| v.to_uppercase().contains("GNOME"))
.unwrap_or(false)
}

/// Check if running on GNOME with Wayland
#[cfg(target_os = "linux")]
pub fn is_gnome_wayland() -> bool {
is_wayland() && is_gnome()
}