summaryrefslogtreecommitdiff
path: root/Ports/neofetch/patches/add-serenity-support.patch
blob: b7b64b7c1fad74d475803f78dd2797b0c4bed2a7 (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
264
265
266
267
268
269
270
271
272
273
274
275
--- neofetch-7.0.0/neofetch	2020-04-27 15:12:00.884771680 +0100
+++ neofetch-7.0.0/neofetch	2020-04-27 20:10:22.265079042 +0100
@@ -775,7 +775,7 @@
 #       PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix, Raspbian,
 #       Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan, Regata,
 #       Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific, Septor,
-#       SharkLinux, Siduction, Slackware, SliTaz, SmartOS, Solus,
+#       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, Ubuntu,
@@ -923,6 +923,8 @@
             : Windows
         ;;
 
+        SerenityOS): SerenityOS ;;
+
         *)
             printf '%s\n' "Unknown OS detected: '$kernel_name', aborting..." >&2
             printf '%s\n' "Open an issue on GitHub to add support for your OS." >&2
@@ -1142,6 +1144,10 @@
         FreeMiNT)
             distro=FreeMiNT
         ;;
+
+        SerenityOS)
+            distro=SerenityOS
+        ;;
     esac
 
     distro=${distro//Enterprise Server}
@@ -1306,7 +1312,7 @@
 
 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 ]] && {
@@ -1327,17 +1333,17 @@
     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/.*}
@@ -1396,7 +1402,10 @@
 
     uptime=${d:+$d, }${h:+$h, }$m
     uptime=${uptime%', '}
-    uptime=${uptime:-$seconds secs}
+    # s/$seconds/$s
+    # Note: this was fixed upstream already but not released yet
+    # https://github.com/dylanaraps/neofetch/commit/e960c5168654211a8429e8089ba160e3cc89dc37
+    uptime=${uptime:-$s secs}
 
     # Make the output of uptime smaller.
     case $uptime_shorthand in
@@ -1577,6 +1586,8 @@
         off) shell="${SHELL##*/} " ;;
     esac
 
+    [[ $os == SerenityOS ]] && shell="SerenityOS Shell"
+
     [[ $shell_version != on ]] && return
 
     case ${shell_name:=${SHELL##*/}} in
@@ -2030,13 +2041,13 @@
             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
@@ -2201,6 +2212,17 @@
             cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
             speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
         ;;
+
+        "SerenityOS")
+            while IFS=":" read -r a b; do
+                case $a in
+                    "brandstr") cpu="${b//\"}" ;;
+                esac
+            done < /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.
@@ -2585,6 +2607,16 @@
             mem_used="$((mem_used / 1024))"
         ;;
 
+        "SerenityOS")
+            while IFS=":" read -d "," -r a b; do
+                case $a in
+                    "\"user_physical_allocated\"") mem_used="$((b * 4096 / 1024 / 1024))" ;;
+                    "\"user_physical_available\"") mem_free="$((b * 4096 / 1024 / 1024))" ;;
+                esac
+            done < /proc/memstat
+            mem_total="$((mem_used + mem_free))"
+        ;;
+
     esac
 
     [[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
@@ -3027,6 +3059,17 @@
             theme="${theme/ '[Plasma]'}"
         fi
     fi
+
+    if [[ "$os" == "SerenityOS" ]]; then
+        theme="Default"
+        # This will stop working if there's another "Name" key!
+        # We somehow need to check if the current section is "[Theme]".
+        while IFS="=" read -r a b; do
+            case $a in
+                $serenity) theme="${b}" ;;
+            esac
+        done < /etc/WindowServer/WindowServer.ini
+    fi
 }
 
 get_theme() {
@@ -3035,6 +3078,7 @@
     gconf="gtk_theme"
     xfconf="/Net/ThemeName"
     kde="Name"
+    serenity="Name"
 
     get_style
 }
@@ -3045,6 +3089,7 @@
     gconf="icon_theme"
     xfconf="/Net/IconThemeName"
     kde="Theme"
+    serenity=
 
     get_style
     icons="$theme"
@@ -3074,6 +3119,8 @@
         *)              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"
@@ -3637,10 +3684,10 @@
 }
 
 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 | \
@@ -3785,13 +3832,13 @@
 }
 
 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"
@@ -4549,8 +4596,8 @@
             padding=${xrdb/*internalBorder:}
             padding=${padding/$'\n'*}
 
-            [[ $padding =~ ^[0-9]+$ ]] ||
-                padding=
+            # [[ $padding =~ ^[0-9]+$ ]] ||
+            #     padding=
         ;;
     esac
 }
@@ -4834,7 +4881,7 @@
                                 PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix, Raspbian,
                                 Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan, Regata,
                                 Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific, Septor,
-                                SharkLinux, Siduction, Slackware, SliTaz, SmartOS, Solus,
+                                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, Ubuntu,
@@ -9097,6 +9144,34 @@
 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'