You are not logged in.
Pages: 1
I'm using xclip, shotgun, and hacksaw as a screenshot tool. This is the script I have, attached to the keyboard print key -
selection=$(hacksaw); shotgun -g $selection - | xclip -t image/png -selection clipboard
But xclip copies the image as text, making it unusable. I confirmed this by running xclip -o -t TARGETS right after copying, and I got this -
TIMESTAMP
TARGETS
MULTIPLE
UTF8_STRING
COMPOUND_TEXT
TEXT
STRING
text/plain;charset=utf-8
text/plain
As you can see, there is no image/png MIME type, despite me explicitly stating the copied image as having that type. I would like the image to be copied as an image/png.
The Arch Linux system has been freshly (re)installed, but it didn't work before either. The reinstall was irrelevant to this issue.
Offline
I guess you're trying the hacksaw example from shotgun readme ?
The example has single quotes around image/png , if you add those do the results differ ?
Another possibility is differences between archlinux xclip and NixOS xclip . You could try asking upstream if they tested that example on archlinux .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I have similar script using maim and xclip, and it works ( image remains image )
maim -u -s | xclip -selection clipboard -t image/png
EDIT: I installed shotgun to check this and it works as well, here is my script
#!/bin/bash
FILE=/tmp/image.png
COUNT=1
while [ -f $FILE ]; do
FILE=/tmp/image$COUNT.png
COUNT=$(( $COUNT + 1 ))
done
#maim -u -s | xclip -selection clipboard -t image/png
sel=$(slop -f "-i %i -g %g")
shotgun $sel - | xclip -selection clipboard -t image/png
xclip -selection clipboard -o > $FILE
notify-send -u normal "Image copied to clipboard and $FILE"
This script copies image to clipboard as well as to a file in /tmp folder.
I don't get image/png, in "xclip -o -t TARGETS" as well.
Last edited by Docbroke (2021-07-15 12:38:37)
Arch is home!
https://github.com/Docbroke
Offline
I guess you're trying the hacksaw example from shotgun readme ?
The example has single quotes around image/png , if you add those do the results differ ?
Another possibility is differences between archlinux xclip and NixOS xclip . You could try asking upstream if they tested that example on archlinux .
I have tried them both, neither work
Offline
I decided to test the example from upstream and it does work.
after running the script I opened libreoffice writer and pasted clipboard contents to it and got the screenshot I took as image .
Are you using bash or another shell, zeroxoneafour ?
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
I'm using bash, but I bound it to the print key via sxhkd. It would appear some applications can detect the image as an image, whereas others detect it as text. I guess the prompt that you paste it into matters. It seemed to work better after I got the xclip-git package from the AUR/
Offline
I don't get image/png, in "xclip -o -t TARGETS" as well.
You need to always set the correct selection, xclip works fine here (xclip 0.13-3)
$ xclip -selection clipboard -i -t image/png <prawn.png
$ xclip -selection clipboard -o -t TARGETS
TARGETS
image/png
$ xclip -selection clipboard -o -t image/png | display -
I can also image that some applications fail when TIMESTAMP is not set, maybe they only work with MULTIPLE selections which would be bad design, or require at least two formats because they are buggy. (timestamp and multiple are defined in ICCCM)
If the git version works better, then it may also be the result of this I think: https://github.com/astrand/xclip/pull/57
By the way, if you use the git version you really need this pull-request or you may get segfaults: https://github.com/astrand/xclip/pull/121
Last edited by progandy (2021-07-16 21:11:37)
| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |
Offline
Pages: 1