arboard icon indicating copy to clipboard operation
arboard copied to clipboard

Files & directories support by path

Open betamos opened this issue 3 years ago • 5 comments
trafficstars

I'm interested in getting the paths of files & directories copied from explorer/finder/etc. Is this a use case that will be supported?

I just tried on MacOS, and through the get_text() API I got the names of the files/dirs separated by \r, but not the full paths, nor a way to distinguish between regular text and file paths.

Thanks for creating and maintaining this library!

betamos avatar Jun 02 '22 15:06 betamos

There's a partial implementation for this on the any-format branch. If that branch gets finished; it could be merged to master and released. No-one is working on it as far as I know, so feel free to take it up.

ArturKovacs avatar Jun 04 '22 06:06 ArturKovacs

These are my higher-level findings so far:

Windows: clipboard-win has support for this in the high API. macOS: NSPasteboardURLReadingFileURLsOnlyKey lets you do a similar and read an array of file URLs from the clipboard. Linux: ???

complexspaces avatar Jun 04 '22 17:06 complexspaces

Apologies for late reply. This is great.

There's a partial implementation for this on the any-format branch.

Just checked it out. You got really far, but I also understand it's hard to keep working on it - it's a lot of formats!

Would you be willing to accept a smaller, incremental step in this direction by having file URLs supported with a similar API to today? For instance, simply by adding a get_file_paths() -> Result<Vec<PathBuf>, Error> API? If so, I'd be more than happy to take a stab.

Windows: clipboard-win has support for this in the high API. macOS: NSPasteboardURLReadingFileURLsOnlyKey lets you do a similar and read an array of file URLs from the clipboard.

Looks very promising. Thanks!

Linux: ???

Tried to research the X11 APIs - it looks a bit tricky but I can take another look when I'm less tired. I happened to see that GTK seems to support this directly. Could that be appropriate for this crate?

betamos avatar Jun 11 '22 09:06 betamos

Took a look at the X11 bindings, but it appears to be quite an undertaking. I couldn't justify investing that level of effort at the moment.

I made my own single-purpose crate for this to get something that works for my use case today: https://github.com/betamos/clipboard-files. It uses gtk for the linux implementation instead.

I'd still love to see file path support in this crate, and happy to help out if I can. Thanks.

betamos avatar Jun 13 '22 02:06 betamos

Please just expose this updates(https://github.com/DoumanAsh/clipboard-win/pull/24) for windows and accept text/uri-list atom on linux

enomado avatar Feb 01 '24 01:02 enomado