Blog: Linux 下定期屏幕截屏脚本(补 20111120): record-active-window.sh

File record-active-window.sh, 601 bytes (added by thinkbase, 6 years ago)
Line 
1#! /bin/bash
2
3mkdir screenshot
4echo "------------------------------------------------------------"
5
6PRE_FILE="not-exist"
7
8while(true); do
9    ACTIVE_WIN_ID=`xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)"| cut -d ' ' -f 5`
10
11    THE_WIN_ID=$ACTIVE_WIN_ID
12
13    FILE_NAME=`date +%Y%m%d-%H%M%S`
14
15    echo -ne "= \b"
16
17    import -window $THE_WIN_ID -screen -frame screenshot/$FILE_NAME.png
18
19    cmp -s screenshot/$FILE_NAME.png screenshot/$PRE_FILE.png
20    if [ $? == 0 ] ; then
21        echo -ne " [X]$PRE_FILE  \b"
22        rm -f screenshot/$PRE_FILE.png
23    fi
24
25    PRE_FILE=$FILE_NAME
26
27    sleep 1
28done
29