Custom actions let you process a screenshot with any program or script right after it is captured: for example to edit it, extract its text, read a QR code or upload it to an online service. Once configured, they appear in the window shown after capturing (see After capturing): select Custom Action, choose the action from the drop-down list and confirm. The screenshot is saved to the system's temporary directory and passed to the command.
Custom actions are available both in the application and in the panel plugin.
Custom actions are added, removed and edited in the Preferences dialog, which can be opened with the Preferences button of the main window or of the panel plugin's properties dialog.
Each custom action is composed of:
%f as a placeholder for the location of the captured screenshot.
| xfce4-screenshooter Preferences Window |
|---|
|
%f is replaced with the full path of the screenshot, already quoted, so file names containing spaces are handled correctly. Do not add quotes around %f yourself.$HOME are expanded, so a command like $HOME/bin/upload.sh %f works.|), redirections (>) and other shell syntax are not supported. If you need them, put the commands in a script and call the script.$PATH.
The following examples assume the necessary dependencies are already installed. The clipboard examples use xclip, which works on X11, on Wayland replace xclip -selection clipboard with wl-copy.
Save the following script somewhere, make it executable (chmod +x read-qr.sh) and set as command: <somewhere>/read-qr.sh %f
#!/bin/bash RES=$(zbarimg --raw "$1" 2> /dev/null) if [ $? -ne 0 ]; then notify-send -e "No QR Code detected" exit 0 fi ANSWER=$(notify-send -e -A 1="Copy to clipboard" -t 5000 "QR Code detected" "$RES") if [ "$ANSWER" == "1" ]; then echo "$RES" | xclip -selection clipboard fi
This custom action allows you to host your screenshot on this free online hosting service, so that you can share it easily with other people. Imgur automatically generates a tiny, medium, and full-size image of your screenshot, which can be used to create thumbnails pointing to the full size screenshot.
You need to register at Imgur and obtain your client ID. Then save the following script somewhere, make it executable (chmod +x imgur.sh) and set as command: <somewhere>/imgur.sh %f <CLIENT ID>. The script requires curl, jq, zenity and xclip.
imgur-upload.sh: custom actions whose command contains that name are removed automatically, because it was the name of the old built-in Imgur action.
#!/usr/bin/env bash URL='https://api.imgur.com/3/image' SCREENSHOT_PATH=$1 CLIENT_ID=$2 if [ -z "$SCREENSHOT_PATH" ] || [ -z "$CLIENT_ID" ]; then zenity --error --text="Arguments are missing" exit 1 fi if ! command -v jq >&2; then zenity --error --text="jq: command not found!" exit 1 fi RESPONSE=$(curl --silent --location "$URL" \ --header "Authorization: Client-ID $CLIENT_ID" \ --form "image=@$SCREENSHOT_PATH" | \ tee >(zenity --progress --pulsate --no-cancel --auto-close --text="Uploading screenshot...")) STATUS=$(echo "$RESPONSE" | jq -r .status) if [ -z "$STATUS" ] || [ "$STATUS" -ne 200 ]; then ERROR=$(echo "$RESPONSE" | jq -r .data.error.message) zenity --error --text="Failed to upload screenshot:\n$ERROR" exit 1 fi LINK="https://imgur.com/$(echo "$RESPONSE" | jq -r .data.id).png" DELETE="https://imgur.com/delete/$(echo "$RESPONSE" | jq -r .data.deletehash)" LOG_DIRECTORY="${XDG_DATA_HOME:-$HOME/.local/share}/xfce4" LOG="$LOG_DIRECTORY/xfce4-screenshooter-imgur.log" # Add link to clipboard echo "$LINK" | xclip -selection clipboard # Add links to log mkdir -p "$LOG_DIRECTORY" echo "--- $(date '+%x %X') Link: $LINK Delete: $DELETE" >> "$LOG" # Show dialog with links zenity --info --title="Screenshot uploaded" --text="Link: <a href='$LINK'>$LINK</a> Delete: <a href='$DELETE'>$DELETE</a> Link copied to clipboard. Links stored in: $LOG"
After the upload, the dialog below shows the link to the image and the link to delete it from the Imgur website. Both links are copied to a log file (~/.local/share/xfce4/xfce4-screenshooter-imgur.log), so you can still delete the image later:
| Imgur Deletion Dialog Window |
|---|
|