mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-11-08 06:00:08 +01:00
Uptime: support Windows
This commit is contained in:
+2
-23
@@ -1,34 +1,13 @@
|
||||
#include "fastfetch.h"
|
||||
#include "common/printing.h"
|
||||
|
||||
#if __APPLE__
|
||||
#include "time.h"
|
||||
#include "sys/sysctl.h"
|
||||
#endif
|
||||
#include "detection/uptime/uptime.h"
|
||||
|
||||
#define FF_UPTIME_MODULE_NAME "Uptime"
|
||||
#define FF_UPTIME_NUM_FORMAT_ARGS 4
|
||||
|
||||
void ffPrintUptime(FFinstance* instance)
|
||||
{
|
||||
uint64_t uptime;
|
||||
|
||||
#if FF_HAVE_SYSINFO_H
|
||||
uptime = (uint64_t) instance->state.sysinfo.uptime;
|
||||
#elif __APPLE__
|
||||
struct timeval bootTime;
|
||||
size_t bootTimeSize = sizeof(bootTime);
|
||||
if(sysctl(
|
||||
(int[]) {CTL_KERN, KERN_BOOTTIME}, 2,
|
||||
&bootTime, &bootTimeSize,
|
||||
NULL, 0
|
||||
) == 0)
|
||||
uptime = (uint64_t) difftime(time(NULL), bootTime.tv_sec);
|
||||
else
|
||||
uptime = 0;
|
||||
#else
|
||||
uptime = 0;
|
||||
#endif
|
||||
uint64_t uptime = ffDetectUptime(instance);
|
||||
|
||||
if(uptime == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user