naelstrof / maim

maim (make image) takes screenshots of your desktop. It has options to take only a region, and relies on slop to query for regions. maim is supposed to be an improved scrot.
Other
2.15k stars 78 forks source link

How to rename the file? #225

Closed TheYellowArchitect closed 3 years ago

TheYellowArchitect commented 3 years ago

I really like this program, but want to make a minor configuration and don't even know where to get started

I want the program to ask me for an input/string (before or after the image is screenshot'd), and then rename the file on what I typed

Any suggestions how to do this?

foxpy commented 3 years ago

I want the program to ask me for an input/string

ask in terminal or graphically?

TheYellowArchitect commented 3 years ago

Either work hahaha Even if there was no visual output of asking a file, but my next typing became the filename (until I pressed enter), it works even then!

foxpy commented 3 years ago

I want the program to ask me for an input/string (before or after the image is screenshot'd), and then rename the file on what I typed

install dmenu. create a file screenshot.sh with contents:

#!/bin/bash
filename="$(dmenu -p Filename).png"
maim "$filename"

then, execute chmod +x ./screenshot.sh run ./screenshot.sh

enjoy.

TheYellowArchitect commented 3 years ago

I have to admit I am new to bash scripting

I tried the above, but it didn't work

I have dmenu installed, and when I ran ./screenshot.sh, the focus kept on the terminal dmenu didnt take input, it wasn't activated Terminal was executing screenshot.sh I assume and I had to ctrl+C, otherwise I couldn't type anything else Maybe it fails because of my setup, having dwm?

IlyaMZP commented 3 years ago

dmenu didnt take input, it wasn't activated

Here is the fixed script. Turns out dmenu needs at least some input from stdin, adding </dev/null fixed it.

#!/bin/bash
filename="$(dmenu -p Filename </dev/null).png"
maim "$filename"
TheYellowArchitect commented 3 years ago

wow, it works!

I am new to Linux (and bash scripting), and was looking into getting into bash scripting with this, yet you solved it for me, I am thankful <3 It seems even if I did get the basics, I would definitely get stuck on the </dev/null thing, since I do not even know why it works!

Anyway, I did a minor modification (added a -s in front of it for selected area), and since I do not know how to run a bash script from any directory location (like e.g. maim), I made the following command and mapped it onto print screen maim -s "$(dmenu -p Filename </dev/null).png"

It works perfectly, thank you both!!!

foxpy commented 3 years ago

I do not know how to run a bash script from any directory location

Maybe you should start here: https://en.wikipedia.org/wiki/PATH_(variable)