Fixing colors when is disabled lolcat
This commit is contained in:
parent
d1ad88abd3
commit
a36b2aa3f8
57
motd.sh
57
motd.sh
@ -1,19 +1,33 @@
|
||||
# Fancy waifu motd
|
||||
#####################################################################
|
||||
# #
|
||||
# Fancy waifu motd #
|
||||
# #
|
||||
#####################################################################
|
||||
|
||||
MOTDPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" # path to motd folder
|
||||
CACHEFILE="/tmp/waifu.cache" # to cache waifu state
|
||||
RESOLUTION=256 # resolution of waifu
|
||||
CENTER=true # center motd?
|
||||
LOLCAT=false # use lolcat? (start delay)
|
||||
UNAMEARG="-sr" # uname arguments
|
||||
UPTIMEARG="--pretty" # uptime arguments
|
||||
tput_cols=$(/usr/bin/tput cols) # terminal columns
|
||||
MINTERMWIDTH=200 # minimal width of term, to display motd
|
||||
UNAMECOLOR="\033[1;38;5;93m"
|
||||
UPTIMECOLOR="\033[1;38;5;99m"
|
||||
lx="$MOTDPATH/lolcat/lolcat"
|
||||
|
||||
WAIFUS=$(($(ls $MOTDPATH/waifus/*.256.png | wc -w) - 1)) # count of waifus
|
||||
##### User config
|
||||
#####################################################################
|
||||
RESOLUTION=128 # resolution of waifu
|
||||
CENTER=true # center motd?
|
||||
LOLCAT=true # use lolcat? (start delay)
|
||||
UNAMEARG="-sr" # uname arguments
|
||||
UPTIMEARG="--pretty" # uptime arguments
|
||||
MINTERMWIDTH=100 # minimal width of term, to display motd (change depending on resolution, 0 to disable)
|
||||
MOTDCOLOR="\033[0m" # Bash color code for motd text (no lolcat)
|
||||
UNAMECOLOR="\033[0m" # Bash color code for uname (no lolcat)
|
||||
UPTIMECOLOR="\033[0m" # Bash color code for uptime (no lolcat)
|
||||
#####################################################################
|
||||
|
||||
|
||||
##### Script config
|
||||
#####################################################################
|
||||
CACHEFILE="/tmp/waifu.cache" # to cache waifu state
|
||||
MOTDPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" # path to motd folder
|
||||
tput_cols=$(/usr/bin/tput cols) # terminal columns
|
||||
WAIFUS=$(($(ls $MOTDPATH/waifus/*.256.png | wc -w) - 1)) # count of waifus
|
||||
lx="$MOTDPATH/lolcat/lolcat" # lolcat
|
||||
#####################################################################
|
||||
|
||||
|
||||
function output() {
|
||||
val=0
|
||||
@ -21,21 +35,22 @@ function output() {
|
||||
if [ $2 == "true" ]; then val=$(($val + 2)); fi
|
||||
case "$val" in
|
||||
0)
|
||||
echo -en $UPTIMECOLOR
|
||||
/bin/cat $MOTDPATH/motd
|
||||
echo -en $UNAMECOLOR
|
||||
uname $UNAMEARG
|
||||
echo -en $UPTIMECOLOR
|
||||
uptime $UPTIMEARG
|
||||
;;
|
||||
|
||||
1)
|
||||
/bin/cat $MOTDPATH/motd | $lx
|
||||
echo "test"
|
||||
echo -en $UNAMECOLOR
|
||||
uname $UNAMEARG | $lx
|
||||
echo -en $UPTIMECOLOR
|
||||
uptime $UPTIMEARG | $lx
|
||||
;;
|
||||
|
||||
2)
|
||||
echo -en $MOTDCOLOR
|
||||
/bin/cat $MOTDPATH/motd | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }'
|
||||
echo -en $UNAMECOLOR
|
||||
uname $UNAMEARG | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }'
|
||||
@ -44,9 +59,7 @@ function output() {
|
||||
;;
|
||||
3)
|
||||
/bin/cat $MOTDPATH/motd | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }' | $lx
|
||||
echo -en $UNAMECOLOR
|
||||
uname $UNAMEARG | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }' | $lx
|
||||
echo -en $UPTIMECOLOR
|
||||
uptime $UPTIMEARG | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }' | $lx
|
||||
;;
|
||||
esac
|
||||
@ -54,8 +67,8 @@ function output() {
|
||||
printf '\033[0m' #reset colors
|
||||
}
|
||||
|
||||
# if [ $tput_cols -gt $MINTERMWIDTH ]
|
||||
# then
|
||||
if [ $tput_cols -gt $MINTERMWIDTH ]
|
||||
then
|
||||
if [ $TERM == "xterm-kitty" ]
|
||||
then
|
||||
if [ $((0 + RANDOM % 2)) -eq 0 ]
|
||||
@ -81,4 +94,4 @@ printf '\033[0m' #reset colors
|
||||
fi
|
||||
fi
|
||||
output $LOLCAT $CENTER
|
||||
# fi
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user