启动程序,在GUI实例化时自动截屏,然后关闭程序


1

这是我的问题:我有一个shell脚本,我用它gitk --all .来表示git存储库的图形。我希望这个脚本无人值守运行,而不是在GUI模式下启动gitk,等待用户关闭它,我想以某种方式:

  • 启动gitk窗口
  • 当它实例化其GUI /窗口时,自动截取其窗口
  • 截图截取后,关闭 gitk

我想,而不是打电话

gitk --all .

...在我的bash脚本中,我会调用类似这样的伪代码:

my_scrshot_cmd --command "gitk --all ." --file myrandomfilename.png

这可以在Linux上做 - 如果是这样,我该怎么做?

Answers:


1

你可以尝试做这样的事情

gitk --all . &         # You run the gitk and go forward meanwhile
PidOfLastCommand=$!    # You need to remember the PID after
sleep 30s              # Change this value with the needed one... 
import screenshot.png  # From Imagemagick it saves the screenshot
kill $PidOfLastCommand # Let's we kill gitk

echo "### Just DONE ###" 

笔记:

  • 它需要安装Imagemagick(import但是,您可以使用您喜欢的命令更改命令)。
  • 你需要等待足够的时间sleep...进行一些测试,并采取一个舒适的价值(你必须确保它的工作)

非常感谢,@哈斯特尔 - 我确实有Imagemagick,所以这对我来说会有所帮助; 现在接受了...干杯!
sdaau 2015年
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.