watcher: wip

This commit is contained in:
Alastair Poole 2021-05-16 12:12:19 +01:00
parent 58a039a820
commit 3138afa782
7 changed files with 86 additions and 0 deletions

16
src/bin/evisum_system.h Normal file
View File

@ -0,0 +1,16 @@
#ifndef EVISUM_SYSTEM_H
#define EVISUM_SYSTEM_H
typedef struct _Evisum_System
{
struct
{
int count;
Eina_List *cores;
int freq_min, freq_max;
int temp_min, temp_max;
} cpu;
} Evisum_System;
#endif

42
src/bin/evisum_watcher.c Normal file
View File

@ -0,0 +1,42 @@
#include <Eina.h>
#include <Ecore.h>
#include "next/machine.h"
static Eina_Thread *background_thread = NULL;
static Eina_List *cores = NULL;
static Eina_List *batteries = NULL;
static Eina_List *sensors = NULL;
static Eina_List *network_interfaces = NULL;
#define SECOND 1000000
#define INTERVAL 16
#define SLEEP_DURATION SECOND / INTERVAL
#define CHECK_EVERY_SECOND(n) ((!n) || (!(n % INTERVAL)))
static void
_cb_background_thread(void *data EINA_UNUSED, Ecore_Thread *thread)
{
int64_t poll_count = 0;
while (!ecore_thread_check(thread))
{
if (CHECK_EVERY_SECOND(poll_count)) {}
usleep(SLEEP_DURATION);
poll_count++;
}
}
int
main(int argc, char **argv)
{
ecore_init();
background_thread = ecore_thread_run(_cb_background_thread, NULL, NULL, NULL);
ecore_main_loop_begin();
ecore_shutdown();
return 0;
}

6
src/bin/evisum_watcher.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef EVISUM_WATCHER_H
#define EVISUM_WATCHER_H
#endif

View File

@ -20,6 +20,18 @@ executable('evisum', src,
gui_app : true,
install : true)
src_watch = files([
'evisum_watcher.c',
'evisum_watcher.h',
])
executable('evisum_watcher', src_watch,
include_directories : inc,
dependencies : [ deps, deps_os, deps_nls ],
gui_app : false,
install : true)
if host_os == 'freebsd' or host_os == 'dragonfly'
meson.add_install_script('perms.sh')
endif

1
src/bin/next/machine.c Normal file
View File

@ -0,0 +1 @@
#include "machine.h"

5
src/bin/next/machine.h Normal file
View File

@ -0,0 +1,5 @@
#ifndef MACHINE_H
#define MACHINE_H
#endif

4
src/bin/next/meson.build Normal file
View File

@ -0,0 +1,4 @@
src += files([
'machine.c',
'machine.h',
])