[英]Command line tool to Screenshot multiple monitors separately
问题陈述
我使用scrot
来截取屏幕截图,除非我有多个显示器或显示器,否则效果很好。 在这种情况下, scrot
将不同显示器的屏幕截图连接到一个 output 中。
从手册页来看, scrot
支持一个选项-m
:
-m, --multidisp
For multiple heads, grab shot from each and join them together.
所以我想象默认行为是不将它们连接在一起。 然而,这种情况并非如此。 即使没有-m
选项,我也会得到加入的屏幕截图。
我很乐观scrot
应该能够做到这一点,因为它支持-u
选项:
-u, --focused
Use the currently focused window.
效果很好。
我还检查了另一个名为maim
的 CLI 工具 - 但我还是不知道如何分别截取不同监视器的屏幕截图。
所以我排除的解决方案应该是这样的:
screenshot_command <display_name> # and other options
仅截屏显示<display_name>
。
到目前为止我的解决方案尝试
maim
支持 curios 查找选项-x
:
-x, --xdisplay=hostname:number.screen_number
Sets the xdisplay to use.
所以我尝试maim -x 0.0 | xclip -selection clipboard -t image/png
maim -x 0.0 | xclip -selection clipboard -t image/png
,但这不起作用。 我不知道如何使用此选项,因为没有足够的文档。
scrot 和scrot
maim
支持选项-s
:
-s, --select
Interactively select a window or rectangle with the mouse.
所以我正在想象一个非常丑陋/hacky的解决方案,使用xdotool
(或类似的)到select所需的显示并使用选项-s
来maim
或scrot
可能会完成这项工作。 但除非没有其他直接的解决方案,否则我宁愿不走这条路。
疯狂的猜测
我想知道这个问题是否是因为我如何添加新显示器? 我通常用这样的命令添加我的第二个显示器:
xrandr --output eDP-1 --auto --output HDMI-1-4 --auto --right-of eDP-1
所以我想知道,可能是maim
或scrot
只有一个显示器。 我想是因为xdpyinfo | grep -A4 '^screen'
xdpyinfo | grep -A4 '^screen'
与一台显示器看起来像:
$ xdpyinfo | grep -A4 '^screen'
screen #0:
dimensions: 1920x1080 pixels (506x285 millimeters)
resolution: 96x96 dots per inch
depths (7): 24, 1, 4, 8, 15, 16, 32
root window id: 0x1ba
并且有两个显示器看起来像这样:
$ xdpyinfo | grep -A4 '^screen'
screen #0:
dimensions: 3280x1080 pixels (865x285 millimeters)
resolution: 96x96 dots per inch
depths (7): 24, 1, 4, 8, 15, 16, 32
root window id: 0x1ba
如果这确实是我的问题的原因,那么我应该如何添加我的第二台显示器?
另一种解决方案是MSS 。
安装非常简单(不需要昂贵的 Python 模块):
$ python3 -m pip install --user -U mss
它将添加一个新的mss
可执行文件,您可以随时调用。
例如,要获取每个监视器的屏幕截图,只需键入:
$ mss
/home/USER/monitor-1.png
/home/USER/monitor-2.png
/home/USER/monitor-3.png
如果您只想捕获第一个监视器:
$ mss --monitor 1
/home/USER/monitor-1.png
要在一张图片中捕获所有监视器的屏幕截图(就像 scrot 所做的那样):
$ mss --monitor -1
/home/USER/monitor-0.png
截至目前,帮助人员显示:
$ mss --help
usage: mss [-h] [-c COORDINATES] [-l {0,1,2,3,4,5,6,7,8,9}] [-m MONITOR]
[-o OUTPUT] [-q] [-v]
optional arguments:
-h, --help show this help message and exit
-c COORDINATES, --coordinates COORDINATES
the part of the screen to capture: top, left, width,
height
-l {0,1,2,3,4,5,6,7,8,9}, --level {0,1,2,3,4,5,6,7,8,9}
the PNG compression level
-m MONITOR, --monitor MONITOR
the monitor to screen shot
-o OUTPUT, --output OUTPUT
the output file name
-q, --quiet do not print created files
-v, --version show program's version number and exit
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.