Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| apps:xfce4-screenshooter:custom-actions [2024/02/04 22:46] – created andreldm | apps:xfce4-screenshooter:custom-actions [2026/11/22 16:34] (current) – Refresh custom actions page epetriglia | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ~~NOTOC~~ | ~~NOTOC~~ | ||
| - | {{ :xfce:xfce.screenshooter.png? | + | {{ :apps:xfce4-screenshooter.png? |
| ====== xfce4-screenshooter - Custom Actions ====== | ====== xfce4-screenshooter - Custom Actions ====== | ||
| + | |||
| + | 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 [[: | ||
| + | |||
| + | Custom actions are available both in the application and in the [[: | ||
| + | |||
| + | * **[[#Adding custom actions|Adding custom actions]]** | ||
| + | * **[[#How commands are executed|How commands are executed]]** | ||
| + | * **[[# | ||
| + | * **[[# | ||
| + | * **[[#Read QR Code|Read QR Code]]** | ||
| + | * **[[# | ||
| + | |||
| + | ---- | ||
| ===== Adding custom actions ===== | ===== Adding custom actions ===== | ||
| - | TODO | + | Custom actions are added, removed and edited in the {gui> |
| + | |||
| + | * Add: click on the plus (+) button. A new blank custom action is added at the bottom of the list. | ||
| + | * Remove: select a custom action and click on the minus (-) button. | ||
| + | * Edit: select a custom action and change its name and command. Changes are saved when the {gui> | ||
| + | |||
| + | Each custom action is composed of: | ||
| + | |||
| + | * Name: a friendly name that will be shown in the drop-down list of the Actions dialog. | ||
| + | * Command: the command to be executed. It can be an inline command or a call to a script. Use '' | ||
| + | |||
| + | <figure " | ||
| + | {{: | ||
| + | </ | ||
| + | |||
| + | [[|Back to Top]] | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== How commands are executed ===== | ||
| + | |||
| + | * '' | ||
| + | * Environment variables such as '' | ||
| + | * The command is executed directly, this means pipes ('' | ||
| + | * Programs without a full path are searched in '' | ||
| + | * Only the command line is stored, not the script it calls. The script is run again on every use, so changes to it take effect immediately, | ||
| + | |||
| + | [[|Back to Top]] | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ===== Examples ===== | ||
| + | |||
| + | The following examples assume the necessary dependencies are already installed. The clipboard examples use '' | ||
| + | |||
| + | ==== Extract text with OCR ==== | ||
| + | |||
| + | Set as command: '' | ||
| + | |||
| + | [[|Back to Top]] | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Read QR Code ==== | ||
| + | |||
| + | Save the following script somewhere, make it executable ('' | ||
| + | |||
| + | <code bash read-qr.sh> | ||
| + | # | ||
| + | |||
| + | RES=$(zbarimg --raw " | ||
| + | if [ $? -ne 0 ]; then | ||
| + | notify-send -e "No QR Code detected" | ||
| + | exit 0 | ||
| + | fi | ||
| + | |||
| + | ANSWER=$(notify-send -e -A 1=" | ||
| + | if [ " | ||
| + | echo " | ||
| + | fi | ||
| + | </ | ||
| + | |||
| + | [[|Back to Top]] | ||
| + | |||
| + | ---- | ||
| + | |||
| + | ==== Hosting on Imgur™ ==== | ||
| + | |||
| + | 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. | ||
| + | |||
| + | <note important> | ||
| + | |||
| + | You need to register at Imgur and obtain your client ID. Then save the following script somewhere, make it executable ('' | ||
| + | |||
| + | <note warning> | ||
| + | |||
| + | <code bash imgur.sh> | ||
| + | # | ||
| + | |||
| + | URL=' | ||
| + | SCREENSHOT_PATH=$1 | ||
| + | CLIENT_ID=$2 | ||
| + | |||
| + | if [ -z " | ||
| + | zenity --error --text=" | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | if ! command -v jq >&2; then | ||
| + | zenity --error --text=" | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | RESPONSE=$(curl --silent --location " | ||
| + | --header " | ||
| + | --form " | ||
| + | tee >(zenity --progress --pulsate --no-cancel --auto-close --text=" | ||
| + | STATUS=$(echo " | ||
| + | |||
| + | if [ -z " | ||
| + | ERROR=$(echo " | ||
| + | zenity --error --text=" | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | LINK=" | ||
| + | DELETE=" | ||
| + | LOG_DIRECTORY=" | ||
| + | LOG=" | ||
| + | |||
| + | # Add link to clipboard | ||
| + | echo " | ||
| + | |||
| + | # Add links to log | ||
| + | mkdir -p " | ||
| + | echo "--- | ||
| + | $(date '+%x %X') | ||
| + | Link: $LINK | ||
| + | Delete: $DELETE" | ||
| + | |||
| + | # Show dialog with links | ||
| + | zenity --info --title=" | ||
| + | Delete: <a href=' | ||
| + | |||
| + | 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 ('' | ||
| + | |||
| + | <figure "Imgur Deletion Dialog Window"> | ||
| + | {{: | ||
| + | </ | ||
| + | |||
| + | [[|Back to Top]] | ||
| + | |||
| + | ---- | ||
| + | [[: | ||