Fbwall

Iš Žinynas.
00:41, 8 rugpjūčio 2022 versija, sukurta \dev\null (Aptarimas | indėlis) (Naujas puslapis: Scriptas skirtas uždėti wallpaperį ant linux framebuffer konsolių pasitelkiant fbterm ir fbi įrankius (pastarieji jau turi būti įdiegti sistemoje). <SyntaxHigh...)
(skirt) ← Ankstesnė versija | Dabartinė versija (skirt) | Vėlesnė versija → (skirt)
Jump to navigation Jump to search

Scriptas skirtas uždėti wallpaperį ant linux framebuffer konsolių pasitelkiant fbterm ir fbi įrankius (pastarieji jau turi būti įdiegti sistemoje).



#!/bin/bash
# (c) 2022 refurbished by e1z0
# source this file from your .bashrc

# Original 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: https://askubuntu.com/q/701874/295286

IMGPATH="/opt/fb"

if [[ ! -d $IMGPATH ]]; then
mkdir $IMGPATH
fi

function printUsage
{
  echo "<<< Script to set background image in TTY console"
  echo "<<< Written by Serg Kolo, Dec 5 , 2015"
  echo "<<< First time run: fbwall /path/to/image"
  echo "<<< It will generate corresponding image used by fbterm"
  echo "<<< Second times you only need to run fbwall without any parameters"
  echo "<<< But if you want to change wallpaper you must run with parameter"
  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 [ "$( tty | awk '{gsub(/[[:digit:]]/,""); gsub(/\/dev\//,"");print}' )" != "tty"  ] ;then
   exit 1
fi

# 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

if [[ "$1" != "" ]]; then
IMAGE="$( readlink -f "$@" )"
( sleep 1; cat /dev/fb0 > $IMGPATH/BACKGROUND.fbimg ) & fbi -t 2 -1 --noverbose -a  "$IMAGE"
fi

# This portion is really optional; you can comment it out 
# if you choose so

# 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 $IMGPATH/BACKGROUND.fbimg  > /dev/fb0 &) > /dev/null; fbterm