Skip to content

Instantly share code, notes, and snippets.

@abdelouahabb
Forked from zellio/fbterm-hacks.md
Created January 18, 2021 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdelouahabb/a17bcaf6c0f998e0d17925a8e101f33d to your computer and use it in GitHub Desktop.
Save abdelouahabb/a17bcaf6c0f998e0d17925a8e101f33d to your computer and use it in GitHub Desktop.
fbterm, installation and configuration hacks

fbterm setup and config hacks

Installation and setup

Install fbterm via your favorite package manager

pacman -S fbterm

Next you will need to grant a little bit of root to the fbterm executable so that it can do some magic with keyboards.

setcap 'cap_sys_tty_config+ep' $(command -v fbterm)

Finally you will need to add your user to the video group so you can access the device frame buffer /dev/fb0

usermod -aG video USERNAME

Run at login hacks

Running fbterm at login is easy, setting your shell variables is surprisingly not. I find that it works best just appending values to your /etc/profile rather than a new script in /etc/profile.d/ but I will probably revisit this at a later date.

Add the code in profile to the end of /etc/profile it sets a flag so you can wrangle your $TERM variable later, executes fbterm for you and injects a few color codes so that everything will render properly.

Next add the code in shellrc to your shell configurations somewhere. It will help to auto-dectect and set your $TERM variable properly. If $TERM is wrong, your colors won't work.

&c.

After installing fbterm and changing those config files you can just use normal color escapes in your display variables.

Configuration of fbterm is handled by $HOME/.fbtermrc which you should get a default copy of.

# hack for 256 color depth with fbterm
if [ "$TERM" = "linux" ]; then
echo -en "\e]P0222222" #black
echo -en "\e]P8222222" #darkgrey
echo -en "\e]P1803232" #darkred
echo -en "\e]P9982b2b" #red
echo -en "\e]P25b762f" #darkgreen
echo -en "\e]PA89b83f" #green
echo -en "\e]P3aa9943" #brown
echo -en "\e]PBefef60" #yellow
echo -en "\e]P4324c80" #darkblue
echo -en "\e]PC2b4f98" #blue
echo -en "\e]P5706c9a" #darkmagenta
echo -en "\e]PD826ab1" #magenta
echo -en "\e]P692b19e" #darkcyan
echo -en "\e]PEa1cdcd" #cyan
echo -en "\e]P7ffffff" #lightgrey
echo -en "\e]PFdedede" #white
FBTERM=1 exec fbterm
fi
#!/usr/bin/sh
case "$TERM" in
xterm*)
if [ -e /usr/share/terminfo/x/xterm-256color ]; then
export TERM=xterm-256color
elif [ -e /usr/share/terminfo/x/xterm-color ]; then
export TERM=xterm-color;
else
export TERM=xterm
fi
;;
linux)
[ -n "$FBTERM" ] && export TERM=fbterm
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment