command-line-interface - 分别截取多个显示器的命令行工具

标签 command-line-interface screenshot multiple-monitors xrandr

问题陈述

我使用 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支持 curios looking 选项 -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.

所以我在想一个非常丑陋/hacky的解决方案,使用xdotool (或类似)选择所需的显示并与选项 -s 一起使用至 maimscrot可以完成这项工作。但我宁愿不走这条路,除非没有其他直接的解决方案。

疯狂的猜测

我想知道这个问题是否可能是因为我添加新监视器的方式?我通常使用如下命令添加我的第二个显示器:

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

所以我想知道,可能是scrotmaim 只有一个显示器。我想是因为 xdpyinfo | grep -A4 '^screen' 的输出ONE 显示器看起来像:

$ 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

关于command-line-interface - 分别截取多个显示器的命令行工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58123181/

相关文章:

c++ - 模拟一个显示器,在windows上获取视频流

linux - 如何使用git命名空间 stash 分支

gruntjs - 无法安装 Grunt?

flutter - 如何使用 RepaintBoundary 为 Image 小部件截取屏幕截图?

android - 如何以编程方式截取 webview 的屏幕截图,捕获整个页面?

app-store-connect - App Store Connect 的 6.5 英寸 iPhone 代号 One 模拟器屏幕截图?

c# - 让 Winform 同时出现在所有现有监视器上(它是一个警报窗口)

具有多个显示器的 VNC 查看器

command-line-interface - 是否有一个不可知的 cli 可以快速生成新功能和项目?

ios - 用于 GoogleMaps 的 ionic 构建 ios - 命令的错误代码 65