Skip to content

Instantly share code, notes, and snippets.

@qsh-zh
Last active February 29, 2020 20:10
Show Gist options
  • Save qsh-zh/617c47254efb3f74e325ea01bfbb4a1b to your computer and use it in GitHub Desktop.
Save qsh-zh/617c47254efb3f74e325ea01bfbb4a1b to your computer and use it in GitHub Desktop.
remote communicate with unit socket and service
echo "$@" | xclip -selection primary
echo "$@" | xclip -selection clipboard

Directory

Place all .socket and .service in ~/.config/user/

start socket

systemctl enable xclip.socket
systemctl start xclip.socket
systemctl status xclip.socket

Local Debug

echo "text to copy" | nc localhost 11988

SSH remote tunnel

Host xxx
Hostname xxx
RemoteForward 11988 localhost:11988

  • Not use sudo, xclip require to use DISPLAY. Otherwise, suffer from Error: Can't open display: (null)
  • pay attention to the name `[email protected]``
  • Theoretically, xclip only support file
[Unit]
Description=Network copy backend for tmux based on xclip
[Socket]
ListenStream=11988
Accept=yes
[Install]
WantedBy=sockets.target
[Unit]
Description=Copy backend service piping input to xclip
Requires=xclip.socket
[Service]
Type=simple
StandardInput=socket
ExecStart=/bin/bash /tmp/abc.sh
StandardOutput=socket
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment