niri icon indicating copy to clipboard operation
niri copied to clipboard

wl-clip-presist crashes

Open anasgets111 opened this issue 8 months ago • 16 comments

with spawn-at-startup "wl-clip-persist" "--clipboard" "regular" copying a block of text from zen/kitty to vscode/vesktop for example crashes vscode/vesktop tried with both wl-clipboard and wl-clipboard-rs , with and without wl-clipboard-x11, once wl-clip-persist is killed no crashes, works fine with it running in hyprland with all the above apps.

Click here to see my niri config
// https://github.com/YaLTeR/niri/wiki/Configuration:-Introduction
// Remember to uncomment the node by removing "/-"!


workspace "Zen"  {open-on-output "DP-3";}
workspace "Chromium"  {open-on-output "DP-3";}
workspace "Code"       {open-on-output "DP-3";}
workspace "Zed"          {open-on-output "DP-3";}
workspace "Files"        {open-on-output "DP-3";}
workspace "Thunderbird"  {open-on-output "DP-3";}
workspace "Games"        {open-on-output "DP-3";}
workspace "Terminal" {open-on-output "DP-3";}
workspace "Telegram" {open-on-output "DP-2";}
workspace "Discord" {open-on-output "DP-2";}
workspace "Slack"   {open-on-output "DP-2";}

input {
    keyboard {
        xkb {
            layout "us,eg"
            options "grp:alt_shift_toggle,lv3:ralt_alt"
        }
        track-layout "window"
        numlock
    }
    touchpad {
        // off
        tap
        dwt
        natural-scroll
    }
    // warp-mouse-to-focus
    focus-follows-mouse max-scroll-amount="0%"
    workspace-auto-back-and-forth
}

// `niri msg outputs` while inside a niri instance.
output "eDP-1" {
    mode "1920x1200@60"
        focus-at-startup
}
output "DP-2" {
    mode "1920x1080@60"
    position x=2560 y=-450
    transform "90"
}
output "DP-3" {
    mode "2560x1440@120"
    position x=0 y=0
    focus-at-startup
    variable-refresh-rate on-demand=true
}

hotkey-overlay {
    skip-at-startup
}


cursor {
    xcursor-theme "Bibata-Modern-Ice"
    xcursor-size 24
}


prefer-no-csd


layout {
    gaps 11
    center-focused-column "never"

    // You can customize the widths that "switch-preset-column-width" (Mod+R) toggles between.
    preset-column-widths {
        proportion 0.33333
        proportion 0.5
        proportion 0.66667
        // fixed 1920
    }

    // You can also customize the heights that "switch-preset-window-height" (Mod+Shift+R) toggles between.
    preset-window-heights {
        proportion 0.33333
        proportion 0.5
        proportion 0.66667
    }

    default-column-width {   proportion 1.0; }

    focus-ring {
        // off
        width 2

        // - CSS named colors: "red"
        // - RGB hex: "#rgb", "#rgba", "#rrggbb", "#rrggbbaa"
        // - CSS-like notation: "rgb(255, 127, 0)", rgba(), hsl() and a few others.
        active-color "#7fc8ff"
        inactive-color "#505050"
        // inactive-gradient from="#505050" to="#808080" angle=45 relative-to="workspace-view"
    }

    border {
        off
    }
    // You can enable drop shadows for windows.
    shadow {
        // on
        // draw-behind-window true
        softness 30
        spread 5
        offset x=0 y=5
        // You can also change the shadow color and opacity.
        color "#0007"
    }
}
clipboard {
    disable-primary
}
// Note that running niri as a session supports xdg-desktop-autostart
spawn-at-startup "/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1"
spawn-at-startup "swayidle"
spawn-at-startup "quickshell"
"wl-paste --watch cliphist store"
// spawn-at-startup "swaync"
spawn-at-startup "wl-clip-persist" "--clipboard" "regular"
spawn-at-startup "kdeconnectd"
spawn-at-startup "kdeconnect-indicator"
spawn-at-startup "speech-dispatcher"
spawn-at-startup "xwayland-satellite"
spawn-at-startup "sh" "-c" "sleep 3 && openrgb --startminimized --profile 'Default'"
spawn-at-startup "code"
spawn-at-startup "zen-browser"
spawn-at-startup "slack"
spawn-at-startup "Telegram"
spawn-at-startup "vesktop"
spawn-at-startup "thunderbird"
spawn-at-startup "xdg-terminal-exec"



animations {
    // off
    screenshot-ui-open {
        duration-ms 471
        curve "ease-out-quad"
    }
    slowdown 0.74
}

// =====================
// Window Rules Section
// =====================

// Workspace placement
window-rule {
match app-id="code"
open-on-workspace "Code"
}
window-rule {
match app-id="org.gnome.Nautilus"
open-on-workspace "Files"
}
window-rule {
match app-id="kitty"
match app-id="alacritty"
match app-id="org.gnome.Terminal"
open-on-workspace "Terminal"
}
window-rule {
match app-id="Slack"
open-on-workspace "Slack"
}
window-rule {
match app-id="org.telegram.desktop"
open-on-workspace "Telegram"
}
window-rule {
match app-id="vesktop"
open-on-workspace "Discord"
}
window-rule {
match app-id="zen"
open-on-workspace "Zen"
}
window-rule {
match app-id="org.chromium.Chromium"
open-on-workspace "Chromium"
}
window-rule {
match app-id="thunderbird"
open-on-workspace "Thunderbird"
}

// Floating windows (no explicit size)
window-rule {
match title="OpenRGB"
match title="Network Connections"
match title="Do you want to retry your last request"
match app-id="org.kde.kdeconnect.handler"
match app-id="waypaper"
open-floating true
}

// Floating windows, medium size (~74%)
window-rule {
match app-id="io.missioncenter.MissionCenter"
match app-id="gtk-pipe-viewer"
match app-id="org.pulseaudio.pavucontrol"
match app-id="blueman-manager"
match app-id="org.gnome.DiskUtility"
match app-id="nm-connection-editor"
match app-id="polkit.authentication-agent."
match app-id="xdg-desktop-portal.*"
match app-id="zenity"
match app-id="pavucontrol"
match app-id="mpv"
match title=".*Global Updates"
match title="Sign in - Google Accounts — Zen Browser"
open-floating true
default-column-width { proportion 0.74; }
default-window-height { proportion 0.74; }
}

// Floating windows, small dialogs (~47%)
window-rule {
match app-id="com.saivert.pwvucontrol"
match title="Install from VSIX"
match title="Open File"
match title="Save File"
match title="Save As"
match title="Downloading Certificate"
match title="Open Folder"
match title="File Upload"
match title="Enter name of file to save to.."
match title="Authentication Required"
match title="Create or select new Steam library folder"
match title="About Zen Browser"
match title=r#"^([Pp]icture[-\s]?[Ii]n[-\s]?[Pp]icture)(.*)$"#
open-floating true
default-column-width { proportion 0.47; }
default-window-height { proportion 0.47; }
}

// Calculator: tiny float (~15%)
window-rule {
match app-id="org.gnome.Calculator"
open-floating true
default-column-width { proportion 0.15; }
default-window-height { proportion 0.15; }
}

// Global window defaults
window-rule {
geometry-corner-radius 15 15 0 0
clip-to-geometry true
draw-border-with-background false
opacity 0.9
}

binds {
    // "Mod" Super when running on a TTY, and to Alt when running as a winit window.
    // shows a list of important hotkeys.
    Mod+Shift+Slash { show-hotkey-overlay; }

    Mod+Return hotkey-overlay-title="Open a Terminal" { spawn "xdg-terminal-exec"; }
    Mod+KP_Enter { spawn "xdg-terminal-exec"; }
    Ctrl+Alt+Delete { spawn "missioncenter"; }
    
    Mod+Z { spawn "zeditor"; }
    Mod+C { spawn "code"; }
    //Mod+SPACE { spawn "pidof rofi && pkill rofi || ~/.config/rofi/launchers/type-6/launcher.sh"; }
    Mod+E { spawn "nautilus"; }
    Mod+B { spawn "zen-browser"; }

    Mod+S { spawn "slack"; }
    Mod+T { spawn "Telegram"; }
    Mod+D { spawn "vesktop"; }

    Super+L hotkey-overlay-title="Lock the Screen" { spawn "swaylock"; }


    // The allow-when-locked=true property makes them work even when the session is locked.
    XF86AudioRaiseVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1+"; }
    XF86AudioLowerVolume allow-when-locked=true { spawn "wpctl" "set-volume" "@DEFAULT_AUDIO_SINK@" "0.1-"; }
    XF86AudioMute        allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SINK@" "toggle"; }
    XF86AudioMicMute     allow-when-locked=true { spawn "wpctl" "set-mute" "@DEFAULT_AUDIO_SOURCE@" "toggle"; }
    XF86Calculator {spawn "gnome-calculator"; }

    // the top-left hot corner, or a four-finger swipe up on a touchpad opens the overview too.
    Mod+Space repeat=false { toggle-overview; }
    Mod+Q { close-window; }

    Mod+Left  { focus-column-left; }
    Mod+Down  { focus-window-or-workspace-down; }
    Mod+Up    { focus-window-or-workspace-up; }
    Mod+Right { focus-column-right; }

    Mod+Ctrl+Left  { move-column-left; }
    Mod+Ctrl+Down  { move-window-down; }
    Mod+Ctrl+Up    { move-window-up; }
    Mod+Ctrl+Right { move-column-right; }

    Mod+Home { focus-column-first; }
    Mod+End  { focus-column-last; }
    Mod+Ctrl+Home { move-column-to-first; }
    Mod+Ctrl+End  { move-column-to-last; }

    Mod+Shift+Left  { focus-monitor-left; }
    Mod+Shift+Down  { focus-monitor-down; }
    Mod+Shift+Up    { focus-monitor-up; }
    Mod+Shift+Right { focus-monitor-right; }
    
    Mod+Shift+Ctrl+Left  { move-window-to-monitor-left; }
    Mod+Shift+Ctrl+Down  { move-window-to-monitor-down; }
    

    Mod+Page_Down      { focus-workspace-down; }
    Mod+Page_Up        { focus-workspace-up; }
    Mod+Ctrl+Page_Down { move-column-to-workspace-down; }
    Mod+Ctrl+Page_Up   { move-column-to-workspace-up; }
    Mod+Ctrl+U         { move-column-to-workspace-down; }
    Mod+Ctrl+I         { move-column-to-workspace-up; }


    Mod+Shift+Page_Down { move-workspace-down; }
    Mod+Shift+Page_Up   { move-workspace-up; }
    Mod+Shift+U         { move-workspace-down; }
    Mod+Shift+I         { move-workspace-up; }

    Mod+WheelScrollDown      { focus-column-right; }
    Mod+WheelScrollUp       { focus-column-left; }
    Mod+Ctrl+WheelScrollDown { move-column-right; }
    Mod+Ctrl+WheelScrollUp  { move-column-left; }

    // Usually scrolling up and down with Shift in applications results in
    // horizontal scrolling; these binds replicate that.
    Mod+Shift+WheelScrollDown      { focus-column-right; }
    Mod+Shift+WheelScrollUp        { focus-column-left; }
    Mod+Ctrl+Shift+WheelScrollDown { move-column-right; }
    Mod+Ctrl+Shift+WheelScrollUp   { move-column-left; }

    Mod+1 { focus-workspace "Zen"; }
    Mod+2 { focus-workspace "Chromium"; }
    Mod+3 { focus-workspace "Code"; }
    Mod+4 { focus-workspace "Zed"; }
    Mod+5 { focus-workspace "Files"; }
    Mod+6 { focus-workspace "Games"; }
    Mod+7 { focus-workspace "Thunderbird"; }
    Mod+8 { focus-workspace "Telegram"; }
    Mod+9 { focus-workspace "Discord"; }
    Mod+0 { focus-workspace "Slack"; }
    
    Mod+Shift+1 { move-window-to-workspace "Zen"; }
    Mod+Shift+2 { move-window-to-workspace "Chromium"; }
    Mod+Shift+3 { move-window-to-workspace "Code"; }
    Mod+Shift+4 { move-window-to-workspace "Zed"; }
    Mod+Shift+5 { move-window-to-workspace "Files"; }
    Mod+Shift+6 { move-window-to-workspace "Torrent"; }
    Mod+Shift+7 { move-window-to-workspace "Thunderbird"; }
    Mod+Shift+8 { move-window-to-workspace "Telegram"; }
    Mod+Shift+9 { move-window-to-workspace "Discord"; }
    Mod+Shift+0 { move-window-to-workspace "Slack"; }



    // Alternatively, there are commands to move just a single window:
    // Mod+Ctrl+1 { move-window-to-workspace 1; }

    // Switches focus between the current and the previous workspace.
    // Mod+Tab { focus-workspace-previous; }

    // The following binds move the focused window in and out of a column.
    // If the window is alone, they will consume it into the nearby column to the side.
    // If the window is already in a column, they will expel it out.
    Mod+BracketLeft  { consume-or-expel-window-left; }
    Mod+BracketRight { consume-or-expel-window-right; }

    // Consume one window from the right to the bottom of the focused column.
    Mod+Comma  { consume-window-into-column; }
    // Expel the bottom window from the focused column to the right.
    Mod+Period { expel-window-from-column; }
    Mod+R { switch-preset-column-width; }
    Mod+Shift+R { switch-preset-window-height; }
    Mod+Ctrl+R { reset-window-height; }
    
    Mod+V       { toggle-window-floating; }
    Mod+F { maximize-column; }
    Mod+Shift+F { fullscreen-window; }

    // Expand the focused column to space not taken up by other fully visible columns.
    // Makes the column "fill the rest of the space".
    Mod+Ctrl+F { expand-column-to-available-width; }

    // Mod+C { center-column; }

    Mod+Minus { set-column-width "-5%"; }
    Mod+Equal { set-column-width "+5%"; }
    Mod+Shift+Minus { set-window-height "-5%"; }
    Mod+Shift+Equal { set-window-height "+5%"; }

    // Toggle tabbed column display mode.
    // Windows in this column will appear as vertical tabs,
    // rather than stacked on top of each other.
    Mod+W { toggle-column-tabbed-display; }


    Print hotkey-overlay-title="Take Screenshot and Annotate" { screenshot ; }
    Ctrl+Print { screenshot-screen; }
    Alt+Print { screenshot-window; }
    Shift+Print { spawn "ScreenRecording.sh" ;}
    // Applications such as remote-desktop clients and software KVM switches may
    // request that niri stops processing the keyboard shortcuts defined here
    // so they may, for example, forward the key presses as-is to a remote machine.
    // It's a good idea to bind an escape hatch to toggle the inhibitor,
    // so a buggy application can't hold your session hostage.
    //
    // The allow-inhibiting=false property can be applied to other binds as well,
    // which ensures niri always processes them, even when an inhibitor is active.
    Mod+Escape allow-inhibiting=false { toggle-keyboard-shortcuts-inhibit; }

    // The quit action will show a confirmation dialog to avoid accidental exits.
    Mod+Shift+L { quit; }

    // Powers off the monitors. To turn them back on, do any input like
    // moving the mouse or pressing any other key.
    Mod+Shift+P { power-off-monitors; }
}

environment {
    DISPLAY ":0"
    ELECTRON_OZONE_PLATFORM_HINT "auto"
}
screenshot-path "~/Pictures/Screenshot from %Y-%m-%d %H-%M-%S.png"

// You can also set this to null to disable saving screenshots to disk.
// screenshot-path null

should be running in wayland according to my config.. even have the code-flags file in .config

System Information

  • niri 25.05.1 (8ba57fc)

  • Distro: Archlinux (default archlinux kernel 6.16)

  • GPU: Nvidia RTX 3080 (nvidia-open 580.76.05)

  • CPU: Ryzen 5900X

anasgets111 avatar Aug 16 '25 23:08 anasgets111

Presumably those are X11 apps so this could be an xwayland-satellite issue?

YaLTeR avatar Aug 17 '25 04:08 YaLTeR

Happens to me and I have vscode running on Wayland and it also happens in kitty

HumpityDumpityDumber avatar Aug 17 '25 04:08 HumpityDumpityDumber

Can you try latest git? There were clipboard fixes in smithay

YaLTeR avatar Aug 17 '25 04:08 YaLTeR

Fair point I haven't tested it since I switch to git. From the small amount. Of messing around it seems fine but I'll keep it running for the next while I use my computer and see if any issues arise.

HumpityDumpityDumber avatar Aug 17 '25 04:08 HumpityDumpityDumber

tested with latest git still the same issue, also I made sure those apps are running in wayland not xwayland (uninstalled xwayland-satellite)

also just found out whenever an app crashes with this, there's a massive 100% spike in system drive utilization that doesn't go away till I kill the pid of crashing app

no idea what is happening

anasgets111 avatar Aug 17 '25 07:08 anasgets111

Sounds weird. WAYLAND_DEBUG=1 on wl-clip-persist and/or target app may help

YaLTeR avatar Aug 17 '25 07:08 YaLTeR

yeah no its still happening to me aswell on the latest git

HumpityDumpityDumber avatar Aug 17 '25 20:08 HumpityDumpityDumber

wl-clip-persist has caused stability issues every time I've tried it. Freezes, random crashes, paste not working... All sorts of fun shit. I recommend staying away from it. It seems broken.

This happened to me in Hyprland as well, so the problem is not specific to niri.

d-r avatar Aug 30 '25 20:08 d-r

Is there a good alternative so that I can have my clipboard persist that isn't a buggy mess? because yeah when it's not crashing an app it's just making me take two attempts to copy something.

HumpityDumpityDumber avatar Sep 01 '25 15:09 HumpityDumpityDumber

I'm not aware of a good alternative, unfortunately. Ever since wl-clip-persist rendered my system unusable, I've been a bit weary of experimenting with other Wayland clipboard utilities.

Not that wonky copy&paste is a Wayland-specific problem. In my two+ decades of using Linux, it's always been janky as hell, is the sad truth.

d-r avatar Sep 02 '25 07:09 d-r

Is there a good alternative so that I can have my clipboard persist that isn't a buggy mess? because yeah when it's not crashing an app it's just making me take two attempts to copy something.

I switched to clipmon, no issues so far.

philippowitz avatar Sep 08 '25 16:09 philippowitz

Is there a good alternative so that I can have my clipboard persist that isn't a buggy mess? because yeah when it's not crashing an app it's just making me take two attempts to copy something.

I switched to clipmon, no issues so far.

I tried that out and its causing me to need to copy something twice for it actually to be on my clipboard which uh isnt ideal

HumpityDumpityDumber avatar Sep 09 '25 15:09 HumpityDumpityDumber

Having this issue as well, no xwayland either Its forcing me to copy twice on most apps (im not using clipmon tho), but only seems to crash when using Electron apps Sometimes it simply freezes the apps other times it straight up crashes the entire session and restarts the display manager service Is there any workaround for this?

TophC7 avatar Nov 06 '25 14:11 TophC7

The "workaround" is to stop using wl-clip-persist, as it's what causing those problems in the first place. What you copy will vanish when the source application closes. Which is annoying. But decidedly less annoying than having to copy everything twice or have apps randomly freeze or crash.

It would appear that reliable "clipboard persistence" remains an unsolved problem in Wayland.

d-r avatar Nov 10 '25 14:11 d-r

The "workaround" is to stop using wl-clip-persist, as it's what causing those problems in the first place. What you copy will vanish when the source application closes. Which is annoying. But decidedly less annoying than having to copy everything twice or have apps randomly freeze or crash.

It would appear that reliable "clipboard persistence" remains an unsolved problem in Wayland.

But as far as Im aware im not using it, I dont have wl-clip-persist anywhere in my system. Only wl-clipboard and cliphist Im on nixos, i havent added it to my config, and it does not seem to be a dependency of any of my installed pkg

So if wl-clip-persist is truly the issue why am i having these problems as well?

TophC7 avatar Nov 11 '25 17:11 TophC7

Ah, alright... I would disable cliphist then, and see if that fixes it. All clipboard related issues I've experienced have come from running some clipboard utility in the background. Those same problems you described. I don't get any of them anymore now that the only clipboard tool I have installed is wl-clipboard. I'm on Arch btw, but the same was true back when I was using NixOS.

There does seem to be something about Wayland that makes clipboard functionality easy to break.

d-r avatar Nov 12 '25 13:11 d-r