Skip to content

u/Shamaoke

In this archive from Oct 2016 to Sep 2023

1
posts
10
comments
0
media
18
score

Here's how this can be implemented via shell scripting.

 #!/usr/bin/env zsh

##
# screengrab -- command line utility for grabbing the desktop
#
# Usage: screengrab [timeout] [dimensions]
#
# Examples:
#
# screengrab 5
#
# screengrab 5 800x600
#
# screengrab 5 +10,20
#
# screengrab 5 800x600+10,20
#

timeout=$1
size=${2%+[[:digit:]]*,[[:digit:]]*}
offset=${(M)2%+[[:digit:]]*,[[:digit:]]*}

_regexp='^.*connected ([[:digit:]]+x[[:digit:]]+)(\+[[:digit:]]+)\+([[:digit:]]).*$'

default_size=$(xrandr | sed -r ":a;N;\$!ba;s/$_regexp/\1/")
default_offset=$(xrandr | sed -r ":a;N;\$!ba;s/$_regexp/\2,\3/")

##
# timeout
#
# set a timeout
#
# Start grabbing the screen after a short period of time.
#
# Default: 0
#

##
# size
#
# set the image size
#
# Specify the size of the screen portion. The format is <width>x<height>.
#
# Default: $default_size
#

##
# offset
#
# set an offset
#
# Specify an offset from the top left corner of the screen. The format is +<x>,<y>.
#
# Default: $default_offset
#

sleep ${timeout:-0}

ffmpeg -f x11grab \
       -video_size ${size:-$default_size} \
       -i :0.0${offset:-$default_offset} \
       -frames:v 1 \
       -f image2pipe \
       -codec:v png \
       - \
| \
xclip -in \
      -target image/png \
      -selection clipboard

##
# ffmpeg
#
# -f x11grab           -- set the input format (X11 screen capture using XCB); use `ffmpeg -formats` to view all formats
# -video_size 1280x720 -- set the frame size (alias: -s)
# -i :0.0+0,0          -- use the X11 display as an input (format: :<display>.<screen>+<x-offset>,<y-offset>)
# -frames:v 1          -- set the number of video frames to output
# -f image2pipe        -- set the output format (an image sent to the input end of other program through a pipe)
# -codec:v png         -- set the video codec (alias: -vcodec)
# -                    -- output to the standard input
#

##
# xclip
#
# -in                  -- read data into the X selection from the standard input (alias: -i)
# -target image/png    -- specify an input data format (alias: -t)
# -selection clipboard -- specify which X selection to use {primary|secondary|clipboard}
#
1 points

yes, it is, because when I open my mouse settings, it turns into a tiny window that has to be scrolled a lot and can't be resized. it's already reported as a bug

I agree, this is annoying, but it's not critical. Moreover, if it was reported, probably it will be fixed sometime.

and a lot of people rel on extensions for their daily use which don't work now

I understand, but again, this is not a GNOME issue. The state of extensions is the responsibility of their maintainers.

1 points

End of this list.

Back to top

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.