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() {
|
function output() {
|
||||||
val=0
|
val=0
|
||||||
@ -21,21 +35,22 @@ function output() {
|
|||||||
if [ $2 == "true" ]; then val=$(($val + 2)); fi
|
if [ $2 == "true" ]; then val=$(($val + 2)); fi
|
||||||
case "$val" in
|
case "$val" in
|
||||||
0)
|
0)
|
||||||
|
echo -en $UPTIMECOLOR
|
||||||
/bin/cat $MOTDPATH/motd
|
/bin/cat $MOTDPATH/motd
|
||||||
|
echo -en $UNAMECOLOR
|
||||||
uname $UNAMEARG
|
uname $UNAMEARG
|
||||||
|
echo -en $UPTIMECOLOR
|
||||||
uptime $UPTIMEARG
|
uptime $UPTIMEARG
|
||||||
;;
|
;;
|
||||||
|
|
||||||
1)
|
1)
|
||||||
/bin/cat $MOTDPATH/motd | $lx
|
/bin/cat $MOTDPATH/motd | $lx
|
||||||
echo "test"
|
|
||||||
echo -en $UNAMECOLOR
|
|
||||||
uname $UNAMEARG | $lx
|
uname $UNAMEARG | $lx
|
||||||
echo -en $UPTIMECOLOR
|
|
||||||
uptime $UPTIMEARG | $lx
|
uptime $UPTIMEARG | $lx
|
||||||
;;
|
;;
|
||||||
|
|
||||||
2)
|
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, ""; }'
|
/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
|
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, ""; }'
|
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)
|
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
|
/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
|
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
|
uptime $UPTIMEARG | awk '{ z = '$tput_cols' - length; y = int(z / 2); x = z - y; printf "%*s%s%*s\n", x, "", $0, y, ""; }' | $lx
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -54,8 +67,8 @@ function output() {
|
|||||||
printf '\033[0m' #reset colors
|
printf '\033[0m' #reset colors
|
||||||
}
|
}
|
||||||
|
|
||||||
# if [ $tput_cols -gt $MINTERMWIDTH ]
|
if [ $tput_cols -gt $MINTERMWIDTH ]
|
||||||
# then
|
then
|
||||||
if [ $TERM == "xterm-kitty" ]
|
if [ $TERM == "xterm-kitty" ]
|
||||||
then
|
then
|
||||||
if [ $((0 + RANDOM % 2)) -eq 0 ]
|
if [ $((0 + RANDOM % 2)) -eq 0 ]
|
||||||
@ -81,4 +94,4 @@ printf '\033[0m' #reset colors
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
output $LOLCAT $CENTER
|
output $LOLCAT $CENTER
|
||||||
# fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user