uptime for Android 9+ (refactorized)
This commit is contained in:
parent
78b9d3e160
commit
c86413c18a
1 changed files with 5 additions and 5 deletions
10
neofetch
10
neofetch
|
@ -1211,13 +1211,13 @@ 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
|
if [[ -r /proc/uptime ]]; then
|
||||||
seconds="$(< /proc/uptime)"
|
seconds="$(< /proc/uptime)"
|
||||||
seconds="${seconds/.*}"
|
seconds="${seconds/.*}"
|
||||||
else # Android >= 9 denies /proc/uptime access
|
else
|
||||||
boot=$(date -d"$(uptime -s)" +%s) \
|
boot="$(date -d"$(uptime -s)" +%s)"
|
||||||
&& now="$(date +%s)" \
|
now="$(date +%s)"
|
||||||
&& seconds="$((now - boot))"
|
seconds="$((now - boot))"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue