LinuxGem
此处为老的 LinuxGem,新版 LinuxGem 请移步 www.linuxgem.org

简易截图脚本

galeki posted @ 2008年9月11日 14:09 in Bash 和它的朋友们 with tags 截图 , 3718 阅读

在 Gnome 下,按下 PrintScreen 和 Alt + PrintScreen 可以方便的截取和保存全屏和当前窗口的图像,但是要想截取部分屏幕画面就要麻烦一些,其实一个 4 行的 bash 脚本就可以解决这个问题:

#! /bin/bash
tmpfile=$(mktemp -u).png
scrot -s $tmpfile
targetfile=$(zenity --file-selection --save --confirm-overwrite 2> /dev/null)
mv $tmpfile $targetfile.png

第 2 行先用 mktemp  创建一个临时文件,第 3 行用 scrot 截图 (-s 是截取屏幕矩形区域),第 4 行弹出对话框询问保存地点,最后第 5 行把文件移动过去,就搞定了。

将上面的文件保存为 capture,然后 chmod +x capture,以后执行 capture 就可以方便的截图了。当然刚好的办法是在桌面边栏上建一个快捷方式,或者绑定到快捷键上~

如果你没有安装 scrot,但是安装了  imagemagick,可以用 import $tmpfile 来替换第 3 行,你也可以借助参数,在截图后自动打开图像,甚至播放提示音~

比那个 Screenshot Applet 好用多了……

anonymity 说:
2008年9月11日 18:25

Thanks,很好用。不妨再改改存储框的标题

zenity --title="save screenshot" --file-selection --save --confirm-overwrite

Head_small
galeki 说:
2008年9月11日 19:03

不错,多谢补充~

princelai 说:
2008年9月12日 08:55

很好!不过我用compiz那个

qqttdh 说:
2008年9月25日 20:50

#/bin/bash
scrot -s
exit

seo 说:
2021年12月29日 03:47

Caldwells is all that you will ever need when it comes to doors. They sell their products at the lowest prices which are made of the finest materials. If you don't believe me, you could https://www.digitekprinting.com/gator-board-posters them out through their website.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter