formats vm-nogui: resize only if /dev/tty exists

This commit is contained in:
lassulus 2022-02-02 14:35:39 +01:00
parent 296067b9c7
commit 494397272f

View File

@ -1,12 +1,14 @@
{ pkgs, ... }:
let
resize = pkgs.writeScriptBin "resize" ''
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\033[18t' > /dev/tty
IFS=';t' read -r _ rows cols _ < /dev/tty
stty "$old"
stty cols "$cols" rows "$rows"
if [ -e /dev/tty ]; then
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\033[18t' > /dev/tty
IFS=';t' read -r _ rows cols _ < /dev/tty
stty "$old"
stty cols "$cols" rows "$rows"
]
''; # https://unix.stackexchange.com/questions/16578/resizable-serial-console-window
in {
imports = [