我使用 Cheese 作為我的網路攝影機軟體。我正在嘗試找出一種方法來獲得它:
- 開始
- 點擊圖片
- 出口
執行腳本時。該腳本不應請求權限,也不應有任何中斷。迄今為止,
#!/bin/bash
cheese
我只能讓它執行步驟 1。文檔文件沒有提到這樣的選項,我不想更改原始碼。 (我也不介意相機)
答案1
瞧!步驟 2 和 3 如下:
這是有效的,儘管它對時間非常關鍵,根據您認為合適的情況進行調整,嘗試適當地評論它,以便您可以看到發生了什麼。
你需要安裝xdo工具為此,我們正在模擬按鍵來拍照並退出(包'xdo工具')
哦,你需要關閉'倒數' 功能在首選項中,否則它可能會在實際拍攝之前按 CTRL-Q(退出)退出程序。
#!/bin/bash
#
# L Nix <[email protected]>
# takeapic : take a photo with Cheese, using default settings, then exit
#
# start cheesing (2> because mine whines about cheesy stuff (ha!))
cheese 2>/dev/null &
# give WM some time to start up program (fails without this)
sleep 5
# set so we can determine if valid window(s) exist(s)
WINDOWIDS=""
# wait for up to 90 seconds (tweak this)
COUNTDOWN=90
while [ ${COUNTDOWN} -gt 0 ]; do
WINDOWIDS=$(xdotool search --class "cheese" 2>/dev/null)
if [ -n "${WINDOWIDS}" ]; then
break
fi
sleep 1
COUNTDOWN=$(( ${COUNTDOWN} - 1 ))
done
# did we get anything?
if [ -z "${WINDOWIDS}" ]; then
echo "Cheese never started, something's wrong"
exit 1
fi
# the shutter button is ALT-T
for WIDS in ${WINDOWIDS}; do
# if you combine these like xdotool allows, it fails
xdotool windowfocus ${WIDS} 2>/dev/null
xdotool key alt+t 2>/dev/null
done
# pause a moment while taking photo
sleep 1
# now CTRL-Q out of the application
for WIDS in ${WINDOWIDS}; do
xdotool windowfocus ${WIDS} 2>/dev/null
xdotool key ctrl+q 2>/dev/null
done
#