mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 14:10:11 +01:00
21 lines
442 B
C
21 lines
442 B
C
#include "uptime.h"
|
|
|
|
#include <time.h>
|
|
#include <sys/sysctl.h>
|
|
#include <sys/time.h>
|
|
|
|
uint64_t ffDetectUptime(const FFinstance* instance)
|
|
{
|
|
FF_UNUSED(instance)
|
|
struct timeval bootTime;
|
|
size_t bootTimeSize = sizeof(bootTime);
|
|
if(sysctl(
|
|
(int[]) {CTL_KERN, KERN_BOOTTIME}, 2,
|
|
&bootTime, &bootTimeSize,
|
|
NULL, 0
|
|
) == 0)
|
|
return (uint64_t) difftime(time(NULL), bootTime.tv_sec);
|
|
|
|
return 0;
|
|
}
|