问题陈述
我使用scrot
来截屏,它可以完美地工作,但当我有多个显示器时就会出现问题,此时scrot
会将不同显示器的屏幕截图合并成一个输出。
从man页面得知,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
支持这个奇特的选项 -x
:
-x, --xdisplay=hostname:number.screen_number
Sets the xdisplay to use.
我尝试过 maim -x 0.0 | xclip -selection clipboard -t image/png
,但这并不起作用。由于文档不足,我不知道如何使用这个选项。
scrot
和 maim
都支持选项 -s
:
-s, --select
Interactively select a window or rectangle with the mouse.
我设想了一种非常丑陋/拙劣的解决方案,使用xdotool(或类似工具)选择所需的显示器,并使用-s选项来执行maim或scrot,可能能够解决问题。但我不想走这条路,除非没有其他简单直接的解决方案。
一个大胆的猜测:
我想知道这个问题是否是因为我添加新监视器的方式不正确?我通常会使用类似以下命令添加第二个显示器:
xrandr --output eDP-1 --auto --output HDMI-1-4 --auto --right-of eDP-1
所以我在想,也许使用 scrot
或者 maim
只有一个显示器。我这样想是因为只有一个监视器时,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
如果这确实是我的问题所在,那么我应该如何添加我的第二个显示器?