You are not logged in.

#1 2021-09-15 20:23:23

Peregrino69
Member
Registered: 2016-03-11
Posts: 89

[SOLVED] Keyboard shortcut to take an area screenshot using scrot

I like very much MacOS:s way of screenshotting an area with a key combo, and have been trying to figure out to do the same with scrot. Scrot -s captures and creates the file in current directory, but the way I do it from the menu (saving to screenshots -dir and launching ImageViewer) is very much preferrable. And that's where I stumble.

Halp, plz?


(unintentionally NSFW title reformatted big_smile)

Last edited by Peregrino69 (2021-09-16 17:07:50)

Offline

#2 2021-09-15 23:31:52

phuturism
Member
From: Melbourne
Registered: 2016-07-15
Posts: 187

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

with commands like these use your keybinding tool to connect these to your desired keystroke combinations.   I think you can hook up terminal commands to your openbox menu too.

(this is from my Arch keybindings file)

# scrot select and copy to clipboard, delete filie
alt + Print
	scrot -s foo.png && xclip -se c -t image/png -i foo.png && rm foo.png &

# scrot full screen and save to Screenshots
#super + Print
#	scrot ~/Screenshots/%Y-%m-%d-%T-screenshot.png

# scrot print screen
Print
    scrot ~/Screenshots/%Y-%m-%d-%T-selectscreenshot.png

#Scrot 5 second [Shots go to your screenshots folder]
ctrl + Print
    scrot -d 5 -c ~/Screenshots/%Y-%m-%d-%T-screenshot.png

# select and save copy to
alt + ctrl + Print

      scrot  -s ~/Selectshots/%Y-%m-%d-%T-selectscreenshot.png &

Last edited by phuturism (2021-09-15 23:32:36)

Offline

#3 2021-09-16 00:40:14

Peregrino69
Member
Registered: 2016-03-11
Posts: 89

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

Thanks. I was a bit unclear... the -s option is the one I want, and I do know how to create the shortcut.

The part I'm strugging with is having a way to save the image and open it with Ristretto as one command, i.e. the way it works on the menu. I could

var=(date [options]) | scrot -s ~/Pictures/screenshots/$var.png | ristretto ~/Pictures/screenshots/$var.png

... but generally there are more elegant ways of doing things than I can come up with big_smile

Offline

#4 2021-09-16 05:56:16

phuturism
Member
From: Melbourne
Registered: 2016-07-15
Posts: 187

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

Yes I should have read more carefully...

No doubt some more experienced command line folks can help you to pass/open the file using the date variables.

Last edited by phuturism (2021-09-16 06:03:05)

Offline

#5 2021-09-16 07:27:57

damo
....moderator....
Registered: 2015-08-20
Posts: 6,732

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

Why not put all the commands you need in a script, and run the script with a keybind?


Be Excellent to Each Other...
The Bunsenlabs Lithium Desktop » Here
FORUM RULES and posting guidelines «» Help page for forum post formatting
Artwork on DeviantArt  «» BunsenLabs on DeviantArt

Offline

#6 2021-09-16 13:58:32

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 1,498

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

Peregrino69 wrote:

Thanks. I was a bit unclear... the -s option is the one I want, and I do know how to create the shortcut.

The part I'm strugging with is having a way to save the image and open it with Ristretto as one command, i.e. the way it works on the menu. I could

var=(date [options]) | scrot -s ~/Pictures/screenshots/$var.png | ristretto ~/Pictures/screenshots/$var.png

... but generally there are more elegant ways of doing things than I can come up with big_smile

Does this:

var=(date [options])

ever change? scrot accepts strftime options directly (see the man page for examples).

Then you can try something like:

scrot -s '%Y-%m-%d_%s.png' -e 'mv $f ~/temp/ ; sxiv ~/temp/$f'

change ~/temp to your directory of choice, and change sxiv to your image viewer of choice (or use xdg-open for the default image viewer).

Addy has a nice script for taking screenshots - screeny; it worked last time I tried it.

scrot or it never happened  monkey

2021-09-16-1631800785.png

Last edited by PackRat (2021-09-16 14:01:26)


You must unlearn what you have learned.
    -- yoda

Online

#7 2021-09-16 17:07:31

Peregrino69
Member
Registered: 2016-03-11
Posts: 89

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

PackRat wrote:

Does this:

var=(date [options])

ever change? scrot accepts strftime options directly (see the man page for examples).

Then you can try something like:

scrot -s '%Y-%m-%d_%s.png' -e 'mv $f ~/temp/ ; sxiv ~/temp/$f'

change ~/temp to your directory of choice, and change sxiv to your image viewer of choice (or use xdg-open for the default image viewer).

Addy has a nice script for taking screenshots - screeny; it worked last time I tried it.

There we go - removing the need to use date elegancifies the line big_smile The name indeed doesn't need to change, date-time-filename -construct is useful here.

@damo - I could've, but wouldn't have learned anything new smile

@phuturism - nah, I really didn't make myself clear. Thanks for pitching in smile

And thanks @PackRat. I've got well enough here to declare the issue solved smile

Offline

#8 2021-09-17 00:30:38

phuturism
Member
From: Melbourne
Registered: 2016-07-15
Posts: 187

Re: [SOLVED] Keyboard shortcut to take an area screenshot using scrot

Peregrino69 wrote:
PackRat wrote:

Does this:

var=(date [options])

ever change? scrot accepts strftime options directly (see the man page for examples).

Then you can try something like:

scrot -s '%Y-%m-%d_%s.png' -e 'mv $f ~/temp/ ; sxiv ~/temp/$f'

change ~/temp to your directory of choice, and change sxiv to your image viewer of choice (or use xdg-open for the default image viewer).

Addy has a nice script for taking screenshots - screeny; it worked last time I tried it.

There we go - removing the need to use date elegancifies the line big_smile The name indeed doesn't need to change, date-time-filename -construct is useful here.

@damo - I could've, but wouldn't have learned anything new smile

@phuturism - nah, I really didn't make myself clear. Thanks for pitching in smile

And thanks @PackRat. I've got well enough here to declare the issue solved smile

No worries!   You can see the commands I use from my examples, but you've inspired me to set one up to open in my image editor too, this would be useful.

Offline

Board footer

Powered by FluxBB