summaryrefslogtreecommitdiff
path: root/Ports/neofetch/patches/0001-Add-support-for-serenity.patch
blob: e32f9beaa6b957509410d1c9df822716681b8de0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
From 155fe5493eafc3a435136ce429052bcc4440d8c6 Mon Sep 17 00:00:00 2001
From: Linus Groh <mail@linusgroh.de>
Date: Sat, 14 Aug 2021 13:33:46 -0400
Subject: [PATCH] Add support for serenity

Co-Authored-By: Andreas Kling <kling@serenityos.org>
Co-Authored-By: Nico Weber <thakis@chromium.org>
---
 neofetch | 121 +++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 90 insertions(+), 31 deletions(-)

diff --git a/neofetch b/neofetch
index 1e4b564..ea5e351 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, SerenityOS, 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 ;;
+        SerenityOS) os=SerenityOS ;;
 
         Linux|GNU*)
             os=Linux
@@ -1185,6 +1186,10 @@ get_distro() {
         FreeMiNT)
             distro=FreeMiNT
         ;;
+
+        SerenityOS)
+            distro=SerenityOS
+        ;;
     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,17 +1382,17 @@ 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() {
     # Get uptime in seconds.
     case $os in
-        Linux|Windows|MINIX)
+        Linux|Windows|MINIX|SerenityOS)
             if [[ -r /proc/uptime ]]; then
                 s=$(< /proc/uptime)
                 s=${s/.*}
@@ -1628,6 +1633,8 @@ get_shell() {
         off) shell="${SHELL##*/} " ;;
     esac
 
+    [[ "$os" == SerenityOS ]] && shell="SerenityOS Shell "
+
     [[ $shell_version != on ]] && return
 
     case ${shell_name:=${SHELL##*/}} in
@@ -2096,13 +2103,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 +2275,13 @@ get_cpu() {
             cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
             speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
         ;;
+
+        "SerenityOS")
+            cpu="$(jq -r '.[0].brandstr' /proc/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 +2660,15 @@ get_memory() {
             mem_used="$((mem_used / 1024))"
         ;;
 
+        "SerenityOS")
+            memstat="$(cat /proc/memstat)"
+            user_physical_allocated="$(echo $memstat | jq .user_physical_allocated)"
+            user_physical_available="$(echo $memstat | jq .user_physical_available)"
+            mem_used="$((user_physical_allocated * 4096 / 1024 / 1024))"
+            mem_free="$((user_physical_available * 4096 / 1024 / 1024))"
+            mem_total="$((mem_used + mem_free))"
+        ;;
+
     esac
 
     [[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
@@ -2980,6 +3003,13 @@ get_style() {
     # Fix weird output when the function is run multiple times.
     unset gtk2_theme gtk3_theme theme path
 
+    if [[ "$os" == "SerenityOS" ]]; 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 +3160,7 @@ get_icons() {
     xfconf="/Net/IconThemeName"
     kde="Theme"
 
-    get_style
-    icons="$theme"
+    icons=
 }
 
 get_font() {
@@ -3158,6 +3187,8 @@ get_term() {
         *)              term="${TERM_PROGRAM/\.app}" ;;
     esac
 
+    [[ "$os" == SerenityOS ]] && term="SerenityOS Terminal"
+
     # Most likely TosWin2 on FreeMiNT - quick check
     [[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && term="TosWin2"
     [[ "$SSH_CONNECTION" ]] && term="$SSH_TTY"
@@ -3722,10 +3753,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 +3902,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 +4681,8 @@ term_padding() {
             padding=${xrdb/*internalBorder:}
             padding=${padding/$'\n'*}
 
-            [[ $padding =~ ^[0-9]+$ ]] ||
-                padding=
+            # [[ $padding =~ ^[0-9]+$ ]] ||
+            #     padding=
         ;;
     esac
 }
@@ -4936,7 +4967,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, SerenityOS, 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 +9544,34 @@ ${c1}              __---''''''---__
 EOF
         ;;
 
+        "SerenityOS"*)
+            set_colors 3 1 7 8 15
+            read -rd '' ascii_data <<'EOF'
+${c4}    _         __       
+  / o \    ,^ _ `\
+  \./ ]   |  /*  /
+${c5}    - *~ .#_ ${c4}`--`
+${c5}  ,`   '    "w
+${c5} ]`   /      ]${c4}Kp
+${c5} B  'M   %m  ]${c4}KK
+ K${c5}p   \      #${c4}KKH
+ KK${c5}N,,,w,__,#${c4}KKK
+ `KKK${c2}\KKKKK${c4}KKK${c3}KK${c4}${c2}KNw${c4}
+   #R${c3}K${c4}K${c3}\KK${c4}gKKKH${c3}L5${c4}${c2}KK${c4}K
+  ]K${c3}|a${c4}#KKKKKBKNp${c3}LI${c4}${c2}K${c4}KN
+ .K${c3}K${c4}KDKBKBBKKKKKKN${c3}]${c4}${c2}KK${c4}
+${c2} ]K${c3}IMK${c4}KBKKKKKKKK${c3}RMI${c4}${c2}KKH${c4}
+${c2} ]K${c3}I${c4}#KkBBBBBBKKKKN${c3}I${c4}${c2}KK${c4}
+${c2} ]K${c3}[K${c4}KKBKKKKKKKKM${c3}*]${c4}KK
+ `KN${c3}|1${c4}KKKKKKKBKM${c3}`L${c4}KKM
+  `KN${c3},|]${c4}KKKKK${c3}/|L;${c4}${c2}#${c4}KK
+    `--KKK KK${c2}KKKKK${c4}
+    aaNKKKaKK  ${c2}`${c4}
+    KKKKKKKKM
+        ````
+EOF
+        ;;
+
         "SharkLinux"*)
             set_colors 4 7
             read -rd '' ascii_data <<'EOF'
-- 
2.36.1