Open jraby opened 4 years ago
That works well, too. Thanks.
Fails on Pi OS Bookwarn with the following message... 6: function: not found
The script only works with bash
, it relies on bash's read
built-in (specifically its -d
option)
That is what is odd... I am using BASH, on Pi OS. I was able to get around it by embedding the following in my .bashrc script file. Still testing this it will force the (agetty) based serial console (say opened with putty) to the desired rows and columns but is not perfect, if you happen to have the putty (COM) session smaller than 60 x 200 it will resize the terminal window and everything seems to honor it... but if serial console is bigger than 60 x 200 it does not seem to shrink the (putty) terminal window (which I expected). I can live with the issue, since typically putty defaults to 24x80 on serial consoles.
if [ $(tty) = "/dev/ttyS0" ]; then
stty rows 60 cols 200
echo -e "\033[8;60;200t"
fi
The big headache is that agetty just does not seem to have any easy way to be changed, looking at the C source code. It defaults to 24x80 but only it the agetty executable does not get a valid terminal size returned
1395 /* Check for terminal size and if not found set default */
1396 if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) == 0) {
1397 if (ws.ws_row == 0)
1398 ws.ws_row = 24;
1399 if (ws.ws_col == 0)
1400 ws.ws_col = 80;
1401 if (ioctl(STDIN_FILENO, TIOCSWINSZ, &ws))
1402 debug("TIOCSWINSZ ioctl failed\n");
1403 }
Would be nice if agetty could be changed to honor say a configuration file in say /etc/default, or such that would allow a default rows and columns values to be set and consistently honored.
(this is not really an issue)
First, thanks for the blogpost about termsize, it got me started on some yak shaving I didn't intend to do today... :-)
While reading your post I figured there should be a way to do it without python at all.
Here's a way to do it, I thought you might be interested.
Also, busybox has
resize(1)
. (which I discovered after writing the above...) https://git.busybox.net/busybox/tree/console-tools/resize.c#n85