1、安装feh
sudo apt install feh
2、设置脚本文件 display_image.sh
#!/bin/bash
# 设置输出文件路径
OUTPUT_FILE="/home/yky/hello.txt"
# 将输出重定向到指定的文件
exec 1>$OUTPUT_FILE 2>&1
# 脚本路径
IMAGE_PATH="/home/yky/GL01_Login.png"
# 打印开始执行的信息
echo "Starting the script to display the image at: $IMAGE_PATH"
# 检查图片文件是否存在
if [ ! -f "$IMAGE_PATH" ]; then
echo "Error: Image file does not exist at the specified path: $IMAGE_PATH"
exit 1
else
echo "Confirmed: Image file exists."
fi
# 尝试使用 feh 打开图片
echo "Attempting to open image with feh..."
feh -F --no-menus "$IMAGE_PATH"
# 检查 feh 命令的退出状态
if [ $? -eq 0 ]; then
echo "Image displayed successfully."
else
echo "Failed to display image using feh."
fi
3、设置开机自启动