mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 04:47:34 +00:00
Ports/neofetch: Use new global variables at /sys/kernel/ directory
This commit is contained in:
parent
a0ed543993
commit
78ca32d14c
1 changed files with 39 additions and 27 deletions
|
@ -1,16 +1,17 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: Linus Groh <mail@linusgroh.de>
|
From: Liav A <liavalb@gmail.com>
|
||||||
Date: Sat, 14 Aug 2021 13:33:46 -0400
|
Date: Tue, 25 Oct 2022 22:06:54 +0300
|
||||||
Subject: [PATCH] Add support for serenity
|
Subject: [PATCH] Add support for serenity
|
||||||
|
|
||||||
Co-Authored-By: Andreas Kling <kling@serenityos.org>
|
Co-Authored-By: Andreas Kling <kling@serenityos.org>
|
||||||
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
Co-Authored-By: Nico Weber <thakis@chromium.org>
|
||||||
|
Co-Authored-By: Linus Groh <mail@linusgroh.de>
|
||||||
---
|
---
|
||||||
neofetch | 121 +++++++++++++++++++++++++++++++++++++++++--------------
|
neofetch | 130 ++++++++++++++++++++++++++++++++++++++++++-------------
|
||||||
1 file changed, 90 insertions(+), 31 deletions(-)
|
1 file changed, 100 insertions(+), 30 deletions(-)
|
||||||
|
|
||||||
diff --git a/neofetch b/neofetch
|
diff --git a/neofetch b/neofetch
|
||||||
index 1e4b564..d2a12cd 100755
|
index 1e4b56462a08dd1ea27fcb21acc6da22f9b6a477..3c111b3207a2abd8107553d353dde9ba42f7bd82 100755
|
||||||
--- a/neofetch
|
--- a/neofetch
|
||||||
+++ b/neofetch
|
+++ b/neofetch
|
||||||
@@ -794,7 +794,7 @@ image_source="auto"
|
@@ -794,7 +794,7 @@ image_source="auto"
|
||||||
|
@ -50,7 +51,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
|
|
||||||
# Haiku uses 'uname -v' and not - 'uname -r'.
|
# Haiku uses 'uname -v' and not - 'uname -r'.
|
||||||
[[ $os == Haiku ]] && {
|
[[ $os == Haiku ]] && {
|
||||||
@@ -1377,17 +1382,17 @@ get_kernel() {
|
@@ -1377,11 +1382,11 @@ get_kernel() {
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Hide kernel info if it's identical to the distro info.
|
# Hide kernel info if it's identical to the distro info.
|
||||||
|
@ -67,14 +68,25 @@ index 1e4b564..d2a12cd 100755
|
||||||
}
|
}
|
||||||
|
|
||||||
get_uptime() {
|
get_uptime() {
|
||||||
# Get uptime in seconds.
|
@@ -1398,6 +1403,17 @@ get_uptime() {
|
||||||
case $os in
|
fi
|
||||||
- Linux|Windows|MINIX)
|
;;
|
||||||
+ Linux|Windows|MINIX|SerenityOS)
|
|
||||||
if [[ -r /proc/uptime ]]; then
|
+ SerenityOS)
|
||||||
s=$(< /proc/uptime)
|
+ if [[ -r /sys/kernel/uptime ]]; then
|
||||||
s=${s/.*}
|
+ s=$(< /sys/kernel/uptime)
|
||||||
@@ -1628,6 +1633,8 @@ get_shell() {
|
+ 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##*/} " ;;
|
off) shell="${SHELL##*/} " ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -83,7 +95,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
[[ $shell_version != on ]] && return
|
[[ $shell_version != on ]] && return
|
||||||
|
|
||||||
case ${shell_name:=${SHELL##*/}} in
|
case ${shell_name:=${SHELL##*/}} in
|
||||||
@@ -2096,13 +2103,13 @@ get_cpu() {
|
@@ -2096,13 +2114,13 @@ get_cpu() {
|
||||||
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
|
speed_dir="/sys/devices/system/cpu/cpu0/cpufreq"
|
||||||
|
|
||||||
# Select the right temperature file.
|
# Select the right temperature file.
|
||||||
|
@ -104,13 +116,13 @@ index 1e4b564..d2a12cd 100755
|
||||||
|
|
||||||
# Get CPU speed.
|
# Get CPU speed.
|
||||||
if [[ -d "$speed_dir" ]]; then
|
if [[ -d "$speed_dir" ]]; then
|
||||||
@@ -2268,6 +2275,13 @@ get_cpu() {
|
@@ -2268,6 +2286,13 @@ get_cpu() {
|
||||||
cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
|
cpu="$(awk -F':' '/CPU:/ {printf $2}' /kern/cpuinfo)"
|
||||||
speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
|
speed="$(awk -F '[:.M]' '/Clocking:/ {printf $2}' /kern/cpuinfo)"
|
||||||
;;
|
;;
|
||||||
+
|
+
|
||||||
+ "SerenityOS")
|
+ "SerenityOS")
|
||||||
+ cpu="$(jq -r '.[0].brandstr' /proc/cpuinfo)"
|
+ cpu="$(jq -r '.[0].brand' /sys/kernel/cpuinfo)"
|
||||||
+ # `cpu` will contain "@ [speed]GHz" and to be super correct we
|
+ # `cpu` will contain "@ [speed]GHz" and to be super correct we
|
||||||
+ # have to cut that off and store it in `speed` only for neofetch
|
+ # 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.
|
+ # to append it again later - but that's fine for now this way.
|
||||||
|
@ -118,12 +130,12 @@ index 1e4b564..d2a12cd 100755
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Remove un-needed patterns from cpu output.
|
# Remove un-needed patterns from cpu output.
|
||||||
@@ -2646,6 +2660,15 @@ get_memory() {
|
@@ -2646,6 +2671,15 @@ get_memory() {
|
||||||
mem_used="$((mem_used / 1024))"
|
mem_used="$((mem_used / 1024))"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
+ "SerenityOS")
|
+ "SerenityOS")
|
||||||
+ memstat="$(cat /proc/memstat)"
|
+ memstat="$(cat /sys/kernel/memstat)"
|
||||||
+ physical_allocated="$(echo $memstat | jq .physical_allocated)"
|
+ physical_allocated="$(echo $memstat | jq .physical_allocated)"
|
||||||
+ physical_available="$(echo $memstat | jq .physical_available)"
|
+ physical_available="$(echo $memstat | jq .physical_available)"
|
||||||
+ mem_used="$((physical_allocated * 4096 / 1024 / 1024))"
|
+ mem_used="$((physical_allocated * 4096 / 1024 / 1024))"
|
||||||
|
@ -134,7 +146,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
esac
|
esac
|
||||||
|
|
||||||
[[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
|
[[ "$memory_percent" == "on" ]] && ((mem_perc=mem_used * 100 / mem_total))
|
||||||
@@ -2980,6 +3003,13 @@ get_style() {
|
@@ -2980,6 +3014,13 @@ get_style() {
|
||||||
# Fix weird output when the function is run multiple times.
|
# Fix weird output when the function is run multiple times.
|
||||||
unset gtk2_theme gtk3_theme theme path
|
unset gtk2_theme gtk3_theme theme path
|
||||||
|
|
||||||
|
@ -148,7 +160,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
if [[ "$DISPLAY" && $os != "Mac OS X" && $os != "macOS" ]]; then
|
if [[ "$DISPLAY" && $os != "Mac OS X" && $os != "macOS" ]]; then
|
||||||
# Get DE if user has disabled the function.
|
# Get DE if user has disabled the function.
|
||||||
((de_run != 1)) && get_de
|
((de_run != 1)) && get_de
|
||||||
@@ -3130,8 +3160,7 @@ get_icons() {
|
@@ -3130,8 +3171,7 @@ get_icons() {
|
||||||
xfconf="/Net/IconThemeName"
|
xfconf="/Net/IconThemeName"
|
||||||
kde="Theme"
|
kde="Theme"
|
||||||
|
|
||||||
|
@ -158,7 +170,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
}
|
}
|
||||||
|
|
||||||
get_font() {
|
get_font() {
|
||||||
@@ -3158,6 +3187,8 @@ get_term() {
|
@@ -3158,6 +3198,8 @@ get_term() {
|
||||||
*) term="${TERM_PROGRAM/\.app}" ;;
|
*) term="${TERM_PROGRAM/\.app}" ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -167,7 +179,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
# Most likely TosWin2 on FreeMiNT - quick check
|
# Most likely TosWin2 on FreeMiNT - quick check
|
||||||
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && term="TosWin2"
|
[[ "$TERM" == "tw52" || "$TERM" == "tw100" ]] && term="TosWin2"
|
||||||
[[ "$SSH_CONNECTION" ]] && term="$SSH_TTY"
|
[[ "$SSH_CONNECTION" ]] && term="$SSH_TTY"
|
||||||
@@ -3722,10 +3753,10 @@ get_local_ip() {
|
@@ -3722,10 +3764,10 @@ get_local_ip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
get_public_ip() {
|
get_public_ip() {
|
||||||
|
@ -182,7 +194,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
|
|
||||||
if [[ -z "$public_ip" ]] && type -p drill >/dev/null; then
|
if [[ -z "$public_ip" ]] && type -p drill >/dev/null; then
|
||||||
public_ip="$(drill myip.opendns.com @resolver1.opendns.com | \
|
public_ip="$(drill myip.opendns.com @resolver1.opendns.com | \
|
||||||
@@ -3871,13 +3902,13 @@ image_backend() {
|
@@ -3871,13 +3913,13 @@ image_backend() {
|
||||||
}
|
}
|
||||||
|
|
||||||
print_ascii() {
|
print_ascii() {
|
||||||
|
@ -203,7 +215,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
|
|
||||||
# Set locale to get correct padding.
|
# Set locale to get correct padding.
|
||||||
LC_ALL="$sys_locale"
|
LC_ALL="$sys_locale"
|
||||||
@@ -4650,8 +4681,8 @@ term_padding() {
|
@@ -4650,8 +4692,8 @@ term_padding() {
|
||||||
padding=${xrdb/*internalBorder:}
|
padding=${xrdb/*internalBorder:}
|
||||||
padding=${padding/$'\n'*}
|
padding=${padding/$'\n'*}
|
||||||
|
|
||||||
|
@ -214,7 +226,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
@@ -4936,7 +4967,7 @@ ASCII:
|
@@ -4936,7 +4978,7 @@ ASCII:
|
||||||
Porteus, PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix,
|
Porteus, PostMarketOS, Proxmox, Puppy, PureOS, Qubes, Radix,
|
||||||
Raspbian, Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan,
|
Raspbian, Reborn_OS, Redstar, Redcore, Redhat, Refracted_Devuan,
|
||||||
Regata, Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific,
|
Regata, Rosa, sabotage, Sabayon, Sailfish, SalentOS, Scientific,
|
||||||
|
@ -223,7 +235,7 @@ index 1e4b564..d2a12cd 100755
|
||||||
SmartOS, Solus, Source_Mage, Sparky, Star, SteamOS, SunOS,
|
SmartOS, Solus, Source_Mage, Sparky, Star, SteamOS, SunOS,
|
||||||
openSUSE_Leap, openSUSE_Tumbleweed, openSUSE, SwagArch, Tails,
|
openSUSE_Leap, openSUSE_Tumbleweed, openSUSE, SwagArch, Tails,
|
||||||
Trisquel, Ubuntu-Budgie, Ubuntu-GNOME, Ubuntu-MATE, Ubuntu-Studio,
|
Trisquel, Ubuntu-Budgie, Ubuntu-GNOME, Ubuntu-MATE, Ubuntu-Studio,
|
||||||
@@ -9513,6 +9544,34 @@ ${c1} __---''''''---__
|
@@ -9513,6 +9555,34 @@ ${c1} __---''''''---__
|
||||||
EOF
|
EOF
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue