Skip to content

Instantly share code, notes, and snippets.

@tbrowder
Created September 11, 2023 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbrowder/b80451afe3a91cf90e2dab183f4758ff to your computer and use it in GitHub Desktop.
Save tbrowder/b80451afe3a91cf90e2dab183f4758ff to your computer and use it in GitHub Desktop.
An xclip mockup forDebian OS
#== From: Max Nikulin <manikulin@gmail.com>
#== Subject: Re: xclip - how to use without a graphics display for testing on Github workflows
#== Date: Sun, 10 Sep 2023 23:48:28 +0700
#== Content-Type: text/plain; charset=UTF-8; format=flowed
#== Content-Transfer-Encoding: 7bit
#== Resent-From: debian-user@lists.debian.org
#== X-Mailing-List: <debian-user@lists.debian.org> archive/latest/803232
#== X-Loop: debian-user@lists.debian.org
#== List-Id: <debian-user.lists.debian.org>
#== List-URL: <https://lists.debian.org/debian-user/>
#== Resent-Date: Sun, 10 Sep 2023 16:49:01 +0000 (UTC)
#
# On 10/09/2023 16:44, Tom Browder wrote:
# > On Sat, Sep 9, 2023 at 21:06 Max Nikulin wrote:
# >
# >> You can create a mock-up and use it instead of real xclip binary.
# >
# > Sounds interesting, Max, can you show the code?
#
# Unless you need to test subtle issues like
#
# https://github.com/astrand/xclip/issues/20
# "Not closing stdout when setting clipboard from stdin"
#
# faced by e.g. tmux users, something simple should be enough:
#!/bin/sh -eu
: "${XCLIP_MOCK_FILE:=$HOME/.xclip-mock}"
while [ $# -gt 0 ]; do
case "$1" in
-i|-in)
;;
-o|--out) exec cat -- "$XCLIP_MOCK_FILE"
;;
-selection|-target) shift
;;
*) # FIXME xclip treats all unknown options at any position as files
break
;;
esac
shift
done
exec cat -- "$@" >"$XCLIP_MOCK_FILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment