Replies: 8 comments
-
|
Turns out the resource you need is either so scarce or no longer exists. But it's alright, if i manage to get a way to get clipboard or drag and drop work i'll comment it here in detail until you're back. |
Beta Was this translation helpful? Give feedback.
-
|
Here's what i am doing to have it sync my clipboard: #!/bin/bash
ips=($(cat ~/.config/clip-iplist))
clsport=${1:-52111}
listen_clipboard() {
for ip in "${ips[@]}"; do
socat TCP-LISTEN:$clsport,fork EXEC:"wl-copy" &
done
}
send_clipboard() {
while clipnotify; do
content=$(wl-paste -n)
for ip in "${ips[@]}"; do
echo "$content" | socat - TCP:$ip:$clsport
done
done
}
listen_clipboard &
send_clipboardJust keep the IPs you wanna sync in Issues:
It's not 100% solid, but i am using it right now. |
Beta Was this translation helpful? Give feedback.
-
|
And here is my script which is SSH-based instead of Key points
Limitations
Usage$ pushclipboard -h
Usage:
/home/deck/projects/shell-utils/pushclipboard [ -v ] [ -t {n} ] [ -4 | -6 ] [ -x | -w ] [ -i sshkey ] {target computer}
Copies the content of Wayland's clipboard to the target computer
Options:
-t {n} timeout for n seconds
-4 connect SSH over IPv4
-6 connect SSH over IPv6
-w use Wayland (auto-detected)
-x use X11 (fall-back)
-v verbose
-i [sshkey] Use sshkey as identity
-f build authorized_keys' forced-command line
Caution You absolutely SHOULD consider setting up SSH forced commands as per the Howto bellow for security reasons, even if HowtoThis is how you configure your local (sender) machine, so that it can push the content of the clipboard to a remote (receiver) machine. SSH KeyFirst you need to create a passphrase-less SSH key-pair dedicated to this script: ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_clipboardoutput of `ssh-keygen`Generating public/private ed25519 key pair.
Enter passphrase for "/home/dryak/.ssh/id_ed25519_clipboard" (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/dryak/.ssh/id_ed25519_clipboard
Your public key has been saved in /home/dryak/.ssh/id_ed25519_clipboard.pub
The key fingerprint is:
SHA256:HRsePTditXVegjurN7o+Rq3R5gTThnXwkM/nX8yJV1M deck@steamdeck
The key's randomart image is:
+--[ED25519 256]--+
| o+o +|
| .++.=E|
| ++=== o|
| o+*=+ooo|
| S +* o.=+|
| o *. o=|
| . B . o|
| = + .|
| o+= . |
+----[SHA256]-----+Tip
SSH Forced CommandsgenerateWe will use forced commands, so that in case of leaked key, the worst that can happen is random shit copied into the clipboard (not even the clipboard content could be inspected, and no arbitrary commands could be run). Use the pushclipboard -foutput of `pushclipboard -f`Found key: /home/dryak/.ssh/id_ed25519_clipboard
# forced command in ~/.ssh/authorized_keys
# Wayland
command="/usr/bin/env WAYLAND_DISPLAY='wayland-0' wl-copy; echo copied",no-agent-forwarding,no-pty,no-X11-forwarding ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK0a9JD/Hwda0HdFKTk64nLAYoPDUFezEHgOjpCqvMwC dryak@nereid
# X11
command="xclip -display :0 -in -rmlastnl -selection clipboard; echo copied",no-agent-forwarding,no-pty,no-X11-forwarding ssh-ed25519 AAAAAC3NzaC1lZDI1NTE5AAAAIK0a9JD/Hwda0HdFKTk64nLAYoPDUFezEHgOjpCqvMwC dryak@nereidconfigure remote receiving endDepending on what desktop environment the remote (receiver) machine is running, copy the appropriate [deck@steamdeck ~]$ nano ~/.ssh/authorized_keysTip if the .ssh configuration directory does not exist for that user on the remote machine, you need to create it with the approriate access rights: mkdir -m 0700 ~/.sshTest it on the CLIOn the local (sender) machine, copy something into the clipboard, either with the mouse, the keyboard, or the command line: date --rfc-3339=seconds | wl-copyTry pushing the content of the keyboard to the remote (receiver) machine using the script on the command line interface: pushclipboard steamdeck.localoutput of `pushclipboard steamdeck.local`Found key: /home/dryak/.ssh/id_ed25519_clipboard
Pushing clipboard to steamdeck.local using wl-paste on Wayland...
copiedTip
Check that the remote (receiver) machine successfully put the string in its clipboard, either by checking the clipboard, or by pasting with the mouse, the keyboard, or the command line: [deck@steamdeck ~]$ xclip -o -selection clipboard
2025-07-25 12:03:23+02:00or [dryak@nereid ~]$ wl-paste
2025-07-25 12:03:23+02:00Configure lan-mouseOn the local (sender) machine you can edit the configuration file: nano ~/.config/lan-mouse/config.tomland add the # …other clients…
[[clients]]
position = "right"
hostname = "steamdeck.home"
activate_on_startup = true
ips = ["10.0.1.16"]
port = 4242
enter_hook="/home/dryak/bin/pushclipboard steamdeck.local"Important
Test it in lan-mouseNow test that in lan-mouse, when moving the cursor from a Wayland Linux instance to another Linux instance, the clipboard gets copied over. lan-mouse's logs…
[2025-07-25T10:46:28Z WARN lan_mouse::capture] releasing capture: not connected
[2025-07-25T10:46:28Z INFO lan_mouse::connect] client 1 connecting ...
[2025-07-25T10:46:28Z INFO lan_mouse::connect] client (1) connecting ... (ips: [10.0.1.16:4242])
[2025-07-25T10:46:28Z INFO lan_mouse::connect] connecting to 10.0.1.16:4242 ...
[2025-07-25T10:46:28Z INFO lan_mouse::service] entering client 1 ...
[2025-07-25T10:46:28Z INFO lan_mouse::service] spawning command!
Found key: /home/dryak/.ssh/id_ed25519_clipboard
Pushing clipboard to steamdeck.local using wl-paste on Wayland...
copied
[2025-07-25T10:46:29Z INFO lan_mouse::service] /home/dryak/bin/pushclipboard steamdeck.local exited successfully
…Rinse and repeatYou can repeat the above steps to add more machines. Tip Depending on how paranoid you are with your keys, you can skip the SSH Keys generation, and simply reuse the Important Due to lan-mouse not yet supporting X11 capture, you can only configure Wayland lan-mouse instance with the hook. Source codepushclipboard#!/bin/bash
declare -a timeout
declare -a read_t
declare -a ssh_options
ssh_key=
buildline=0
gfxsys=
usage() {
cat <<HELP
Usage:
$0 [ -v ] [ -t {n} ] [ -4 | -6 ] [ -x | -w ] [ -i sshkey ] {target computer}
Copies the content of Wayland's clipboard to the target computer
Options:
-t {n} timeout for n seconds
-4 connect SSH over IPv4
-6 connect SSH over IPv6
-w use Wayland (auto-detected)
-x use X11 (fall-back)
-v verbose
-i [sshkey] Use sshkey as identity
-f build authorized_keys' forced-command line
HELP
exit "$1"
}
# Process options
while getopts "t:46wxvi:f-:h" o; do
case "${o}" in
t)
timeout=( timeout "${OPTARG}" )
read_t=( '-t' "${OPTARG}" )
;;
4|6|v) ssh_options+=( "-${o}" ) ;;
i) ssh_key="${OPTARG}"
if [[ ! -r "${ssh_key}" ]]; then
echo "Cannot read ${ssh_key}" 1>&2
exit 2
else
echo "Using ${ssh_key}"
fi
;;
f) buildline=1 ;;
w) gfxsys=wayland ;;
x) gfxsys=x11 ;;
h) usage 0 ;;
-) case "${OPTARG}" in
help) usage 0 ;;
*) printf 'Bad option %s\n\n' "${OPTARG}"; usage 2 1>&2 ;;
esac
;;
*) printf 'Bad option %s\n\n' "${o}"; usage 2 1>&2 ;;
esac
done
shift $((OPTIND-1))
if [[ -z "${1}" ]] && (( ! buildline )); then
usage 2
else
target="${1}"
fi
# Search clipboard-specific SSH key
if [[ -z "${ssh_key}" ]]; then
search_ssh_key=( ~/.ssh/id_*_clipboard )
if [[ -r "${search_ssh_key[0]}" ]]; then
ssh_key="${search_ssh_key[0]}"
printf 'Found key:\t%s\n' "${ssh_key}"
fi
fi
# Build forced command line for the authorized keys config
if (( buildline )); then
echo '# forced command in ~/.ssh/authorized_keys'
if [[ -z "${ssh_key}" ]]; then
echo 'No key available to build a forced-command line' 1>&2
exit 1
fi
echo "# Wayland"
printf "command=\"/usr/bin/env WAYLAND_DISPLAY='wayland-0' wl-copy; echo copied\",no-agent-forwarding,no-pty,no-X11-forwarding %s\n" "$(< "${ssh_key%.pub}.pub" )"
echo "# X11"
printf 'command="xclip -display :0 -in -rmlastnl -selection clipboard; echo copied",no-agent-forwarding,no-pty,no-X11-forwarding %s\n' "$(< "${ssh_key%.pub}.pub" )"
exit 0
fi
# Auto-detect display server
if [[ -n "${gfxsys}" ]]; then
:
elif [[ "${XDG_SESSION_TYPE,,}" =~ wayland|x11 ]]; then
gfxsys="${XDG_SESSION_TYPE,,}"
elif [[ -n "${WAYLAND_DISPLAY}" ]]; then
gfxsys=wayland
echo "Wayland detected"
elif [[ -n "${DISPLAY}" ]]; then
gfxsys=x11
echo "X11 detected"
fi
# Display-specific command
clipcmd=
if [[ "${gfxsys,}" == "x11" ]]; then
clipcmd=( xclip -out -rmlastnl -selection clipboard ) # -display :0
else
clipcmd=( wl-paste --no-newline )
fi
# Copy-Paste time!
echo "Pushing clipboard to ${target} using ${clipcmd[0]} on ${gfxsys^}..."
while read ${read_t:+ "${read_t[@]}" } -r result; do
ssh_pid="$!"
echo -e "${result}"
kill -TERM "${ssh_pid}"
exit 0
done < <(
exec \
${timeout:+ "${timeout[@]}" } \
ssh \
${ssh_options:+ "${ssh_options[@]}" } \
${ssh_key:+ -o"ControlPath none" -o"IdentitiesOnly yes" -i "${ssh_key}"} \
"${target}" \
-- \
/usr/bin/env WAYLAND_DISPLAY="wayland-0" wl-copy \; \
echo copied \
< <( "${clipcmd[@]}" ) \
|| echo "fail ?" >&2
)
echo "timeout" >&2
exit 1TODO
|
Beta Was this translation helpful? Give feedback.
-
|
@kevinJ045
You paid attentions to avoid trailing lines with content="$(wl-paste -n)"
for ip in "${ips[@]}"; do
echo -n "$content" | socat - TCP:$ip:$clsportalso side-note, as you're using bash: echo -n "${content}" > "/devtcp/${ip}/${clsport}"Also, FYI, I am trying to gather a collection of what people have implemented as solutions for clipboard sharing, so we can try to properly document it into lan-mouse. I think we could add yours, too. |
Beta Was this translation helpful? Give feedback.
-
|
A very simple way I've found to get clipboard syncing to work is by using https://github.com/quackduck/uniclip. Once installed, you can run One downside I've found with uniclip is that you currently cannot directly target which network interface you want to use, however the network interface it chooses from what I've found is consistent and will always choose the same network interface given the same network configuration. I would first try running Additionally, you can set the port using the |
Beta Was this translation helpful? Give feedback.
-
|
Additionally, I've found that |
Beta Was this translation helpful? Give feedback.
-
|
i let KDE Connect handle the clipboard and it works fine |
Beta Was this translation helpful? Give feedback.
-
|
Note for people who run Plasma 6.5 and use the "focus stealing prevention" options: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
The roadmap in the main readme still lists clipboard unchecked:
While technically true, as lan-mouse's own protocol doesn't (and can't easily for technical reasons around UDP realtime communications) carry clipboard content, in practice clipboard sharing works like a charm (see #105) thanks to hooks, and external tools such as wl-clipboard/wl-clipboard-rs and xclip (for clipboard management) and SSH forced commands (for encryption and security) or Syncthing (keeping clipboard history synced)
In this HOWTO issue, several users have documented their respective solutions for sharing clipboard content.
TODO
Link this issue from the roadmap.
UPDATE
Beta Was this translation helpful? Give feedback.
All reactions