support uptime from Android 9+
This commit is contained in:
parent
cc78503b58
commit
78b9d3e160
1 changed files with 8 additions and 2 deletions
6
neofetch
6
neofetch
|
@ -1211,8 +1211,14 @@ get_uptime() {
|
||||||
# Get uptime in seconds.
|
# Get uptime in seconds.
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"Linux" | "Windows" | "MINIX")
|
"Linux" | "Windows" | "MINIX")
|
||||||
|
if [ -f /proc/uptime ]; then
|
||||||
seconds="$(< /proc/uptime)"
|
seconds="$(< /proc/uptime)"
|
||||||
seconds="${seconds/.*}"
|
seconds="${seconds/.*}"
|
||||||
|
else # Android >= 9 denies /proc/uptime access
|
||||||
|
boot=$(date -d"$(uptime -s)" +%s) \
|
||||||
|
&& now="$(date +%s)" \
|
||||||
|
&& seconds="$((now - boot))"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
"Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT")
|
"Mac OS X" | "iPhone OS" | "BSD" | "FreeMiNT")
|
||||||
|
|
Loading…
Reference in a new issue