Flameshot-to-Plik Pipeline -- Quinn

Created on 2021-03-05T15:09:38-06:00

Return to the Index

This card can also be read via Gemini.

Check the tool itself: nope, Flameshot only supports Imgur and only anonymous Imgur at that. No option to run a script on images that are saved.

Have to have a file watcher and a special upload directory.

Find incron.

Confirm that incron will run a script whenever a file is written to this directory.

Use ffmpeg to convert pngs to compressed webp's but store them in a separate directory so we don't get infinite loops.

Install plik CLI client because otherwise its a pain in the ass to set upload parameters.

Discover that CLI client ignores ~/.plikrc for some reason; even though it writes to there it won't read from it so it just asks for login details every fucking run.

Hard code upload token and server URL in the processing script.

Success kind of.

Notice that incron doesn't run script in such a way that xclip or notify-send works properly.

Try putting `env DISPLAY=:0` around echo to xclip but then learn you can't pass environment variables that way.

Write URL to a temp file which we can then have xclip read.

Finally re-create something ShareX just does.

Script

#!/bin/fish
cd /home/icedquinn/Pictures/Poast/Inbox
set fuckinfile (basename $argv .png).webp
ffmpeg -y -i $argv -compression_level 9 "../"$fuckinfile
set url (~/.local/bin/plik --server "https://plik.iceworks.cc" --token "lol no" --ttl 1d -q "../"$fuckinfile)
echo $url > /tmp/uploaded.url
env DISPLAY=:0 xclip -in -selection clipboard < /tmp/uploaded.url

References