如何截取登录屏幕的屏幕截图?


31

如何截取登录屏幕的屏幕截图?

我不想在虚拟机中重新创建Ubuntu安装。


1
我要寻找的第一件事是捕获X的输出。对“ screenshot xserver”的搜索使我在Linuxquestions.org上找到这个答案
Lekensteyn

此相关讨论可能是相关的:superuser.com/q/290432/120246
Waldir Leoncio

Answers:


17

该博客可能会有所帮助:http : //ptspts.blogspot.com/2010/02/how-to-create-screen-shot-of-gdm-login.html

安装ImageMagick进行以下图像文件格式转换:

sudo apt-get install imagemagick

创建一个辅助脚本:

echo 'DISPLAY=:0 XAUTHORITY=/var/lib/gdm/:0.Xauth xwd -root' >/tmp/shot.sh

确保您的登录屏幕处于活动状态(注销或重新启动计算机,然后等待直到看到登录屏幕)。以文本模式(通过按Ctrl-Alt-F1键)或使用SSH登录。通过运行创建屏幕截图

sudo bash /tmp/shot.sh >/tmp/shot.xwd

您现在可以登录(通过先按Ctrl-AltF7返回GDM登录屏幕)。将屏幕截图转换为JPEG和/或PNG:

convert -quality 50 /tmp/shot.xwd /tmp/shot.jpg
convert /tmp/shot.xwd /tmp/shot.png

在您喜欢的图像查看器中查看屏幕截图。


4
我最终sudo sh -c 'sleep 5s; xwd -display :0 -root | convert - screenshot.png'从虚拟控制台使用,并在5秒钟的睡眠期间切换到登录屏幕。
ændrük

3
我针对lightdm进行了调整。$ echo'DISPLAY =:0 XAUTHORITY = / var / run / lightdm / root /:0 xwd -root'> /tmp/shot.sh
popey 2012年

11

对于11.10和Lightdm及更高版本

您可以尝试unity-greeter --test-mode在终端中运行。它在会话中显示登录屏幕。然后,您可以像通常使用任何其他应用程序一样对登录屏幕进行截图。

在此处输入图片说明


但是那太笼统了,看不到任何修改。有什么方法可以测试当前的修改?
Ubuntuser

@Ubuntuser我不知道。您正在测试哪种修改?
jokerdino

我正在测试指纹读取器。在登录屏幕和锁定屏幕上,它显示很好。我想同时截图。
Ubuntuser

@Ubuntuser我猜您所做的修改会直接影响lightdm,而不是Unity-greeter?我不确定。我只是在推测。您可能要问一个新的问题..
jokerdino

8

您可以尝试以下方法:

gnome-screenshot -d 10

您无需安装任何东西,只需输入命令并锁定屏幕,屏幕将在执行命令后的10秒钟内拍摄。

甚至更多..该命令将锁定屏幕,将屏幕截图复制到剪贴板,然后再次解锁屏幕。全部靠自己。

gnome-screensaver-command -l && sleep 2 && gnome-screenshot -c && loginctl unlock-session

 在此处输入图片说明


3
到目前为止,这是我找到的最简单的解决方案。
苛性

7

对于Ubuntu 14.04

上面的答案在Ubuntu 14.04中对我不起作用-我四处搜索并发现这有效。

  1. 安装ImageMagick

    sudo apt-get install imagemagick
    
  2. 在您的主目录中创建一个文件(shot.sh最好在主文件夹中命名),并将以下代码粘贴到其中:

    chvt 7;
    sleep 5s;
    DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 xwd -root -out ~/screenshot.xwd;
    convert ~/screenshot.xwd ~/screenshot.png;
    rm ~/screenshot.xwd
    
  3. 使它可执行

    sudo chmod +x shot.sh
    
  4. 注销系统。按Ctrl+ Alt+ F1转到控制台(tty1)并登录。使用以下命令运行脚本:

    sudo ./shot.sh
    

它将带您返回登录屏幕图形界面(第7章),并在五秒钟后将屏幕快照和文件名保存到您的主目录中screenshot.png


这是我的:

在此处输入图片说明

来源:http//itsfoss.com/screenshot-login-screen-ubuntu-linux/


我可以确认此Shell脚本仍可在带有Unity 7.5.0的Ubuntu 18.10 Cosmic Cuttlefish上使用。我可以尝试一次成功截图。谢谢@Parto。
阿德·马尔萨萨·阿克巴尔

6

在终端中输入以下内容:

dm-tool add-nested-seat --fullscreen

而已!照常截图

按Alt + F4关闭登录屏幕的全屏窗口


太美了!天才!
安华

我还可以确认此技巧可以在Ubuntu 18.10上完美运行。我认为这个技巧比shell脚本更容易,更快捷。谢谢@afriend。
阿德·马尔萨萨·阿克巴尔

2

只是想说明一下,在Ubuntu 10.04 LTS上使用此方法遇到很多问题,这是我的解决方案:

我在机器A上,并通过ssh登录到机器B:

myusername@pcA:~$ ssh pcB
myusername@pcB's password: 
Linux pcB 2.6.32-44-generic #98-Ubuntu SMP Mon Sep 24 17:32:45 UTC 2012 i686 GNU/Linux
Ubuntu 10.04.4 LTS

Welcome to Ubuntu!
 * Documentation:  https://help.ubuntu.com/

myusername@pcB:~$ 

然后,我进行了几次尝试以截取屏幕截图的尝试,但都失败了。可以将问题减少xwininfo为无法探测窗口状态:

myusername@pcB:~$  xwininfo
xwininfo:  unable to open display ''

myusername@pcB:~$ sudo xwininfo
[sudo] password for myusername: 
xwininfo:  unable to open display ''

myusername@pcB:~$ DISPLAY=:0.0 xwininfo
No protocol specified
xwininfo:  unable to open display ':0.0'

myusername@pcB:~$ DISPLAY=:0 xwininfo
No protocol specified
xwininfo:  unable to open display ':0'

好吧,事实证明,由于某种原因,通过ssh定向X窗口的正确调用是DISPLAY=:0.0 sudo xwininfo ...-即DISPLAY=:0.0环境变量优先;所述sudo进入第二-然后相应的X命令:

myusername@pcB:~$ DISPLAY=:0 sudo xwininfo

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

myusername@pcB:~$ DISPLAY=:0.0 sudo xwininfo -root

xwininfo: Window id: 0x109 (the root window) (has no name)

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1366
  Height: 768
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1366x768+0+0

现在我们知道xwininfo可以探测状态了,通过xwd以下方式捕获屏幕截图也没有问题:

myusername@pcB:~$ DISPLAY=:0.0 sudo xwd -root > /tmp/shot.xwd

0

我编辑了“ / etc / mdm / Init / Default”并添加了:

scrot -d 5 -e 'mv $f /root' &

在“退出0”行之前。

下次登录时,蜂鸣声达到五次,并且屏幕截图位于“ / root”目录中。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.