Copy "entire" file (not just file content)
Hi there,
I have looked around this repo, but I haven't found a matching issue.
How can an "entire" file be copied to the clipboard so that it can be pasted into other applications like web-browsers or email-clients (e.g. as attachments)?
When I do something like $ wl-copy < my_document.pdf, it appearently only copies the file content, but not the entire file. I can not paste the copied file into another application with Ctrl+V.
What is the command to copy the entire file into the clipboard via wl-copy?
Hi, please see https://github.com/bugaevc/wl-clipboard/issues/26
In particular, something like this is likely to do what you want:
$ wl-copy -t text/uri-list "file://$(realpath my_document.pdf)"
Thanks for the quick reply! Unfortunately, this does not seem to work (and neither do the suggestions from the linked issue thread).
In Gnome, when I go to Nautilus and Ctrl+C on a file, $ wl-paste --list-types gives me
text/plain;charset=utf-8
text/uri-list
application/vnd.portal.files
application/vnd.portal.filetransfer
x-special/gnome-copied-files
and $ wl-paste returns
/home/user/my_document.pdf
and I can easily paste this file into other applications using Ctrl+V.
Now I tried doing $ wl-paste | wl-copy -t <type> where <type> is any of the above, then I tried to paste this into another application with Ctrl+V to see what happens; but nothing happend for any of the types (and I made sure to re-copy the file from Nautilus between trying this command with different types).
So this kind of seems like there must be something else that Nautilus is copying into the clipboard compared to wl-copy?
i came here cuz https://yazi-rs.github.io/docs/tips/#selected-files-to-clipboard wasn't working...
what i found was
wl-copy -t x-special/gnome-copied-files file:///home/vaisakh/Vide
os/getvid.mp4
now i can paste to thunar(maybe nautilus too?) file manager, but not to browser
wl-copy -t text/uri-list file:///home/vaisakh/Videos/getvid.mp4
now i can paste to browser (firefox)
can i specify both type at once?
wl-copy -t text/uri-list "file://$(realpath my_document.pdf)"
This especially does not work for portals as they use something different
Hi, this is still relevant and I would love to be able to do this. My use case is a screenshot script that copies the screenshot file to the clipboard.
I just created a pull request for this, https://github.com/bugaevc/wl-clipboard/pull/248
i am not that good at c, but i hope this will do..
Hi @Vaisakhkm2625 . Thanks for the effort and that is definitely better than nothing but there is still some necessary functionality missing because there are certain mime types, like application/vnd.portal.filetransfer that do special things behind the scenes -- for example for that mime type the "copied" data is just some numeric ID; I have not investigated how the ID is generated but it would require more advanced behaviour.
So, application/vnd.portal.filetransfer and application/vnd.portal.files are based on a D-Bus protocol: https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.FileTransfer.xml
wl-clipboard currently contains no dbus code. I think it would not be very good to add it just for this. The question is just, how many applications actually depend on that protocol?
So, application/vnd.portal.filetransfer and application/vnd.portal.files are based on a D-Bus protocol: https://github.com/flatpak/xdg-desktop-portal/blob/main/data/org.freedesktop.portal.FileTransfer.xml
wl-clipboard currently contains no dbus code. I think it would not be very good to add it just for this. The question is just, how many applications actually depend on that protocol?
:( i am not sure, but i assume almost all application that packaged under flatpak right? biggest issue is, it feel like it's own sub project, as it's not only need to support things like checking for flatpak permissions but i hope it also need to check for various inconsistencies of the implementations between different DEs...
wl-clipboard currently contains no dbus code. I think it would not be very good to add it just for this. The question is just, how many applications actually depend on that protocol?
Anything running as a Flatpak which on my system is e.g. Telegram, Signal, Discord...
OK, then I think we need the opinion of the maintainers. My instinct is to say that FlatPak should be responsible for that, i.e., bridging copied files into the flatpak sandbox. But I have no idea how that would work.
My instinct is to say that FlatPak should be responsible for that, i.e., bridging copied files into the flatpak sandbox. But I have no idea how that would work.
It already handles most of it as long as it's not about files. For files, however, there needs to be special care as the apps cannot access the original location. Generally the toolkits which initiate the copying already take care of that (e.g. GTK for GNOME Files, QT for Dolphin) but as this project completely sidesteps those and does everything manually we will need to do the talking to D-Bus ourselves
OK, then I think we need the opinion of the maintainers. My instinct is to say that FlatPak should be responsible for that, i.e., bridging copied files into the flatpak sandbox. But I have no idea how that would work.
but as this project completely sidesteps those and does everything manually we will need to do the talking to D-Bus ourselves
Indeed Flatpak/D-Bus has nothing to do with wl-clipboard. wl-clipboard interacts with the Wayland clipboard, not with clipboard implemented over other protocols like D-Bus or X11.
If you want to build an utility for copying files into clipboard in a Flatpak-aware way, you might use wl-clipboard as one of the components it builds on. Another other component might be busctl for example (which does D-Bus and not Wayland or X11). You'd call the D-Bus method to start a session and add the files to transfer, then copy the key into the Wayland clipboard using wl-clipboard.
OK, so for wl-clipboard we just need support for multiple mime types.
In terms of interface I like the look of something like wl-clipboard -t text/plain hello -t application/json '{"message":"hello"}' -t text/html '<p>hello</p>' but this is not practical if the strings to be copied start with dashes or come from stdin. So I don't know.