Closed AkerDark closed 1 year ago
-
Puedes abrir el archivo .local/bin/sysfetch borrarlo todo y reemplazarlo completo con este;
#!/usr/bin/env bash
# sysfetch
# Thanks to u/x_ero for his sysinfo script
# Modified by gh0stzk https://github.com/gh0stzk/dotfiles
# color escapes
PBLK=$(printf "%b" "\x1b[38;2;58;58;58m")
PRED=$(printf "%b" "\e[31m")
PGRN=$(printf "%b" "\e[32m")
PYLW=$(printf "%b" "\e[33m")
PBLU=$(printf "%b" "\e[34m")
PPUR=$(printf "%b" "\e[35m")
PCYN=$(printf "%b" "\e[36m")
PWHT=$(printf "%b" "\e[37m")
PGRY=$(printf "%b" "\e[90;1m")
PRST=$(printf "%b" "\e[0m")
PBLD=$(printf "%b" "\033[1m")
# vars
FULL=━
EMPTY=━
name=$USER
host=$(uname -n)
distro=$(uname -o | awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release)
wm=$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t | grep "WM_NAME" | cut -f2 -d \")
get_pkg_count() {
package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge')
for package_manager in ${package_managers[@]}; do
if command -v $package_manager 2>/dev/null>&2; then
case "$package_manager" in
xbps-install ) xbps-query -l | wc -l ;;
apk ) apk search | wc -l ;;
apt ) apt list --installed 2>/dev/null | wc -l ;;
pacman ) pacman -Q | wc -l ;;
nix ) nix-env -qa --installed '*' | wc -l ;;
dnf ) dnf list installed | wc -l ;;
rpm ) rpm -qa | wc -l ;;
emerge ) qlist -I | wc -l ;;
esac
# if a package manager is found return from the function
return
fi
done
echo 'Unknown'
}
storage=$(df -h / | awk '/^\//{print $3}')
term=$(ps -o sid= -p "$$" | xargs ps -o ppid= -p | xargs ps -o comm= -p)
uptm=$(uptime -p | sed -e 's/hour/hr/' -e 's/hours/hrs/' -e 's/minutes/mins/' -e 's/minute/min/' -e 's/up //')
#Cleanup first
clear
# find the center of the screen
COL=$(tput cols)
ROW=$(tput lines)
((PADY = ROW / 2 - 10 - 22 / 2))
((PADX = COL / 2 - 34 / 2))
for ((i = 0; i < PADX; ++i)); do
PADC="$PADC "
done
for ((i = 0; i < PADY; ++i)); do
PADR="$PADR\n"
done
# vertical padding
printf "%b" "$PADR"
printf "\n"
PADXX=$((PADX - 3))
for ((i = 0; i < PADXX; ++i)); do
PADCC="$PADCC "
done
# Ascii art arms
cat <<EOF
$PADCC$PBLD $PBLU.
$PADCC $PBLU/ $PPUR\\
$PADCC $PBLU/ $PPUR\\
$PADCC $PBLU/^. $PPUR\\
$PADCC $PBLU/ .$PWHT-$PPUR. \\
$PADCC $PBLU/ ( $PPUR) _\\
$PADCC $PBLU/ _.~ $PPUR~._^\\
$PADCC $PBLU/.^ $PPUR^.\\
EOF
BAR=" ▓▒░"
OUTT="$PBLK$BAR$PRED$BAR$PGRN$BAR$PYLW$BAR$PBLU$BAR$PPUR$BAR$PCYN$BAR$PWHT$BAR$PRST"
printf "%s%b" "$PADC" "$OUTT"
printf "\n\n"
# greetings
printf "%s%b" "$PADC" " hola $PRED$PBLD$name$PRST\n"
printf "%s%b" "$PADC" " Bienvenido a $PGRN$BLD$host$PRST\n"
printf "%s%b" "$PADC" " up $PCYN$BLD$uptm$PRST\n\n"
# environment
printf "%s%b" "$PADC" "$PRED distro $PGRY⏹ $PRST$distro\n"
printf "%s%b" "$PADC" "$PBLU kernel $PGRY⏹ $PRST$(uname -r)\n"
printf "%s%b" "$PADC" "$PPUR packages $PGRY⏹ $PRST$(get_pkg_count)\n"
printf "%s%b" "$PADC" "$PGRN shell $PGRY⏹ $PRST${SHELL##*/}\n"
printf "%s%b" "$PADC" "$PYLW term $PGRY⏹ $PRST$term\n"
printf "%s%b" "$PADC" "$PCYN wm $PGRY⏹ $PRST${wm}\n"
printf "%s%b" "$PADC" "$PBLU disk $PGRY⏹ $PRST$storage used\n"
printf " $PRST\n"
# progress bar
draw() {
perc=$1
size=$2
inc=$((perc * size / 100))
out=
color="$3"
for v in $(seq 0 $((size - 1))); do
test "$v" -le "$inc" &&
out="${out}\e[1;${color}m${FULL}" ||
out="${out}\e[0;37m${PGRY}${EMPTY}"
done
printf $out
}
# cpu
cpu=$(grep 'cpu ' /proc/stat | awk '{usage=($2+$4)*100/($2+$4+$5)} END {print usage}')
c_lvl=$(printf "%.0f" "$cpu")
printf "%b" "$PADC"
printf " $PPUR%-4s $PWHT%-5s %-25s \n" " cpu" "$c_lvl%" $(draw $c_lvl 15 35)
# ram
ram=$(free | awk '/Mem:/ {print int($3/$2 * 100.0)}')
printf "%b" "$PRST" "$PADC"
printf " $PPUR%-4s $PWHT%-5s %-25s \n" " ram" "$ram%" $(draw $ram 15 35)
# hide the cursor and wait for user input
tput civis
read -n 1
# give the cursor back
tput cnorm
He cambiado todo el archivo completo por el que me acabas de enviar y al parecer el error es el sistema de números por que me sale numeró invalido y me muestra el número 8.77372 y si lo cierro y lo vuelvo a abrir me aparece otro número y me sale el número es invalido
ya el problema es en el codigo del cpu, soy sincero es dificil, solucionarlo por que a mi me funciona tal como esta, y me han enviado imagenes de que a demas gente tambien, sin embargo eres la segunda persona que me dice de este error, el codigo esta bien, el problema es el formato. Puedes cambiar esta linea
c_lvl=$(printf "%.0f" "$cpu")
por esto
c_lvl=`printf "%.0f" $cpu`
He tratado de haberiguar un modo pero no lo encuentro por que me sigue saliendo el problema de número invalido en la misma línea, así cambie el formato
Hola, buen dia, podrias editar tu archivo por este y me dices si se soluciono por favor.;
#!/bin/sh
# sysfetch
# Thanks to u/x_ero for his sysinfo script
# Modified by gh0stzk https://github.com/gh0stzk/dotfiles
# color escapes
CBK=$(tput setaf 0)
CRE=$(tput setaf 1)
CGR=$(tput setaf 2)
CYE=$(tput setaf 3)
CBL=$(tput setaf 4)
CMA=$(tput setaf 5)
CCY=$(tput setaf 6)
CWH=$(tput setaf 7)
CBD=$(tput bold)
CNC=$(tput sgr0)
# vars
FULL=━
EMPTY=━
name=$USER
host=$(uname -n)
distro=$(uname -o | awk -F '"' '/PRETTY_NAME/ { print $2 }' /etc/os-release)
wm=$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') -notype -f _NET_WM_NAME 8t | grep "WM_NAME" | cut -f2 -d \")
get_pkg_count() {
package_managers=('xbps-install' 'apk' 'apt' 'pacman' 'nix' 'dnf' 'rpm' 'emerge')
for package_manager in ${package_managers[@]}; do
if command -v $package_manager 2>/dev/null>&2; then
case "$package_manager" in
xbps-install ) xbps-query -l | wc -l ;;
apk ) apk search | wc -l ;;
apt ) apt list --installed 2>/dev/null | wc -l ;;
pacman ) pacman -Q | wc -l ;;
nix ) nix-env -qa --installed '*' | wc -l ;;
dnf ) dnf list installed | wc -l ;;
rpm ) rpm -qa | wc -l ;;
emerge ) qlist -I | wc -l ;;
esac
# if a package manager is found return from the function
return
fi
done
echo 'Unknown'
}
storage=$(df -h / | awk '/^\//{print $3}')
term=$(ps -o sid= -p "$$" | xargs ps -o ppid= -p | xargs ps -o comm= -p)
uptm=$(uptime -p | sed -e 's/hour/hr/' -e 's/hours/hrs/' -e 's/minutes/mins/' -e 's/minute/min/' -e 's/up //')
#Cleanup first
clear
# find the center of the screen
COL=$(tput cols)
ROW=$(tput lines)
((PADY = ROW / 2 - 10 - 22 / 2))
((PADX = COL / 2 - 34 / 2))
for ((i = 0; i < PADX; ++i)); do
PADC="$PADC "
done
for ((i = 0; i < PADY; ++i)); do
PADR="$PADR\n"
done
# vertical padding
printf "%b" "$PADR"
printf "\n"
PADXX=$((PADX - 3))
for ((i = 0; i < PADXX; ++i)); do
PADCC="$PADCC "
done
# Ascii art arms
cat <<EOF
$PADCC$CBD $CBL.
$PADCC $CBL/ $CMA\\
$PADCC $CBL/ $CMA\\
$PADCC $CBL/^. $CMA\\
$PADCC $CBL/ .$CWH-$CMA. \\
$PADCC $CBL/ ( $CMA) _\\
$PADCC $CBL/ _.~ $CMA~._^\\
$PADCC $CBL/.^ $CMA^.\\
EOF
BAR=" ▓▒░"
OUTT="$CBK$BAR$CRE$BAR$CGR$BAR$CYE$BAR$CBL$BAR$CMA$BAR$CCY$BAR$CWH$BAR$CNC"
printf "%s%b\n\n" "$PADC" "$OUTT"
# greetings
printf "%s%b\n" "$PADC" " hola $CRE$CBD$name$CNC"
printf "%s%b\n" "$PADC" " Bienvenido a $CGR$CBD$host$CNC"
printf "%s%b\n\n" "$PADC" " up $CCY$CBD$uptm$CNC"
# environment
printf "%s%b" "$PADC" "$CRE distro $CWH⏹ $CNC$distro\n"
printf "%s%b" "$PADC" "$CBL kernel $CWH⏹ $CNC$(uname -r)\n"
printf "%s%b" "$PADC" "$CMA packages $CWH⏹ $CNC$(get_pkg_count)\n"
printf "%s%b" "$PADC" "$CGR shell $CWH⏹ $CNC${SHELL##*/}\n"
printf "%s%b" "$PADC" "$CYE term $CWH⏹ $CNC$term\n"
printf "%s%b" "$PADC" "$CCY wm $CWH⏹ $CNC${wm}\n"
printf "%s%b" "$PADC" "$CBL disk $CWH⏹ $CNC$storage used\n"
printf " $CNC\n"
# progress bar
draw() {
perc=$1
size=$2
inc=$((perc * size / 100))
out=
color="$3"
for v in $(seq 0 $((size - 1))); do
test "$v" -le "$inc" &&
out="${out}\e[1;${color}m${FULL}" ||
out="${out}\e[0;37m${CWH}${EMPTY}"
done
printf $out
}
# cpu
cpu=$(awk -v a="$(awk '/cpu /{print $2+$4,$2+$4+$5}' /proc/stat; sleep 1)" '/cpu /{split(a,b," "); print 100*($2+$4-b[1])/($2+$4+$5-b[2])}' /proc/stat)
c_lvl=`printf "%.0f" $cpu`
printf "%b" "$PADC"
printf " $CMA%-4s $CWH%-5s %-25s \n" " cpu" "$c_lvl%" $(draw $c_lvl 15 35)
# ram
ram=$(free | awk '/Mem:/ {print int($3/$2 * 100.0)}')
printf "%b" "$CNC" "$PADC"
printf " $CMA%-4s $CWH%-5s %-25s \n" " ram" "$ram%" $(draw $ram 15 35)
# hide the cursor and wait for user input
tput civis
read -n 1
# give the cursor back
tput cnorm
hola, buena noche, lo he copiado y sigue lo mismo, número invalido
Hola podria modificar por favor esta linea:
c_lvl=`printf "%.0f" $cpu`
por esta
c_lvl=`printf "%1.f" $cpu`
New file updated, now must work for everyone.
Hello, Sorry to bother you with this error but I have tried to fix it but I could not find any way to fix it, please could you help me.![sysfetch](https://user-images.githubusercontent.com/100214431/213330618-9ee99bec-fedd-4f8c-8468-7570191af204.png)