Comments (7)
Upon merge of PR #20 this issue is fixed
from sysfetch.
Confirmed fixed by pull request #20 and working (tested in place). Thanks!
from sysfetch.
commit 9eeaba1 changes if statement to read for uptime --pretty command instead. Thank you for the great work!
from sysfetch.
commit 9eeeaba1 reverted the fix - command -v uptime --pretty
does not successfully verify support for --pretty on busybox. So far the only thing I've found that clearly works is testing whether calling the command in question symlinks back to /bin/busybox.
from sysfetch.
I reopened the issue. Hoping we can find a way to print 'uptime' on busybox without path refrence to os
from sysfetch.
Got it. One option, since there seem to have been other small systems that don't have the full version of uptime --pretty
would be to just pull the raw uptime value (first field in /proc/uptime) and reformat it ourselves. That method is guaranteed to work the same on every Linux based system I've ever seen myself, and it's actually easier to process that value (which is just uptime in raw seconds) than trying to strip it out of the output of any of the uptime commands. Should only take a dozen lines of code, I don't have fetch handy to work directly but here is a code snippet you can use to extract, then format however you'd like:
#!/bin/bash
# Get raw seconds value
RAWSEC=$(cat /proc/uptime | awk '{print $1}')
# Cut off decimal
RAWSEC=${RAWSEC%\.*}
echo $RAWSEC
# Extract weeks
WEEKS=$((RAWSEC/604800))
REMSEC=$((RAWSEC%604800))
echo "$WEEKS weeks and $REMSEC seconds"
# Extract days
DAYS=$((REMSEC/86400))
REMSEC=$((REMSEC%86400))
echo "$WEEKS weeks, $DAYS days and $REMSEC seconds"
# Extract hours
HOURS=$((REMSEC/3600))
REMSEC=$((REMSEC%3600))
echo "$WEEKS weeks, $DAYS days, $HOURS hours and $REMSEC seconds"
# Extract minutes
MINUTES=$((REMSEC/60))
REMSEC=$((REMSEC%60))
echo "$WEEKS weeks, $DAYS days, $HOURS hours, $MINUTES min and $REMSEC seconds"
# format it however you like
echo "Compare to output of uptime --pretty:"
uptime --pretty
That produces the following terminal output:
chuck@vapor:~/code$ ./uptime.sh
5972231
9 weeks and 529031 seconds
9 weeks, 6 days and 10631 seconds
9 weeks, 6 days, 2 hours and 3431 seconds
9 weeks, 6 days, 2 hours, 57 min and 11 seconds
Compare to output of uptime --pretty:
up 9 weeks, 6 days, 2 hours, 57 minutes
Once you strip out my comments, you can use that to extract a time pattern that works on any system, even the tiny ones like Alpine and OpenWRT, no doubts.
from sysfetch.
Check out commit de093b4
from sysfetch.
Related Issues (20)
- DE/WM themes not working again HOT 2
- Current Build: Theme category not showing: HOT 17
- de/wm not detected correctly (xsessions) HOT 8
- Uptime display supposed to be like this?: HOT 3
- Add support for Windows and Mac HOT 13
- CPU Frequency issue under WSL2: HOT 3
- KDE / KRunner / Latte Dock `term` Value
- Wrong values for TERM and WM HOT 16
- syntax error: invalid arithmetic operator HOT 1
- lsblk: /dev/nvme0n1p: not a block device HOT 30
- Errors on Qemu HOT 4
- Arch WSL2 output very slim HOT 2
- Errors on Android via Termux HOT 4
- Not able to access drive and exiting on Alpine HOT 2
- No output on Fedora VM HOT 4
- Slim output on MINGW Windows HOT 1
- Verbose option HOT 5
- Several ascii art missing HOT 1
- Suggestion: rename sysfetch to sysfetch.sh HOT 1
- ASCII art not working.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sysfetch.