Both sides previous revisionPrevious revisionNext revision | Previous revision |
apps:xfce4-screenshooter:custom-actions [2024/02/05 22:13] – Add go back link andreldm | apps:xfce4-screenshooter:custom-actions [2025/02/15 12:52] (current) – [Hosting on Imgur™] Update about client id andreldm |
---|
~~NOTOC~~ | ~~NOTOC~~ |
{{ :xfce:xfce.screenshooter.png?no link|}} | {{ :apps:xfce4-screenshooter.png?nolink|}} |
====== xfce4-screenshooter - Custom Actions ====== | ====== xfce4-screenshooter - Custom Actions ====== |
| |
* **[[#Adding custom actions|Adding custom actions]]** | * **[[#Adding custom actions|Adding custom actions]]** |
* **[[#Examples|Examples]]** | * **[[#Examples|Examples]]** |
| * **[[#Extract text with OCR|Extract text with OCR]]** |
| * **[[#Read QR Code|Read QR Code]]** |
| * **[[#Hosting on Imgur™|Hosting on Imgur™]]** |
| |
===== Adding custom actions ===== | ===== Adding custom actions ===== |
| |
<figure "Preferences"> | <figure "xfce4-screenshooter Preferences Window"> |
{{:apps:screenshooter:xfce4-screenshooter-preferences.png?nolink|}} | {{:apps:xfce4-screenshooter:xfce4-screenshooter-preferences.png|xfce4-screenshooter Preferences Window}} |
</figure> | </figure> |
| |
The following examples assume the necessary dependencies are already installed. | The following examples assume the necessary dependencies are already installed. |
| |
**Extract text with OCR** | ==== Extract text with OCR ==== |
| |
''gimagereader-gtk %f'' | ''gimagereader-gtk %f'' |
| |
**Read QR Code** | ---- |
| |
| ==== Read QR Code ==== |
| |
Save the following script somewhere and set as command: ''<somewhere>/read-qr.sh %f'' | Save the following script somewhere and set as command: ''<somewhere>/read-qr.sh %f'' |
</code> | </code> |
| |
** Host on Imgur™ ** | [[|Back to Top]] |
| |
Save the following script somewhere and set as command: ''<somewhere>/imgur-upload.sh %f <CLIENT ID>'' | ---- |
For the time being, screenshooter provides its own client id as ''%imgur_client_id'', in future releases that will be removed, you will need to register at Imgur and obtain your client id. | |
| ==== 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>Hosting images in a public-facing service must be done with caution, as it is not possible to guarantee the removal of a image after publishing it. Before using this action, please review Imgur's [[https://imgur.com/tos|Terms of service]], if you do not agree with the terms please refrain from using this service.</note> |
| |
| |
| Save the following script somewhere and set as command: ''<somewhere>/imgur-upload.sh %f <CLIENT ID>'', you need to register at Imgur and obtain your client id. |
| |
<code> | <code> |
#!/bin/sh | #!/usr/bin/env bash |
| |
URL='https://api.imgur.com/3/image' | URL='https://api.imgur.com/3/image' |
if [ -z "$SCREENSHOT_PATH" ] || [ -z "$CLIENT_ID" ]; then | if [ -z "$SCREENSHOT_PATH" ] || [ -z "$CLIENT_ID" ]; then |
zenity --error --text="Arguments are missing" | zenity --error --text="Arguments are missing" |
| exit 1 |
| fi |
| |
| if ! command -v jq >&2; then |
| zenity --error --text="jq: command not found!" |
exit 1 | exit 1 |
fi | fi |
#RESPONSE='{"data":{"id":"q9a8Oh4","title":null,"description":null,"datetime":1690124891,"type":"image\/png","animated":false,"width":217,"height":186,"size":593,"views":0,"bandwidth":0,"vote":null,"favorite":false,"nsfw":null,"section":null,"account_url":null,"account_id":0,"is_ad":false,"in_most_viral":false,"has_sound":false,"tags":[],"ad_type":0,"ad_url":"","edited":"0","in_gallery":false,"deletehash":"b0AjSDJjSU4iyhE","name":"","link":"https:\/\/i.imgur.com\/q9a8Oh4.png"},"success":true,"status":200}' | #RESPONSE='{"data":{"id":"q9a8Oh4","title":null,"description":null,"datetime":1690124891,"type":"image\/png","animated":false,"width":217,"height":186,"size":593,"views":0,"bandwidth":0,"vote":null,"favorite":false,"nsfw":null,"section":null,"account_url":null,"account_id":0,"is_ad":false,"in_most_viral":false,"has_sound":false,"tags":[],"ad_type":0,"ad_url":"","edited":"0","in_gallery":false,"deletehash":"b0AjSDJjSU4iyhE","name":"","link":"https:\/\/i.imgur.com\/q9a8Oh4.png"},"success":true,"status":200}' |
#RESPONSE='{"data":{"error":{"code":1003,"message":"File type invalid (1)","type":"ImgurException","exception":[]},"request":"\/3\/image","method":"POST"},"success":false,"status":400}' | #RESPONSE='{"data":{"error":{"code":1003,"message":"File type invalid (1)","type":"ImgurException","exception":[]},"request":"\/3\/image","method":"POST"},"success":false,"status":400}' |
RESPONSE=$(curl --silent --location "$URL" --header "Authorization: Client-ID $CLIENT_ID" --form "image=@$SCREENSHOT_PATH") | 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) | STATUS=$(echo "$RESPONSE" | jq -r .status) |
| |
LINK="https://imgur.com/$(echo "$RESPONSE" | jq -r .data.id).png" | LINK="https://imgur.com/$(echo "$RESPONSE" | jq -r .data.id).png" |
DELETE="https://imgur.com/delete/$(echo "$RESPONSE" | jq -r .data.deletehash)" | DELETE="https://imgur.com/delete/$(echo "$RESPONSE" | jq -r .data.deletehash)" |
LOG_DIRECTORY="$HOME/.local/share/xfce4" | LOG_DIRECTORY="${XDG_DATA_HOME:-$HOME/.local/share}/xfce4" |
LOG="$LOG_DIRECTORY/xfce4-screenshooter-imgur.log" | LOG="$LOG_DIRECTORY/xfce4-screenshooter-imgur.log" |
| |
$LOG" | $LOG" |
</code> | </code> |
| |
| The dialog below will give you the links to delete the image off of the Imgur website. The link will only be shown once. Make sure to save it if you think you might be deleting this image: |
| |
| <figure "Imgur Deletion Dialog Window"> |
| {{:apps:xfce4-screenshooter:xfce4-screenshooter-custom-action-imgur.png|Imgur Deletion Dialog Window}} |
| </figure> |
| |
| |
| [[|Back to Top]] |
| |
---- | ---- |
[[:apps:screenshooter:start:|Back to xfce4-screenshooter main page]] | [[:apps:screenshooter:start:|Return to xfce4-screenshooter Main Documentation Page]] |