public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* substitute for xclip?
@ 2022-10-19  6:58 Ulli Horlacher
  2022-10-19  7:44 ` Sam Edge
  2022-10-19  9:01 ` Backwoods BC
  0 siblings, 2 replies; 10+ messages in thread
From: Ulli Horlacher @ 2022-10-19  6:58 UTC (permalink / raw)
  To: cygwin

With Linux I am using xclip to read the X11 clipboard.
Is there a cygwin equivalent to read the Windows clipboard?

My use case is:
The user copies file names to the clipboard and then starts a program
which processes these files.


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<20221019065805.GA17124@tik.uni-stuttgart.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  6:58 substitute for xclip? Ulli Horlacher
@ 2022-10-19  7:44 ` Sam Edge
  2022-10-19  7:54   ` Sam Edge
  2022-10-19  9:01 ` Backwoods BC
  1 sibling, 1 reply; 10+ messages in thread
From: Sam Edge @ 2022-10-19  7:44 UTC (permalink / raw)
  To: cygwin

Hi there.

In the absence of a Cygwin-native utility, how about?

x="$(powershell -command Get-Clipboard)"

You can pipe to the Windows 'clip' utility to go the other way or use
'powershell -command Set-Clipboard'.

But I agree, a Cygwin utility would be nice, unless there already is one?

--
Sam Edge

On 19/10/2022 07:58, Ulli Horlacher wrote:
> With Linux I am using xclip to read the X11 clipboard.
> Is there a cygwin equivalent to read the Windows clipboard?
>
> My use case is:
> The user copies file names to the clipboard and then starts a program
> which processes these files.
>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  7:44 ` Sam Edge
@ 2022-10-19  7:54   ` Sam Edge
  0 siblings, 0 replies; 10+ messages in thread
From: Sam Edge @ 2022-10-19  7:54 UTC (permalink / raw)
  To: cygwin

H again.

Or you can use:-

#!/bin/bash
shopt -s lastpipe
powershell -command Get-Clipboard | mapfile array_variable

for multiline.

--
Sam Edge

On 19/10/2022 08:44, Sam Edge wrote:
> Hi there.
>
> In the absence of a Cygwin-native utility, how about?
>
> x="$(powershell -command Get-Clipboard)"
>
> You can pipe to the Windows 'clip' utility to go the other way or use
> 'powershell -command Set-Clipboard'.
>
> But I agree, a Cygwin utility would be nice, unless there already is one?
>
> --
> Sam Edge
>
> On 19/10/2022 07:58, Ulli Horlacher wrote:
>> With Linux I am using xclip to read the X11 clipboard.
>> Is there a cygwin equivalent to read the Windows clipboard?
>>
>> My use case is:
>> The user copies file names to the clipboard and then starts a program
>> which processes these files.
>>
>>
>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  6:58 substitute for xclip? Ulli Horlacher
  2022-10-19  7:44 ` Sam Edge
@ 2022-10-19  9:01 ` Backwoods BC
  2022-10-19 11:56   ` Sam Edge
                     ` (2 more replies)
  1 sibling, 3 replies; 10+ messages in thread
From: Backwoods BC @ 2022-10-19  9:01 UTC (permalink / raw)
  To: cygwin

On Tue, Oct 18, 2022 at 11:59 PM Ulli Horlacher
<framstag@rus.uni-stuttgart.de> wrote:
>
> With Linux I am using xclip to read the X11 clipboard.
> Is there a cygwin equivalent to read the Windows clipboard?

There are 2 ways to access the clipboard:
1. The commands 'getclip' and 'putclip'
2. Redirection to/from /dev/clipboard

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  9:01 ` Backwoods BC
@ 2022-10-19 11:56   ` Sam Edge
  2022-10-19 12:58   ` Ulli Horlacher
  2022-10-20  3:23   ` Thomas Wolff
  2 siblings, 0 replies; 10+ messages in thread
From: Sam Edge @ 2022-10-19 11:56 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1: Type: text/plain, Size: 528 bytes --]


On 19/10/2022 10:01, Backwoods BC wrote:
 > On Tue, Oct 18, 2022 at 11:59 PM Ulli Horlacher
 > <framstag@rus.uni-stuttgart.de> wrote:
 >>
 >> With Linux I am using xclip to read the X11 clipboard.
 >> Is there a cygwin equivalent to read the Windows clipboard?
 >
 > There are 2 ways to access the clipboard:
 > 1. The commands 'getclip' and 'putclip'
 > 2. Redirection to/from /dev/clipboard
 >

Eek. I knew that. I use them all the time.

Apologies for the bad steer ... and for top-posting!

-- 
Sam Edge

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  9:01 ` Backwoods BC
  2022-10-19 11:56   ` Sam Edge
@ 2022-10-19 12:58   ` Ulli Horlacher
  2022-10-19 22:52     ` Oliver Schoede
  2022-10-20  3:23   ` Thomas Wolff
  2 siblings, 1 reply; 10+ messages in thread
From: Ulli Horlacher @ 2022-10-19 12:58 UTC (permalink / raw)
  To: cygwin

On Wed 2022-10-19 (02:01), Backwoods BC wrote:
> On Tue, Oct 18, 2022 at 11:59 PM Ulli Horlacher
> <framstag@rus.uni-stuttgart.de> wrote:
> 
> >
> > With Linux I am using xclip to read the X11 clipboard.
> > Is there a cygwin equivalent to read the Windows clipboard?
> 
> There are 2 ways to access the clipboard:
> 1. The commands 'getclip' and 'putclip'

W10dev:~: getclip
bash: getclip: command not found

I found getclip in package cygutils-extra.



> 2. Redirection to/from /dev/clipboard

https://fex.rus.uni-stuttgart.de/fop/jFZ6T7wI/X-20221019141237.png

I have selected [copy] in the file browser, but /dev/clipboard is empty.
Also getclip gives me no output.


-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/
REF:<CAKwdsS-QwFxpB0pG+3QCvjipHuB-e09sdGFJH01AG3YaVL7CeA@mail.gmail.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19 12:58   ` Ulli Horlacher
@ 2022-10-19 22:52     ` Oliver Schoede
  2022-10-20  7:27       ` Sam Edge
  0 siblings, 1 reply; 10+ messages in thread
From: Oliver Schoede @ 2022-10-19 22:52 UTC (permalink / raw)
  To: cygwin

Hi!

On Wed, 19 Oct 2022 14:58:42 +0200
Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:
>
>https://fex.rus.uni-stuttgart.de/fop/jFZ6T7wI/X-20221019141237.png
>
>I have selected [copy] in the file browser, but /dev/clipboard is
>empty. Also getclip gives me no output.
>


It looks to me like you copied the file, not the file name?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19  9:01 ` Backwoods BC
  2022-10-19 11:56   ` Sam Edge
  2022-10-19 12:58   ` Ulli Horlacher
@ 2022-10-20  3:23   ` Thomas Wolff
  2 siblings, 0 replies; 10+ messages in thread
From: Thomas Wolff @ 2022-10-20  3:23 UTC (permalink / raw)
  To: cygwin



Am 19.10.2022 um 11:01 schrieb Backwoods BC:
> On Tue, Oct 18, 2022 at 11:59 PM Ulli Horlacher
> <framstag@rus.uni-stuttgart.de> wrote:
>> With Linux I am using xclip to read the X11 clipboard.
>> Is there a cygwin equivalent to read the Windows clipboard?
> There are 2 ways to access the clipboard:
> 1. The commands 'getclip' and 'putclip'
> 2. Redirection to/from /dev/clipboard
>
There is also xsel and xclip; both need a running X server.
Note that *clip, xsel and xclip do not adapt character encoding, should 
you wish to transfer text between terminals of different 
encoding/locale. /dev/clipboard applies transparent character encoding 
conversion (as does the powershell trick).

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-19 22:52     ` Oliver Schoede
@ 2022-10-20  7:27       ` Sam Edge
  2022-10-20  8:12         ` Backwoods BC
  0 siblings, 1 reply; 10+ messages in thread
From: Sam Edge @ 2022-10-20  7:27 UTC (permalink / raw)
  To: cygwin

On 19/10/2022 23:52, Oliver Schoede wrote:
> Hi!
>
> On Wed, 19 Oct 2022 14:58:42 +0200
> Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:
>> https://fex.rus.uni-stuttgart.de/fop/jFZ6T7wI/X-20221019141237.png
>>
>> I have selected [copy] in the file browser, but /dev/clipboard is
>> empty. Also getclip gives me no output.
>>
>
> It looks to me like you copied the file, not the file name?
>
To clarify the above, Windows has a non-text clipboard data type when
'copying' a file in the File Explorer which encodes additional
information other than its path. This is to allow the equivalent 'paste'
function in Explorer and other file-accepting GUI applications to work
more intelligently. Unfortunately, Cygwin's /dev/clipboard and
get/putclip only process text formats.

I imagine your X file manager is simply copying a textual representation
of the file path to the clipboard when you choose 'copy' which of course
can be extracted by scripts etc. It appears that Windows Explorer
doesn't also place a textual representation onto the clipboard (the
Windows clipboard allows multiple representations to exist
simultaneously) which is what would be required for Cygwin to use it at
present.

--
Sam Edge


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: substitute for xclip?
  2022-10-20  7:27       ` Sam Edge
@ 2022-10-20  8:12         ` Backwoods BC
  0 siblings, 0 replies; 10+ messages in thread
From: Backwoods BC @ 2022-10-20  8:12 UTC (permalink / raw)
  To: cygwin

On Thu, Oct 20, 2022 at 12:27 AM Sam Edge <sam.edge.cygwin@gmx.com> wrote:
> On 19/10/2022 23:52, Oliver Schoede wrote:
> > Hi!
> >
> > On Wed, 19 Oct 2022 14:58:42 +0200
> > Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:
> >> https://fex.rus.uni-stuttgart.de/fop/jFZ6T7wI/X-20221019141237.png
> >>
> >> I have selected [copy] in the file browser, but /dev/clipboard is
> >> empty. Also getclip gives me no output.
> >>
> >
> > It looks to me like you copied the file, not the file name?
> >
> To clarify the above, Windows has a non-text clipboard data type when
> 'copying' a file in the File Explorer which encodes additional
> information other than its path. This is to allow the equivalent 'paste'
> function in Explorer and other file-accepting GUI applications to work
> more intelligently. Unfortunately, Cygwin's /dev/clipboard and
> get/putclip only process text formats.
>
> I imagine your X file manager is simply copying a textual representation
> of the file path to the clipboard when you choose 'copy' which of course
> can be extracted by scripts etc. It appears that Windows Explorer
> doesn't also place a textual representation onto the clipboard (the
> Windows clipboard allows multiple representations to exist
> simultaneously) which is what would be required for Cygwin to use it at
> present.
>
> --
> Sam Edge

You can force Windows Explorer to copy the path by doing
SHIFT-RightClick on the filename and selecting "Copy as path."

The next hurdle that you'll run into is that the clipboard contents
will be in Windows/DOS format (c:\folder\filename) while Cygwin will
most often expect it in *nix format (cygdrive/c/folder.filename).
'cygpath' is your friend. Sometimes (not clear exactly when) Cygwin
will accept the Windows path, but I always convert it to *nix format
to avoid unpleasant surprises later.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-10-20  8:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19  6:58 substitute for xclip? Ulli Horlacher
2022-10-19  7:44 ` Sam Edge
2022-10-19  7:54   ` Sam Edge
2022-10-19  9:01 ` Backwoods BC
2022-10-19 11:56   ` Sam Edge
2022-10-19 12:58   ` Ulli Horlacher
2022-10-19 22:52     ` Oliver Schoede
2022-10-20  7:27       ` Sam Edge
2022-10-20  8:12         ` Backwoods BC
2022-10-20  3:23   ` Thomas Wolff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).