You are not logged in.
I use nautilus every time i wanna paste image from clipboard as a file I realised I could maybe use thunar custom action, but idk how to
I want something like "Paste Clipboard Image" and ideally it should prompt me for name but it's fine if it uses current date/time or smthn like that
please help me..
jumpieee
Offline
How about a script like this (it requires xclip to be installed):
#!/bin/bash
DEST="$1/$(date +%s).png"
xclip -selection clipboard -t image/png -o > $DEST
Make the script executable and in the custom action, set the command to "/path/to/this/script %f" and in appearance settings, select "Dicrectories" only.
Or if you want to be prompted for the filename (requires zenity):
#!/bin/bash
FILENAME=$(zenity --entry --title "Filename..." --text "Enter the filename to use:")
DEST="$1/$FILENAME.png"
xclip -selection clipboard -t image/png -o > $DEST
Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
that's awesome I went made it a bit more dynamic (making it work with jpgs etc) and added notifications
#!/bin/bash
type="$(xclip -selection clipboard -t TARGETS -o | grep image | head -n1)"
extension="$(echo "$type" | awk -F"/" '{print $2}')"
if [ -z "$extension" ] ; then
notify-send "No image copied in clipboard" && exit
elif [ "$extension" == "jpeg" ] ; then
extension="jpg"
fi
xclip -selection clipboard -t $type -o > "Pasted-$(date +%Y-%d-%m_%H-%M-%S).$extension"
Last edited by boop (2023-11-18 17:24:42)
jumpieee
Offline
Yet another version.
1. x-qt-image is the type of image cropped-copied from XnView etc.
2. Zenity to confirm/change file name.
3. Check for "$1" allows to paste image into the current folder, running the script via terminal or via xfce launcher button (where it could be set as Pictures etc).
#!/bin/bash
# Paste image from clipboard as file
type="$(xclip -selection clipboard -t TARGETS -o | grep image | head -n1)"
extension="$(echo "$type" | awk -F"/" '{print $2}')"
if [ -z "$extension" ] ; then
notify-send "No image copied in clipboard" && exit
elif [ "$extension" == "jpeg" ] ; then
extension="jpg"
elif [ "$extension" == "x-qt-image" ] ; then
extension="png"
fi
if ! FILENAME=$(zenity --entry --width=720 --title "Picture from clipboard" --text "Save .$extension as:" --entry-text="pic-$(date +%Y-%m-%d_%H-%M)")
then
# echo Cancelled
exit
fi
if [ -z "$1" ]
then
DEST="$FILENAME.$extension"
else
DEST="$1/$FILENAME.$extension"
fi
xclip -selection clipboard -t $type -o > $DEST
Offline