# uptm: just show system uptime 2024-02-10T14:32:16Z I find annoying to have current date, load averages, numbers or users next to system uptime in ''w'' or ''uptime''. So, I modified w.c to just print uptime. I find it handy in a status script for tmux or dwm. ``` /* modified w.c to only display uptime */ #include #include #define SECSPERHOUR (60 * 60) #define SECSPERDAY (24 * 60 * 60) int main(void) { struct timespec boottime; time_t uptime, now; int days, hrs, mins; time(&now); /* * Print how long system has been up. */ if (clock_gettime(CLOCK_BOOTTIME, &boottime) != -1) { uptime = boottime.tv_sec; if (uptime > 59) { uptime += 30; days = uptime / SECSPERDAY; uptime %= SECSPERDAY; hrs = uptime / SECSPERHOUR; uptime %= SECSPERHOUR; mins = uptime / 60; if (days > 0) (void)printf("%d day%s", days, days > 1 ? "s" : ""); if (hrs > 0 && mins > 0) (void)printf("%2d:%02d", hrs, mins); else { if (hrs > 0) (void)printf("%d hr%s", hrs, hrs > 1 ? "s" : ""); if (mins > 0 || (days == 0 && hrs == 0)) (void)printf("%d min%s", mins, mins != 1 ? "s" : ""); } } else printf("%d secs", (int)uptime); } return 0; } ``` --- Comments? => mailto:bla@bla.si3t.ch?subject=uptm-only-show-system-uptime Comments intructions => https://si3t.ch/log/_commentaires_.txt gemini://si3t.ch/log/2024-02-10-uptm-only-show-system-uptime.txt

-- Leo's gemini proxy

-- Connecting to si3t.ch:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/plain

-- Response ended

-- Page fetched on Fri May 17 08:22:56 2024