[英]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.