Skip to content

Instantly share code, notes, and snippets.

@zellio
Last active November 30, 2023 06:45
Show Gist options
  • Star 34 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save zellio/5809852 to your computer and use it in GitHub Desktop.
Save zellio/5809852 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
@ivspenna
Copy link

Awesome! Thanks!

@chaimleib
Copy link

chaimleib commented Dec 8, 2020

I'm trying fbterm under Raspbian Lite on a Raspberry Pi. If I type fbterm from the tty, things work fine, and vim shows things with an extended color palette, unlike without fbterm, where I'm much more limited and certain colors do not display. So fbterm is compatible with my hardware, and the pi user already has the necessary permissions for things to work.

However, when I tried to add exec fbterm to /etc/profile and log back in, fbterm stopped seeing my keyboard. I could use alt-right or alt-left to switch tty's, where I could type in a username and login, but once fbterm launched, it would not respond to normal keystrokes.

SysRq-r would show [<uptime in secs.usecs>] sysrq: Keyboard mode set to system default in the non-fbterm font.

SysRq-e would show rapid messages from killing fbterm and return to the login prompt, but the cursor underline would no longer appear and blink like normal. On the other hand, I could still type a username and login, only to get stuck in fbterm again.

On a subsequent attempt, I tried keeping tty2 open, where I ran sudo setcap 'cap_sys_tty_config+ep' $(command -v fbterm). Trying to login again on tty1 yielded the same result, except that SysRq-e now logged me out of all tty2 as well instead of just the current one.

@nvillar
Copy link

nvillar commented Feb 17, 2021

I'm running into the same issue, under the same conditions (Raspbian Lite on a Raspberry Pi). @chaimleib, did you ever find a workaround for this?

@chaimleib
Copy link

@nvillar no, not yet.

@timmypidashev
Copy link

Interesting, I am thinking of installing fbterm on the rpi myself, since I do not want to mess up my laptop install. I hope a workaround will be found soon.

@chaimleib
Copy link

I wonder now if the problem is a broken linkage between fbterm and the input-method program.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment