Newer
Older
minerva / Ports / neofetch / patches / 0001-Add-support-for-minerva.patch
@minerva minerva on 13 Jul 9 KB Initial commit
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Liav A <liavalb@gmail.com>
Date: Tue, 25 Oct 2022 22:06:54 +0300
Subject: [PATCH] Add support for minerva

Co-Authored-By: Andreas Kling <kling@serenityos.org>
Co-Authored-By: Nico Weber <thakis@chromium.org>
Co-Authored-By: Linus Groh <mail@linusgroh.de>
---
 neofetch | 130 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 100 insertions(+), 30 deletions(-)

diff --git a/neofetch b/neofetch
index 1e4b56462a08dd1ea27fcb21acc6da22f9b6a477..3c111b3207a2abd8107553d353dde9ba42f7bd82 100755
--- a/neofetch
+++ b/neofetch
@@ -794,7 +794,7 @@ image_source="auto"
 #       popos, Porteus, PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix,
 #       Raspbian, Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan,
 #       Regata, Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific,
-#       Septor, SereneLinux, SharkLinux, Siduction, Slackware, SliTaz,
+#       Septor, SereneLinux, Minerva, SharkLinux, Siduction, Slackware, SliTaz,
 #       SmartOS, Solus, Source_Mage, Sparky, Star, SteamOS, SunOS,
 #       openSUSE_Leap, openSUSE_Tumbleweed, openSUSE, SwagArch, Tails,
 #       Trisquel, Ubuntu-Budgie, Ubuntu-GNOME, Ubuntu-MATE, Ubuntu-Studio,
@@ -929,6 +929,7 @@ get_os() {
         AIX)      os=AIX ;;
         IRIX*)    os=IRIX ;;
         FreeMiNT) os=FreeMiNT ;;
+        Minerva) os=Minerva ;;
 
         Linux|GNU*)
             os=Linux
@@ -1185,6 +1186,10 @@ get_distro() {
         FreeMiNT)
             distro=FreeMiNT
         ;;
+
+        Minerva)
+            distro=Minerva
+        ;;
     esac
 
     distro=${distro//Enterprise Server}
@@ -1356,7 +1361,7 @@ get_title() {
 
 get_kernel() {
     # Since these OS are integrated systems, it's better to skip this function altogether
-    [[ $os =~ (AIX|IRIX) ]] && return
+    # [[ $os =~ (AIX|IRIX) ]] && return
 
     # Haiku uses 'uname -v' and not - 'uname -r'.
     [[ $os == Haiku ]] && {
@@ -1377,11 +1382,11 @@ get_kernel() {
     esac
 
     # Hide kernel info if it's identical to the distro info.
-    [[ $os =~ (BSD|MINIX) && $distro == *"$kernel_name"* ]] &&
-        case $distro_shorthand in
-            on|tiny) kernel=$kernel_version ;;
-            *)       unset kernel ;;
-        esac
+    # [[ $os =~ (BSD|MINIX) && $distro == *"$kernel_name"* ]] &&
+    #     case $distro_shorthand in
+    #         on|tiny) kernel=$kernel_version ;;
+    #         *)       unset kernel ;;
+    #     esac
 }
 
 get_uptime() {
@@ -1398,6 +1403,17 @@ get_uptime() {
             fi
         ;;
 
+        Minerva)
+            if [[ -r /sys/kernel/uptime ]]; then
+                s=$(< /sys/kernel/uptime)
+                s=${s/.*}
+            else
+                boot=$(date -d"$(uptime -s)" +%s)
+                now=$(date +%s)
+                s=$((now - boot))
+            fi
+        ;;
+
         "Mac OS X"|"macOS"|"iPhone OS"|BSD|FreeMiNT)
             boot=$(sysctl -n kern.boottime)
             boot=${boot/\{ sec = }
@@ -1628,6 +1644,8 @@ get_shell() {
         off) shell="${SHELL##*/} " ;;
     esac
 
+    [[ "$os" == Minerva ]] && shell="Minerva Shell "
+
     [[ $shell_version != on ]] && return
 
     case ${shell_name:=${SHELL##*/}} in
@@ -2096,13 +2114,13 @@ get_cpu() {
             speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
 
             # Select the right temperature file.
-            for temp_dir in /sys/class/hwmon/*; do
-                [[ "$(< "${temp_dir}/name")" =~ (coretemp|fam15h_power|k10temp) ]] && {
-                    temp_dirs=("$temp_dir"/temp*_input)
-                    temp_dir=${temp_dirs[0]}
-                    break
-                }
-            done
+            # for temp_dir in /sys/class/hwmon/*; do
+            #     [[ "$(< "${temp_dir}/name")" =~ (coretemp|fam15h_power|k10temp) ]] && {
+            #         temp_dirs=("$temp_dir"/temp*_input)
+            #         temp_dir=${temp_dirs[0]}
+            #         break
+            #     }
+            # done
 
             # Get CPU speed.
             if [[ -d "$speed_dir" ]]; then
@@ -2268,6 +2286,13 @@ get_cpu() {
             cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
             speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
         ;;
+
+        "Minerva")
+            cpu="$(jq -r '.[0].brand' /sys/kernel/cpuinfo)"
+            # `cpu` will contain "@ [speed]GHz" and to be super correct we
+            # have to cut that off and store it in `speed` only for neofetch
+            # to append it again later - but that's fine for now this way.
+        ;;
     esac
 
     # Remove un-needed patterns from cpu output.
@@ -2646,6 +2671,15 @@ get_memory() {
             mem_used="$((mem_used / 1024))"
         ;;
 
+        "Minerva")
+            memstat="$(cat /sys/kernel/memstat)"
+            physical_allocated="$(echo $memstat | jq .physical_allocated)"
+            physical_available="$(echo $memstat | jq .physical_available)"
+            mem_used="$((physical_allocated * 4096 / 1024 / 1024))"
+            mem_free="$((physical_available * 4096 / 1024 / 1024))"
+            mem_total="$((mem_used + mem_free))"
+        ;;
+
     esac
 
     [[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
@@ -2980,6 +3014,13 @@ get_style() {
     # Fix weird output when the function is run multiple times.
     unset gtk2_theme gtk3_theme theme path
 
+    if [[ "$os" == "Minerva" ]]; then
+        theme=$(ini /etc/WindowServer.ini Theme Name)
+        if [ -z "$theme" ]; then
+            theme="Default"
+        fi
+    fi
+
     if [[ "$DISPLAY" && $os != "Mac OS X" && $os != "macOS" ]]; then
         # Get DE if user has disabled the function.
         ((de_run != 1)) && get_de
@@ -3130,8 +3171,7 @@ get_icons() {
     xfconf="/Net/IconThemeName"
     kde="Theme"
 
-    get_style
-    icons="$theme"
+    icons=
 }
 
 get_font() {
@@ -3158,6 +3198,8 @@ get_term() {
         *)              term="${TERM_PROGRAM/\.app}" ;;
     esac
 
+    [[ "$os" == Minerva ]] && term="Minerva Terminal"
+
     # Most likely TosWin2 on FreeMiNT - quick check
     [[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && term="TosWin2"
     [[ "$SSH_CONNECTION" ]] && term="$SSH_TTY"
@@ -3722,10 +3764,10 @@ get_local_ip() {
 }
 
 get_public_ip() {
-    if type -p dig >/dev/null; then
-        public_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com)"
-       [[ "$public_ip" =~ ^\; ]] && unset public_ip
-    fi
+    # if type -p dig >/dev/null; then
+    #     public_ip="$(dig +time=1 +tries=1 +short myip.opendns.com @resolver1.opendns.com)"
+    #    [[ "$public_ip" =~ ^\; ]] && unset public_ip
+    # fi
 
     if [[ -z "$public_ip" ]] && type -p drill >/dev/null; then
         public_ip="$(drill myip.opendns.com @resolver1.opendns.com | \
@@ -3871,13 +3913,13 @@ image_backend() {
 }
 
 print_ascii() {
-    if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then
-        ascii_data="$(< "$image_source")"
-    elif [[ "$image_source" == "ascii" || $image_source == auto ]]; then
-        :
-    else
-        ascii_data="$image_source"
-    fi
+    # if [[ -f "$image_source" && ! "$image_source" =~ (png|jpg|jpeg|jpe|svg|gif) ]]; then
+    #     ascii_data="$(< "$image_source")"
+    # elif [[ "$image_source" == "ascii" || $image_source == auto ]]; then
+    #     :
+    # else
+    #     ascii_data="$image_source"
+    # fi
 
     # Set locale to get correct padding.
     LC_ALL="$sys_locale"
@@ -4650,8 +4692,8 @@ term_padding() {
             padding=${xrdb/*internalBorder:}
             padding=${padding/$'\n'*}
 
-            [[ $padding =~ ^[0-9]+$ ]] ||
-                padding=
+            # [[ $padding =~ ^[0-9]+$ ]] ||
+            #     padding=
         ;;
     esac
 }
@@ -4936,7 +4978,7 @@ ASCII:
                                 Porteus, PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix,
                                 Raspbian, Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan,
                                 Regata, Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific,
-                                Septor, SereneLinux, SharkLinux, Siduction, Slackware, SliTaz,
+                                Septor, SereneLinux, Minerva, SharkLinux, Siduction, Slackware, SliTaz,
                                 SmartOS, Solus, Source_Mage, Sparky, Star, SteamOS, SunOS,
                                 openSUSE_Leap, openSUSE_Tumbleweed, openSUSE, SwagArch, Tails,
                                 Trisquel, Ubuntu-Budgie, Ubuntu-GNOME, Ubuntu-MATE, Ubuntu-Studio,
@@ -9513,6 +9552,34 @@ ${c1}              __---''''''---__
 EOF
         ;;
 
+        "Minerva"*)
+            set_colors 15
+            read -rd '' ascii_data <<'EOF'
+${c1}     .........#########            
+   .....#####..........####  
+ ........#######...........##
+ .........#######............## 
+..#......########.............##
+..###############..............##
+..###############...............##
+#..#############.................##
+##...##########..................##
+##...............................##
+##...............................##
+##...............................##
+ ##.............................##
+  ##...........................##
+   ##.........................##
+    ##.......................##
+      ##...................##
+        ####...........####
+            ###########
+EOF
+        ;;
+
+
+
+
         "SharkLinux"*)
             set_colors 4 7
             read -rd '' ascii_data <<'EOF'