fbi
일련의 이미지를 표시하기 위해 bash 스크립트를 사용하려고 합니다 .jpg
. 그러나 일단 fbi
프로세스가 시작되면 계속해서 이미지를 순환하므로 설정된 기간 동안 각 이미지를 한 번만 표시하고 싶습니다.
답변1
부인 성명:나는 실제로 이것을 fbi로 테스트하지 않았습니다. 나는 여러 텍스트 파일과 함께 watch를 사용했습니다 (watch는 이미지가 아닌 텍스트를 표시하지만 fbi처럼 죽을 때까지 실행됩니다). 따라서 이론적으로 이 (또는 유사한) 기술은 또한 FBI와 협력해 보세요.
#!/bin/sh
# Where are the files?
IMG_PATH="/foo/bar/fred/"
cd $IMG_PATH
# File list. Can either be hard-coded, space separated,
# or to use the output of a command, use $(command). The
# safest approach is to use a shell glob as I have done here.
FILE_LIST=*.txt
# How long to run the command in seconds before killing it?
TIMEOUT=1
# For every file on the list...
for FILE in $FILE_LIST
do
# OK, this is where the magic happens...
# First invoke a shell and feed the mini script (in double quotes)
# to that shell. The mini script first executes fbi with whatever
# filename is now set to $FILE by the loop, meanwhile, whatever is
# in brackets gets executed simultaneously (sleep for $TIMEOUT seconds
# then force kill the second shell and all its children, including fbi).
# What the heck is \$\$? Well, $$ normally refers to the process ID
# of the script itself. But we don't want to kill the main script with
# the for loop - we want to loop to go on. So we escape the $$ with
# backslashes like so \$\$ so that literally "$$" gets passed to the
# second subshell, so it kills only itself (and fbi as its child).
#########################
# You can add parameters to fbi if you need to.
# Also you may want to try removing the -9 parameter to kill in
# case it messes up your framebuffer... not sure how well fbi
# handles a forceful (-9) vs. graceful (no -9) kill.
sh -c "(sleep $TIMEOUT; kill -9 \$\$) & exec fbi $FILE"
done
이것이 적어도 올바른 방향을 알려주기를 바랍니다... :)