Friday, March 6, 2015

Linux Console with Non-Blinking Block Hardware Cursor

By default linux console gets you hardware cursor (underlined and blinking). However, it's possible to change this with an appropriate terminal escape sequence. To get rid of blinking one has to enable software cursor instead. I've found that \E[?112c works reasonably well (gray background, with a bit dimmed foreground), however contrast is not that great and I haven't found a way to configure foreground color at all (instead setting it controls how much dimmed foreground will be).

I was wondering if there is a way to keep hardware cursor and just turn blinking off, since it's only way I've found to have true reverse cursor. Eventually, I've managed to do just that with following udev rule.

ACTION=="add|change", KERNEL=="fbcon", SUBSYSTEM=="graphics", ATTR{cursor_blink}="0"

Then edit linux terminfo entry (and install it globally).

$ infocmp -A /usr/share/terminfo linux linux
comparing linux to linux.
    comparing booleans.
    comparing numbers.
    comparing strings.
        cnorm: '\E[?25h\E[?0c', '\E[?25h\E[?8c'.
        rs2: NULL, '\E[?25h\E[?8c'.

To achieve same for agetty login, prepend rs2 value to /etc/issue.