Whiptailの背景色をその場で変更するにはどうすればいいでしょうか。例えば、赤、緑、黄色など、青は色が足りないようです。確認してみましたNewt アプリの紫色の背景色を取り除くにはどうすればいいですか?これは本当にシステムを破壊します。永続的な青が必要な場合は問題ありません。
たとえば、Ubuntu をインストールすると、一致するパスワードが得られない場合に背景色が変更されるので、それが実行可能であることはわかっています。Whiptail のマニュアルには、その方法について説明されていません。
これがベースなので、ニュートを扱っていることは知っていますが、そこでもどのように扱われるかは説明されていません。
答え1
whiptail の内部カラーパレットは、カラー定義を含むファイルへのパスを指定することにより、コンパイル時に上書きされる可能性があります。
Ubuntu では、sudo update-alternatives --config newt-palette
Ubuntu パレットとオリジナルのパレットを選択する方法が提供されています。
このファイルの場所は、NEWT_COLORS_FILE
別のファイルを指すように設定することで上書きできます。
さらに、環境変数を設定することで、以前の両方のオーバーライドをオーバーライドできますNEWT_COLORS
。
定義の構造は次のとおりです。
name=[fg],[bg][;|:|\n|\r|\t]name2=[fg],[bg]]...
name
次のいずれかになります。
root root fg, bg
border border fg, bg
window window fg, bg
shadow shadow fg, bg
title title fg, bg
button button fg, bg
actbutton active button fg, bg
checkbox checkbox fg, bg
actcheckbox active checkbox fg, bg
entry entry box fg, bg
label label fg, bg
listbox listbox fg, bg
actlistbox active listbox fg, bg
textbox textbox fg, bg
acttextbox active textbox fg, bg
helpline help line
roottext root text
emptyscale scale full
fullscale scale empty
disentry disabled entry fg, bg
compactbutton compact button fg, bg
actsellistbox active & sel listbox
sellistbox selected listbox
bg
また、fg
次のようになります。
color0 or black
color1 or red
color2 or green
color3 or brown
color4 or blue
color5 or magenta
color6 or cyan
color7 or lightgray
color8 or gray
color9 or brightred
color10 or brightgreen
color11 or yellow
color12 or brightblue
color13 or brightmagenta
color14 or brightcyan
color15 or white
赤いウィンドウ背景のメッセージ ボックスを表示する例:
#!/bin/sh
NEWT_COLORS='
window=,red
border=white,red
textbox=white,red
button=black,white
' \
whiptail --msgbox "passwords don't match" 0 0
Ubuntu カラーに追加:
#!/bin/bash
readarray -t newtcols < /etc/newt/palette
newtcols_error=(
window=,red
border=white,red
textbox=white,red
button=black,white
)
NEWT_COLORS="${newtcols[@]} ${newtcols_error[@]}" \
whiptail --msgbox "passwords don't match" 0 0