Open AlejandroSuero opened 4 months ago
The unix implementation will likely fail in the near feature as xclip
will not work on systems using Wayland. This issue might best be resolved by providing users with the ability to override this internal function with their own and we can provide a few defaults for the most common ones.
@ethanholz What would you think should be the best way to approach it?
This is what first comes to my mind.
Adding an option such as:
local freeze = {
opts = {
-- ...
copy_cmd = ""
}
output = nil
}
-- ...
function freeze.copy(filename)
if freeze.opts.copy_cmd ~= "" then
-- use freeze.opts.copy_cmd
end
-- otherwise use the defaults?
end
I don't use Wayland so I was not familiar with those type of changes, sorry.
No worries on Wayland, I still appreciate the changes! let me think about implementation around the copy_cmd
this weekend and I can get back to you on that.
@ethanholz I made some changes for the copy
command to work properly.
For some reason it won't work unless outside a job
or spawn
, it will trigger it but ignore it. Since they are terminal commands I called them in os.execute
and it works fine now.
Tested it with both open
and copy
actions active (true) and it will trigger both.
@ethanholz I added the Wayland support, but reading into Wayland here I discovered that echo $XDG_SESSION_TYPE
could result in x11
if using Wayland under X11
system.
What do you think is the best way to show if using Wayland if this not enough to tell? Maybe using echo $WAYLAND_DISPLAY
and check if not nil
?
What do you think is the best way to show if using Wayland if this not enough to tell? Maybe using
echo $WAYLAND_DISPLAY
and check if notnil
?
I think this is good idea for a first pass and is good enough for review.
If they merge this PR https://github.com/charmbracelet/freeze/pull/97 it could be much easier, don't know exactly how it will work on Wayland
but is working on Windows, MacOS and the Manjaro that I have.
It is using gclip in case you want to test it on your machine.
If we can get this merged upstream I would much prefer to lean on that. Let's give it some time to see if your PR gets merged and if it does (it was reviewed so I'm hopeful), we can use that.
powershell
scriptpowershell
script demo from Windows11 VM:Image pasted from Windows11 VM:
osascript
osascript
demo from MacOS:Image from the script:
xclip
I didn't test it yet in Ubuntu, but the script looks fine from what I use to copy images myself. If
xclip
is not the way to do it, I will appreciate some suggestions.Closes #5