尽管Foogod的答案对我不起作用,但是通过提供一半的解决方案(即读取帧缓冲区数据,同时fbi
在TTY屏幕上显示图像),确实使我朝着正确的方向前进。因此,我已授予他悬赏的答案。
贝娄(Bellow)是一个脚本,可以很容易地fbterm
将图像的部分路径作为单个命令行参数启动
用法
脚本必须保存在$PATH
变量中列出的目录中。最好它必须在您的个人$HOME/bin
文件夹中。请参阅如何将目录添加到PATH?关于如何将您的个人添加bin
到的说明$PATH
,但是bin
在您的主目录中创建一个名为的目录足以PATH
在重新登录时将其添加到。
该脚本还必须具有可执行权限。您可以使用设置chmod +x /path/to/script.sh
。
最后,必须与一起运行sudo
,以允许root访问以读写/dev/fb0
。
脚本源
也可以在我的Github存储库中找到。
#!/bin/bash
# Author : Serg Kolo
# Date: Dec 5, 2015
# Description: Script to render image and set it as background
# in conjunction with fbterm
# Depends: fbterm,fbi, awk
# Written for: /ubuntu//q/701874/295286
function printUsage
{
echo "<<< Script to set background image in TTY console"
echo "<<< Written by Serg Kolo, Dec 5 , 2015"
echo "<<< Usage: scriptName.sh /path/to/image"
echo "<<< Must be ran with root privileges, in TTY only"
echo "exiting"
}
# check if we're root, if there's at least one ARG, and it is a TTY
if [ "$(whoami)" != "root" ] || [ "$#" -eq 0 ] || [ "$( tty | awk '{gsub(/[[:digit:]]/,""); gsub(/\/dev\//,"");print}' )" != "tty" ] ;then
printUsage
exit 1
fi
# read the full path of the image
IMAGE="$( readlink -f "$@" )"
# Launch fbi with whatever image was supplied as command line arg
# then take out whatever is the data in framebuffer;
# Store that data to /tmp folder
( sleep 1; cat /dev/fb0 > /tmp/BACKGROUND.fbimg ; sleep 1; pkill fbi ) & fbi -t 2 -1 --noverbose -a "$IMAGE"
# This portion is really optional; you can comment it out
# if you choose so
echo "LAUNCH FBTERM ?(y/n)"
read ANSWER
if [ "$ANSWER" != "y" ] ; then
echo exiting
exit 1
fi
# The man page states that fbterm takes screenshot of
# what is currently in framebuffer and sets it as background
# if FBTERM_BACKGROUND_IMAGE is set to 1
# Therefore the trick is to send the framebuffer data captured
# in the last step (which will display the image on screen)
# and then launch fbterm. Note, that I send output from the command
# send to background in order to avoid the extra text displayed on
# screen. That way we have clear image in framebuffer, without
# the shell text, when we launch fbterm
export FBTERM_BACKGROUND_IMAGE=1
clear
( cat /tmp/BACKGROUND.fbimg > /dev/fb0 &) > /dev/null; sleep 0.25; fbterm
附加信息
事实证明用户不一定需要使用sudo
; /dev/fb0
属于video
集团,所以用户可以只将自己添加到该组使用
sudo usermod -a -G video $USER
因此,以上脚本中对root的检查变得过时,特别是[ "$(whoami)" != "root" ] ||
一部分。