用于分别截屏多个监视器的命令行工具

问题描述 投票:2回答:1

问题语句

我使用scrot来截取屏幕截图,除非我有多台监视器或显示器,否则该屏幕截图效果很好。在这种情况下,scrot将不同监视器的屏幕快照合并为一个输出。

从联机帮助页,scrot支持选项-m

-m, --multidisp
        For multiple heads, grab shot from each and join them together.

所以我想象默认的行为是NOT将它们连接在一起。然而,这种情况并非如此。即使没有-m选项,我也可以加入屏幕截图。

我很乐观scrot应该能够做到这一点,因为它支持-u选项:

-u, --focused
        Use the currently focused window.

效果很好。

我还签出了另一个名为maim的CLI工具,但同样我无法弄清楚如何分别拍摄不同监视器的屏幕截图。

所以我要排除的解决方案应该像这样工作:

screenshot_command <display_name> # and other options

仅截屏显示<display_name>

我到目前为止的解决方案尝试

[maim支持古玩外观选项-x

-x, --xdisplay=hostname:number.screen_number
          Sets the xdisplay to use.

所以我尝试了maim -x 0.0 | xclip -selection clipboard -t image/png,但这不起作用。我不知道如何使用此选项,因为没有足够的文档。

scrotmaim都还支持选项-s

-s, --select
        Interactively select a window or rectangle with the mouse.

所以我正在想一个非常ug / hacky的解决方案,它使用xdotool(或类似的东西)来选择所需的显示,并使用选项-smaimscrot来完成任务。但是我宁愿不走这条路,除非没有其他直接的解决方案。

一个疯狂的猜测

我想知道这个问题是否可能是由于我如何添加新显示器?我通常在第二个显示器上添加如下命令:

xrandr --output eDP-1 --auto --output HDMI-1-4 --auto --right-of eDP-1

所以我想知道,可能是scrotmaim仅一个显示。我想是这样,因为使用[[ONE监视器的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
并且带有

two

监视器如下所示:$ 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
如果这确实是我的问题的原因,那么我应该如何添加第二台显示器?
command-line-interface screenshot multiple-monitors xrandr
1个回答
0
投票
另一个解决方案是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

© www.soinside.com 2019 - 2024. All rights reserved.