0

I have once known how to do this, but totally forgot about it.

So I use scrot, i.e 'scrot '%d/%m-scrot.jpg'. I know I can pass an -e argument to execute a program, but that's where I got stuck.

I want to use scrot with the Imgur uploader bash script from https://gist.github.com/vivien/9768953 and upload the image to Imgur. I can't figure out how to do both in one command, though.

What I want to do is take a scrot, upload it to imgur and send the stdout from imgur.sh to xclip so the imgur url is added to my clipboard.

I have a faint memory of it looking something like this: scrot '%d/%m-lulzol.jpg' -e imgur $f and then some xargs. It does not recognize $f now though.

I'm not sure how I can use the previous scrot command's output as a variable for the Imgur command. Is there some kind of general variable used for stdout from a previous command in Bash? As you can tell, I am not not very familiar with Bash's inner workings or syntax regarding files.

0

I have a faint memory of it looking something like this: scrot '%d/%m-lulzol.jpg' -e imgur $f and then some xargs. It does not recognize $f now though.

$f is using parameter substitution. It sounds like you were using it in a for-loop, probably something like for f in $(ls);....

Is there some kind of general variable used for stdout from a previous command in Bash?

I/O redirection. (there is no such thing as a 'general variable' in BASH btw.)

What I want to do is take a scrot, upload it to imgur and send the stdout from imgur.sh to xclip so the imgur url is added to my clipboard.

I am unfamiliar with imgur.sh, but based on your memory of using xargs, I would say the command would look something like:
scrot '%d/%m-lulzol.jpg' -e imgur.sh <imagename> | xargs xclip

This uses scrot to execute imgur.sh on a given image (< day >/< month >-lulzol.jpg), then pipes the stdout (presumably the image URL?) to xargs, which feeds it as an argument to xclip, which copies it to your clipboard.

0

From man scrot:

[...]
       -e, --exec APP
            Exec APP on the saved image.
[...]
SPECIAL STRINGS
       Both the --exec and filename parameters  can  take  format  specifiers
       that  are  expanded by scrot when encountered.  There are two types of
       format specifier. Characters preceded by a  '%'  are  interpretted  by
       strftime(2). See man strftime for examples.  These options may be used
       to refer to the current date and time.  The second kind  are  internal
       to  scrot  and are prefixed by '$' The following specifiers are recog‐
       nised:

       $f image path/filename (ignored when used in the filename)
[...]

So the command would be:

scrot '%d/%m-scrot.jpg' -e 'imgur $f | xclip'

A nonsense example just to show that the command passed to -e works even if containing pipes:

% scrot -e 'echo $f | grep 2015'
2015-12-02-015014_1366x768_scrot.png
% scrot -e 'echo $f | grep 2016'
% 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.