wren-linux / bin / nmtui
#!/bin/bash
# nmtui: written by Wren Linux parts/network-manager.sh
# NetworkManager's text interface in Wren Linux's colors: white on black, the
# chosen line reversed. The same colors as the install list (install-extras.sh).
# Colors you set yourself in NEWT_COLORS win. The real program is
# /usr/bin/nmtui (WREN_NMTUI points somewhere else, for tests).
# A button is drawn in compactbutton colors until Tab reaches it, then in button colors:
# button is the reversed pair so the chosen one shows.
# newt (whiptail, nmtui) reads #rrggbb colors only when the terminal says it
# has 24-bit color (COLORTERM=truecolor); otherwise it ignores them all and
# draws its own blue and red, the chosen line hard to see. foot has 24-bit
# color, so it is said for it. The Linux console has none and gets color
# names (its black is black; foot's "black" is a dark teal). Every one of
# newt's color sets is given: one left out stays red.
# In foot the black behind it is "default", the terminal's own background:
# foot makes only that one see-through (the bar's windows are, colors.alpha),
# and an explicit #000000 is drawn solid black over it.
if [ -z "${NEWT_COLORS:-}" ]; then
if [ "${TERM:-}" = linux ]; then
_w=white _b=black _g=gray _bg=black
else
_w='#ffffff' _b='#000000' _g='#aaaaaa' _bg=default
# the light theme: dark text (bin/theme; theme env prints only checked colors)
eval "$("$HOME/.local/bin/theme" env 2>/dev/null | grep -E "^NEWT_(TEXT|REVERSED|DIM)='[0-9a-f]{6}'\$")"
[ -z "${NEWT_TEXT:-}" ] || _w="#$NEWT_TEXT" _b="#$NEWT_REVERSED" _g="#$NEWT_DIM"
unset NEWT_TEXT NEWT_REVERSED NEWT_DIM
# S-Lang (newt's) clears the screen in white on black before newt's
# colors start; this makes that the terminal's own colors too
[ -n "${COLORFGBG:-}" ] || export COLORFGBG="default;default"
case ${COLORTERM:-} in truecolor | 24bit) ;; *) export COLORTERM=truecolor ;; esac
fi
NEWT_COLORS="root=$_w,$_bg border=$_w,$_bg window=$_w,$_bg shadow=$_b,$_bg title=$_w,$_bg"
NEWT_COLORS+=" button=$_b,$_w actbutton=$_b,$_w compactbutton=$_w,$_bg"
NEWT_COLORS+=" checkbox=$_w,$_bg actcheckbox=$_b,$_w entry=$_w,$_bg disentry=$_g,$_bg label=$_w,$_bg"
NEWT_COLORS+=" listbox=$_w,$_bg actlistbox=$_b,$_w sellistbox=$_w,$_bg actsellistbox=$_b,$_w"
NEWT_COLORS+=" textbox=$_w,$_bg acttextbox=$_b,$_w helpline=$_w,$_bg roottext=$_w,$_bg"
NEWT_COLORS+=" emptyscale=$_w,$_bg fullscale=$_b,$_w"
unset _w _b _g _bg
fi
export NEWT_COLORS
exec "${WREN_NMTUI:-/usr/bin/nmtui}" "$@"