在此之前我先把code寫在下面。code中如果你在程序中出現問題就看code前的注意,我在執行時出現以下錯誤。
1:在我標註紅色字體的是最容易出錯的地方,因爲它直接影響你的捕抓當前窗口的大小,也只有這個地方要你改的,但該起來容易,主要是在分析,看分析這個code?
2:但你按照程序的如入是會出現這個錯誤,就是“xwininfo 幫助信息”。原因出在哪兒?
3:出錯原因就是你的當前終端會話標題,把下面的紅色字體,改爲你當前終端會話標題,但又不能亂改。怎麼改才合理?
4:使用"xwininfo -root -tree" 這個命令,來獲取你的當前終端會話窗口,看下面一行,就是我的當前會話id 窗口名 (括號裏的你不用管) WidthxHeight+0+0 +x+y,(其中的x和y就是程序裏的了),這樣就找到了我的當前會話窗口了,然後把code的紅色字體改了你的當前會話名,就可以了。java基礎教程
0x2600019 "Desktop : bash": ("konsole" "Konsole") 843x591+0+0 +470+50
#!/bin/bash
# A simple shell script wrapper to record current terminal session of a linux
# desktop. May work under other Unix like operating systems too.
# Tested on RHEL 6.x, Debian 6.x, and Ubuntu Linux
# ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/> 這是原代碼官方
# (c) 2012 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated: 19/Aug/2012
# ----------------------------------------------------------------------------
_xw=/usr/bin/xwininfo
_recd=/usr/bin/recordmydesktop
_awk=/usr/bin/awk
_grep=/bin/grep
_file="$1"
_output=""
# change this to match your PS1 settings
_regex='"Desktop : bash":'
die(){
echo -e "$1"
exit ${2:9999}
}
[ $# -eq 0 ] && die "Usage: $0 filename.ogv\n\nRecord terminal desktop sessions under Linux or Unix." 1
# add extension .ogv if not given
_ext="${_file%%.ogv}"
[[ "$_ext" == "$_file" ]] && _output="$_file.ogv" || _output="$_file"
[ ! -x "$_xw" ] && die "Error: $_xw not found or set correct \$_xw in $0" 2
[ ! -x "$_recd" ] && die "Error: $_recd not found or set correct \$_recd in $0" 3
[ ! -x "$_awk" ] && die "Error: $_awk not found or set correct \$_awk in $0" 4
[ ! -x "$_grep" ] && die "Error: $_grep not found or set correct \$_grep in $0" 5
#get terminal window id
_id=$($_xw -root -tree | $_grep "$_regex" | $_awk '{ print $1}')
#get terminal windows x,y, width, and hight
_x=$($_xw -id $_id | $_grep 'Absolute upper-left X' | $_awk '{ print $4}')
_y=$($_xw -id $_id | $_grep 'Absolute upper-left Y' | $_awk '{ print $4}')
_w=$($_xw -id $_id | $_grep 'Width:' | $_awk '{ print $2}')
_h=$($_xw -id $_id | $_grep 'Height:' | $_awk '{ print $2}')
x=$(( $_x + 8 ))
y=$(( $_y + 57 ))
width=$(( $_w -31 ))
height=$(( $_h -62 ))
$_recd --no-sound -x $x -y $y --width $width --height $height -o $_output
怎麼使用代碼?這裏我原文裏的不翻譯了。
Open a terminal.
Open Tab.
Run script as:
./script.sh foo.ogv
Switch to tab # 1 and run your command.
When done switch back to tab #2 and press CTRL + C to save recording to foo.ogv.
To run foo.ogv type:
gnome-open foo.ogv
or
mplayer foo.ogv
More aritcle about linux Link:http://note.sdo.com/u/_mr.jian/
1:在我標註紅色字體的是最容易出錯的地方,因爲它直接影響你的捕抓當前窗口的大小,也只有這個地方要你改的,但該起來容易,主要是在分析,看分析這個code?
2:但你按照程序的如入是會出現這個錯誤,就是“xwininfo 幫助信息”。原因出在哪兒?
3:出錯原因就是你的當前終端會話標題,把下面的紅色字體,改爲你當前終端會話標題,但又不能亂改。怎麼改才合理?
4:使用"xwininfo -root -tree" 這個命令,來獲取你的當前終端會話窗口,看下面一行,就是我的當前會話id 窗口名 (括號裏的你不用管) WidthxHeight+0+0 +x+y,(其中的x和y就是程序裏的了),這樣就找到了我的當前會話窗口了,然後把code的紅色字體改了你的當前會話名,就可以了。java基礎教程
0x2600019 "Desktop : bash": ("konsole" "Konsole") 843x591+0+0 +470+50
#!/bin/bash
# A simple shell script wrapper to record current terminal session of a linux
# desktop. May work under other Unix like operating systems too.
# Tested on RHEL 6.x, Debian 6.x, and Ubuntu Linux
# ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/> 這是原代碼官方
# (c) 2012 nixCraft under GNU GPL v2.0+
# ----------------------------------------------------------------------------
# Last updated: 19/Aug/2012
# ----------------------------------------------------------------------------
_xw=/usr/bin/xwininfo
_recd=/usr/bin/recordmydesktop
_awk=/usr/bin/awk
_grep=/bin/grep
_file="$1"
_output=""
# change this to match your PS1 settings
_regex='"Desktop : bash":'
die(){
echo -e "$1"
exit ${2:9999}
}
[ $# -eq 0 ] && die "Usage: $0 filename.ogv\n\nRecord terminal desktop sessions under Linux or Unix." 1
# add extension .ogv if not given
_ext="${_file%%.ogv}"
[[ "$_ext" == "$_file" ]] && _output="$_file.ogv" || _output="$_file"
[ ! -x "$_xw" ] && die "Error: $_xw not found or set correct \$_xw in $0" 2
[ ! -x "$_recd" ] && die "Error: $_recd not found or set correct \$_recd in $0" 3
[ ! -x "$_awk" ] && die "Error: $_awk not found or set correct \$_awk in $0" 4
[ ! -x "$_grep" ] && die "Error: $_grep not found or set correct \$_grep in $0" 5
#get terminal window id
_id=$($_xw -root -tree | $_grep "$_regex" | $_awk '{ print $1}')
#get terminal windows x,y, width, and hight
_x=$($_xw -id $_id | $_grep 'Absolute upper-left X' | $_awk '{ print $4}')
_y=$($_xw -id $_id | $_grep 'Absolute upper-left Y' | $_awk '{ print $4}')
_w=$($_xw -id $_id | $_grep 'Width:' | $_awk '{ print $2}')
_h=$($_xw -id $_id | $_grep 'Height:' | $_awk '{ print $2}')
x=$(( $_x + 8 ))
y=$(( $_y + 57 ))
width=$(( $_w -31 ))
height=$(( $_h -62 ))
$_recd --no-sound -x $x -y $y --width $width --height $height -o $_output
怎麼使用代碼?這裏我原文裏的不翻譯了。
Open a terminal.
Open Tab.
Run script as:
./script.sh foo.ogv
Switch to tab # 1 and run your command.
When done switch back to tab #2 and press CTRL + C to save recording to foo.ogv.
To run foo.ogv type:
gnome-open foo.ogv
or
mplayer foo.ogv
More aritcle about linux Link:http://note.sdo.com/u/_mr.jian/