You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The system clipboard silently fails to be read, via all Wayland compositors. #26832
Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation
This was originally reported at discussions/26745, where the reproduction method was more complex. However, I have confirmed that the undermentioned is sufficient, which Metekillot (@Metekillot) corroborates:
I wonder what utility the *-Clipboard cmdlets use? The help says it's xclip, but why do them work on a TTY (without X11)? And what should be used on Wayland?
Reacted by Mr Beedell, Roke Julian Lockhart and Michael Klement
PS /home/RokeJulianLockhart> Get-Command xclipGet-Command: The term 'xclip' is not recognized as a name of a cmdlet, function, script file, or executable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.PS /home/RokeJulianLockhart> Get-Error -Newest 1Exception :
Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The term 'xclip' is not recognized as a name of a cmdlet, function, script file, or executable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : xclipCategoryInfo : ObjectNotFound: (xclip:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CommandNotFoundExceptionCommandName : xclipMessage : The term 'xclip' is not recognized as a name of a cmdlet, function, script file, or executable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : xclipCategoryInfo : ObjectNotFound: (xclip:String) [Get-Command], CommandNotFoundExceptionFullyQualifiedErrorId : CommandNotFoundException,Microsoft.PowerShell.Commands.GetCommandCommandInvocationInfo :
MyCommand : Get-CommandScriptLineNumber : 1OffsetInLine : 1HistoryId : 1Line : Get-Command xclipStatement : Get-Command xclipPositionMessage : At line:1 char:1+ Get-Command xclip+ ~~~~~~~~~~~~~~~~~InvocationName : Get-CommandCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, <No file>: line 1PipelineIterationInfo :
0 1
Consequently, why does calling Get-Clipboard not raise an error? My $ErrorActionPreference is not SilentlyContinue. It's Continue.
If xclip isn't available, PowerShell falls back to an internal, PowerShell-only clipboard.
That is, with xclip not found to be installed on a Linux distro, Set-Clipboard foo && Get-Clipboard works, but only because Set-Clipboard was the command to fill the PowerShell-only clipboard.
Conversely, any clipboard provided by any other external utility will not be seen by Get-Clipboard.
Reacted by Mr Beedell, Roke Julian Lockhart and 237dmitry
Michael Klement (@mklement0), might I create a separate FR to modify that behaviour? I don't see a use case for it, without, at the least, informing the user that the system clipboard is unavailable.
The use case is that as long as it is Set-Clipboard that's filling the clipboard, Get-Clipboard will work as expected.
That said: Yes, it's worth creating a feature request.
My hunch is that, in the interest of maintaining backward compatibility, the most realistic solution is to require -Verbose in order to be informed of the unavailability of PowerShell-transcendent functionality.
GNOME 50 is out and removes X11 entirely in favor of Wayland, which is going to affect most linux distributions soon, so a Wayland fallback is pretty important. In fact, we're moving toward a situation where Wayland should probably be the primary clipboard with a fallback to X11.
xclip is annoying - still unfixed, unclosed PR. 'pwsh' as a linux shell hardcodes 'xclip'.
wl-copy is needed
Solution? Save as ~/tmp/xclip-wayland-shim.sh
xclip-wayland-shim.sh
#!/usr/bin/env bashset -euo pipefail
# Install an xclip shim that forwards to wl-clipboard on Wayland, so# PowerShell's Set-Clipboard/Get-Clipboard (which hardcode `xclip` on# Linux) work in a Wayland session.## Usage:# bash ./path/to/xclip-wayland-shim.sh# source ~/.bashrc
target_user="${SUDO_USER:-${USER:-$(id -un)}}"ifcommand -v getent >/dev/null 2>&1;then
target_home="$(getent passwd "$target_user"| cut -d: -f6 || true)"else
target_home="${HOME:?HOME is not set and getent is unavailable}"fiif [[ -z"$target_home"||!-d"$target_home" ]];thenprintf'Could not resolve a home directory for %s.\n'"$target_user">&2exit 1
fi
bin_dir="$target_home/.local/bin"
shim="$bin_dir/xclip"
bashrc="$target_home/.bashrc"
mkdir -p "$bin_dir"
cat >"$shim"<<'SHIM'#!/bin/sh# xclip shim: forward to wl-clipboard on Wayland, real xclip otherwise.# Installed by xclip-wayland-shim.sh; safe to re-run.if [ -n "${WAYLAND_DISPLAY:-}" ]; then case "$*" in *"-out"*) if command -v wl-paste >/dev/null 2>&1; then exec wl-paste fi ;; *) if command -v wl-copy >/dev/null 2>&1; then exec wl-copy fi ;; esacfi# Fall back to the real xclip. Absolute paths avoid re-entering this shim.for candidate in /usr/bin/xclip /bin/xclip; do if [ -x "$candidate" ]; then exec "$candidate" "$@" fidoneprintf 'xclip shim: no clipboard backend found (install wl-clipboard for Wayland, xclip for X11)\n' >&2exit 1SHIM
chmod +x "$shim"
path_line="export PATH=\"$bin_dir:\$PATH\""
touch "$bashrc"if! grep -Fqx -- "$path_line""$bashrc";thenprintf'\n# xclip Wayland shim\n%s\n'"$path_line">>"$bashrc"printf'Added to %s: %s\n'"$bashrc""$path_line"elseprintf'Bash PATH already contains the shim entry in %s.\n'"$bashrc"fiif [[ $(id -u)-eq 0 &&"$target_user"!= root ]];then
chown "$target_user":"$(id -gn "$target_user")""$shim""$bashrc"fiexport PATH="$bin_dir:$PATH"
resolved="$(command -v xclip || true)"if [[ -z"$resolved" ]];thenprintf'xclip not found on PATH after install.\n'>&2exit 1
fiprintf'xclip shim: %s\n'"$shim"printf'xclip resolves to: %s\n'"$resolved"printf'This script refreshed PATH for itself. Run: source %q\n'"$bashrc"printf'pwsh Set-Clipboard/Get-Clipboard now work on Wayland (needs wl-clipboard).\n'
Then run: bash ./xclip-wayland-shim.sh & source ~/.bashrc
Set-Clipboard is otherwise a dead, non-erroring cmdlet.
This fixes so stdin & out work under xclip without using anything but a fancy shim.
Other solution, i.e. Practical options on Wayland:
Just use the native tools, even from pwsh: Get-Content file | wl-copy / wl-paste.
If you're on X11 (or XWayland with $DISPLAY set), pacman -S xclip makes the cmdlets work.
(the above fix) A fun hack that exploits the hardcoded binary name: shadow xclip with a shim earlier on your PATH that translates to wl-clipboard on Wayland:
That covers exactly the two call patterns pwsh uses (-selection clipboard -in / -out), and both read/write stdin/stdout just like wl-copy/wl-paste do.
So the read is correct: as of 7.6.6, Set-Clipboard on a Wayland-only system is functionally dead — it's an xclip-only implementation with a silent in-memory fallback, and Wayland support is still an open gap upstream.
changed the title [-]7.5.4 cannot read the clipboard on Wayland.[/-][+]The system clipboard silently fails to be read, via all Wayland compositors.[/+]on Oct 21, 2026
The @PowerShell/wg-powershell-cmdlets discussed this. We agree that for Linux, the clipboard cmdlets should use the Wayland tools if xclip is not available.
CommanderTurtle, yes; that's an abstraction above XClip. That's what I desire. However, what I quoted indicated that an implementation to solve this may merely check for the existence of XClip installed, rather than consider XClip's compatibility with its environment.
BTW, best to paste text as actual text, rather than a screenshot, when feasible. Consider anyone who utilises a screen reader; OCR tools shall struggle with that.
For sure. The reply above had a full code reply inlined. Might've been overthinking it. I was just restating in case it was a simple check to see if xclip responds, since it would be much more robust to rather check for the package through the applicable package manager: pacman -Q xclip, etc. In this case though, just wanted to mention all of omarchy faces this trouble with powershell (Powershell effectively has no clipboard for all omarchy users - unless they run a shim workaround and stumbled on these very issue discussion threads).
off-topic
I don't see anyone using the internet from cli nowadays, but, your advice makes sense.
The information contained within the image is in text above though in the codeblock, so, no info lost at least.
WebAssembly build of paddle-ocr for console screen readers, if you're stumbling on this in the future from terminal emulator --> ppocr-wasm
I was just restating in case it was a simple check to see if xclip responds, since it would be much more robust to rather check for the package through the applicable package manager: pacman -Q xclip, etc.
CommanderTurtle, hence the previous reference to $Env:PATH; Get-Command provides that.
In this case though, just wanted to mention all of omarchy faces this trouble with powershell (Powershell effectively has no clipboard for all omarchy users - unless they run a shim workaround and stumbled on these very issue discussion threads).
That is true for all Wayland DEs, to the same degree. No PowerShell clipboard exists for any Wayland DE.
Turns out I was wrong. A package manager check isn't enough. Lol. Omarchy's hyprland shows xclip but only wl-clip is the proved working path. After shim, xclip still responds to package manager call.
PS /home/alienuser>$Env:PATH-split':'/usr/lib/powershell-7/home/alienuser/.local/bin
/home/alienuser/.bun/bin
/home/alienuser/.cache/.bun/bin
/opt/cuda/bin
/home/alienuser/.local/share/mise/installs/bun/latest/bin
/home/alienuser/.local/share/mise/installs/codex/latest/bin
/home/alienuser/.local/share/mise/dotnet-root
/home/alienuser/.local/share/mise/installs/gh/latest/gh_2.103.3_linux_amd64/bin
/home/alienuser/.local/share/mise/installs/github-can1357-oh-my-pi/latest
/home/alienuser/.local/share/mise/installs/node/26.12.1/bin
/home/alienuser/.local/share/mise/installs/npm-playwright/latest/node_modules/.bin
/home/alienuser/.local/share/mise/installs/python/3.15/bin
/home/alienuser/.local/share/mise/installs/ruby/latest/bin
/home/alienuser/.local/share/mise/shims
/usr/share/omarchy/bin
/home/alienuser/.cargo/bin
/home/alienuser/.local/share/../bin
/usr/local/sbin
/usr/local/bin
/usr/bin
/opt/cuda/bin
/usr/bin/site_perl
/usr/bin/vendor_perl
/usr/bin/core_perl
PS /home/alienuser>Get-Command xclip
CommandType Name Version Source
----------------------------
Application xclip 0.0.0.0/home/alienuser/.local/bin/xclip
PS /home/alienuser>if (Get-Command xclip -ErrorAction SilentlyContinue) {
>>"xclip is available">> } else {
>>"xclip NOT found in PATH">> }
xclip is available
PS /home/alienuser>Get-Command xclip -All
CommandType Name Version Source
----------------------------
Application xclip 0.0.0.0/home/alienuser/.local/bin/xclip
Application xclip 0.0.0.0/home/alienuser/.local/share/../bin/xclip
Application xclip 0.0.0.0/usr/bin/xclip
PS /home/alienuser> echo @'>> A more correct route...?>> '@; echo @'>> Check for wl-clipboard, then xclip:>> '@; (pacman -Ql wl-clipboard 2>$null | Select-String '/bin/'); (pacman -Ql xclip 2>$null | Select-String '/bin/') A more correct route...?Check for wl-clipboard, then xclip:wl-clipboard /usr/bin/wl-clipboard /usr/bin/wl-copywl-clipboard /usr/bin/wl-pastexclip /usr/bin/xclip /usr/bin/xclipxclip /usr/bin/xclip-copyfilexclip /usr/bin/xclip-cutfilexclip /usr/bin/xclip-pastefilePS /home/alienuser> pacman -Q xclip; pacman -Q wl-clipboardxclip 0.13-6wl-clipboard 1:2.3.0-1
Makes this even more convoluted to shim installers.
PowerShell has no idea what your compositor is. It's all env vars and loginctl...
Proper method is probably then a test just simply if "Set-Clipboard" modifies the clipboard. If both are installed fallover to wl-clipboard - due to xwayland being wonky to begin with.
This is the whole reason to care which binary is real. On omarchy, xclip only works via XWayland — and it hangs forever if no X socket exists, which is a miserable failure mode in a script.
If ~/.local/bin/xclip turns out to be a shim that execs wl-clipboard (a common trick people use to make xclip scripts work on Wayland), that explains everything — and you'd want to keep it, not "fix" it by putting /usr/bin first.
Second command apparently hangs... which I guess, is a good thing! Science succeeded.
Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdletsgeneral cmdlet issuesWG-ReviewedA Working Group has reviewed this and made a recommendation
Activity
237dmitry commentedon Feb 15, 2026
I wonder what utility the *-Clipboard cmdlets use? The help says it's xclip, but why do them work on a TTY (without X11)? And what should be used on Wayland?
0009-0009-1013-986X commentedon Feb 15, 2026
237dmitry,
blob/08b13f24e6d359877b2cdbe650f7c8fc5ca20135/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.csdefines it:PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/GetClipboardCommand.cs
Lines 1 to 116 in 08b13f2
However, I do not know where
GetTextis defined, nor whyPlatformNotSupportedExceptionis not raised, at the least.mklement0 commentedon Feb 15, 2026
PowerShell/src/Microsoft.PowerShell.Commands.Management/commands/management/Clipboard.cs
Line 62 in 08b13f2
xclipis used on Linux, andpbpasteon macOS.[-]7.5.4 cannot read the clipboard.[/-][+]7.5.4 cannot read the clipboard on Wayland.[/+]0009-0009-1013-986X commentedon Feb 15, 2026
Michael Klement (@mklement0),
Get-Command xclipraises:Consequently, why does calling
Get-Clipboardnot raise an error? My$ErrorActionPreferenceis notSilentlyContinue. It'sContinue.mklement0 commentedon Feb 15, 2026
If
xclipisn't available, PowerShell falls back to an internal, PowerShell-only clipboard.That is, with
xclipnot found to be installed on a Linux distro,Set-Clipboard foo && Get-Clipboardworks, but only becauseSet-Clipboardwas the command to fill the PowerShell-only clipboard.Conversely, any clipboard provided by any other external utility will not be seen by
Get-Clipboard.0009-0009-1013-986X commentedon Feb 15, 2026
Michael Klement (@mklement0), might I create a separate FR to modify that behaviour? I don't see a use case for it, without, at the least, informing the user that the system clipboard is unavailable.
mklement0 commentedon Feb 15, 2026
The use case is that as long as it is
Set-Clipboardthat's filling the clipboard,Get-Clipboardwill work as expected.That said: Yes, it's worth creating a feature request.
My hunch is that, in the interest of maintaining backward compatibility, the most realistic solution is to require
-Verbosein order to be informed of the unavailability of PowerShell-transcendent functionality.0009-0009-1013-986X commentedon Feb 16, 2026
brianary commentedon Mar 21, 2026
GNOME 50 is out and removes X11 entirely in favor of Wayland, which is going to affect most linux distributions soon, so a Wayland fallback is pretty important. In fact, we're moving toward a situation where Wayland should probably be the primary clipboard with a fallback to X11.
GNOME 50 debuts with X11 axed, Wayland front and center • The Register
CommanderTurtle commentedon Oct 20, 2026
xclip is annoying - still unfixed, unclosed PR. 'pwsh' as a linux shell hardcodes 'xclip'.
wl-copy is needed
Solution? Save as
~/tmp/xclip-wayland-shim.shxclip-wayland-shim.sh
Then run:
bash ./xclip-wayland-shim.sh & source ~/.bashrcSet-Clipboardis otherwise a dead, non-erroring cmdlet.This fixes so stdin & out work under xclip without using anything but a fancy shim.
Other solution, i.e. Practical options on Wayland:
Get-Content file | wl-copy/wl-paste.$DISPLAYset),pacman -S xclipmakes the cmdlets work.xclipwith a shim earlier on your PATH that translates to wl-clipboard on Wayland:That covers exactly the two call patterns pwsh uses (
-selection clipboard -in/-out), and both read/write stdin/stdout just like wl-copy/wl-paste do.So the read is correct: as of 7.6.6,
Set-Clipboardon a Wayland-only system is functionally dead — it's an xclip-only implementation with a silent in-memory fallback, and Wayland support is still an open gap upstream.picture of working shim
brianary commentedon Oct 21, 2026
KDE has now followed GNOME in switching to Wayland. This will soon represent the vast majority of linux systems.
KDE turns 30 with Plasma 6.8, remote upgrades, and an X11 farewell - Ars Technica
1 remaining item
[-]7.5.4 cannot read the clipboard on Wayland.[/-][+]The system clipboard silently fails to be read, via all Wayland compositors.[/+]SteveL-MSFT commentedon Nov 4, 2026
The @PowerShell/wg-powershell-cmdlets discussed this. We agree that for Linux, the clipboard cmdlets should use the Wayland tools if xclip is not available.
0009-0009-1013-986X commentedon Nov 4, 2026
Steve Lee (@SteveL-MSFT), would XClip function with a non-X{Org} compositor, even if it were in
$Env:PATH?CommanderTurtle commentedon Nov 4, 2026
If the shim is performed like above 😂
Details
0009-0009-1013-986X commentedon Nov 4, 2026
CommanderTurtle, yes; that's an abstraction above XClip. That's what I desire. However, what I quoted indicated that an implementation to solve this may merely check for the existence of XClip installed, rather than consider XClip's compatibility with its environment.
BTW, best to paste text as actual text, rather than a screenshot, when feasible. Consider anyone who utilises a screen reader; OCR tools shall struggle with that.
CommanderTurtle commentedon Nov 4, 2026
For sure. The reply above had a full code reply inlined. Might've been overthinking it. I was just restating in case it was a simple check to see if xclip responds, since it would be much more robust to rather check for the package through the applicable package manager:
pacman -Q xclip, etc. In this case though, just wanted to mention all of omarchy faces this trouble with powershell (Powershell effectively has no clipboard for all omarchy users - unless they run a shim workaround and stumbled on these very issue discussion threads).off-topic
I don't see anyone using the internet from cli nowadays, but, your advice makes sense.
The information contained within the image is in text above though in the codeblock, so, no info lost at least.
WebAssembly build of paddle-ocr for console screen readers, if you're stumbling on this in the future from terminal emulator --> ppocr-wasm
0009-0009-1013-986X commentedon Nov 4, 2026
CommanderTurtle, hence the previous reference to
$Env:PATH;Get-Commandprovides that.That is true for all Wayland DEs, to the same degree. No PowerShell clipboard exists for any Wayland DE.
CommanderTurtle commentedon Nov 5, 2026
Turns out I was wrong. A package manager check isn't enough. Lol. Omarchy's hyprland shows xclip but only wl-clip is the proved working path. After shim, xclip still responds to package manager call.
Makes this even more convoluted to shim installers.
PowerShell has no idea what your compositor is. It's all env vars and
loginctl...Proper method is probably then a test just simply if "Set-Clipboard" modifies the clipboard. If both are installed fallover to wl-clipboard - due to xwayland being wonky to begin with.
This is the whole reason to care which binary is real. On omarchy,
xcliponly works via XWayland — and it hangs forever if no X socket exists, which is a miserable failure mode in a script.And to sanity-check that the winner on PATH actually functions rather than merely existing:
If
~/.local/bin/xclipturns out to be a shim thatexecswl-clipboard(a common trick people use to makexclipscripts work on Wayland), that explains everything — and you'd want to keep it, not "fix" it by putting/usr/binfirst.Second command apparently hangs... which I guess, is a good thing! Science succeeded.
0009-0009-1013-986X commentedon Nov 5, 2026
CommanderTurtle, that's probably worth a PR for
astrand/xclip, citing this andissues/62#issuecomment-966020595as examples of interest in it.