[PR] dylanaraps/neofetch#2305 from BomberFish - Fix Chrome OS.

Upstream PR: https://github.com/dylanaraps/neofetch/pull/2305
Thanks to @BomberFish

Co-authored-by: BomberFish <87151697+BomberFish@users.noreply.github.com>
This commit is contained in:
Hykilpikonna 2023-03-15 16:23:35 -04:00
commit 5343182ea1
No known key found for this signature in database
GPG key ID: 256CD01A41D7FA26

View file

@ -1187,6 +1187,12 @@ get_distro() {
elif [[ -f /etc/vzlinux-release ]]; then elif [[ -f /etc/vzlinux-release ]]; then
distro='VzLinux' distro='VzLinux'
# Chrome OS doesn't conform to the /etc/*-release standard.
# While the file is a series of variables they can't be sourced
# by the shell since the values aren't quoted.
elif grep -q CHROMEOS /etc/lsb-release; then
distro='Chrome OS'
elif type -p guix >/dev/null; then elif type -p guix >/dev/null; then
case $distro_shorthand in case $distro_shorthand in
on|tiny) distro="Guix System" ;; on|tiny) distro="Guix System" ;;
@ -1255,11 +1261,14 @@ get_distro() {
distro='Chrome OS' distro='Chrome OS'
elif [[ $(< /proc/version) == *chrome-bot* || -f /dev/cros_ec ]]; then elif [[ $(< /proc/version) == *chrome-bot* || -f /dev/cros_ec ]]; then
# gets chrome os version from /etc/lsb-release.
# totally not written by chatgpt :trolley:
cros_version=$(grep -oE 'CHROMEOS_RELEASE_CHROME_MILESTONE=([0-9]+)' /etc/lsb-release | cut -d= -f2)
[[ $distro != *Chrome* ]] && [[ $distro != *Chrome* ]] &&
case $distro_shorthand in case $distro_shorthand in
on) distro="Chrome OS $distro" ;; on) distro="Chrome OS $cros_version" ;;
tiny) distro="Chrome OS" ;; tiny) distro="Chrome OS" ;;
*) distro="Chrome OS $distro" ;; *) distro="Chrome OS $cros_version $distro" ;;
esac esac
fi fi