commit - a55e0e43a86b71548e22a041b2441ed4d485db7b
commit + 3726d3ccf1e70c2d368684178c12bbd4636842df
blob - fbd7a7db49aa24ed39154b9e5d39d526da1e848c
blob + 15618524e6bf84d52c325faf94753adeec699edb
--- include/statbar.h
+++ include/statbar.h
#define BATTLOW "\uf243"
#define BATTAC "\uf492"
#define UNKNOWN "\ueb32"
-#define CPUTEMP "\uf4bc"
-#define FANSPEED "\uefa7"
#define WIFI "\uf1eb"
#define ETHERNET "\uef09"
-extern void close_display(void);
-
/* FS */
extern void read_config(void);
extern int open_command_interface(void);
extern pid_t start_volume_process(int *pipe_fd);
-/* CPU Temp */
-extern char cputemp_string[14];
-
-extern void get_cputemp(void);
-
-/* Fan Speed */
-extern char fanspeed_string[16];
-
-extern void get_fanspeed(void);
-
/* Mail */
extern char mail_string[7];
blob - a539d6cd091520c896d42d7b677c2a7435711c2f
blob + 4122a3ed28669554cdf43f33d621d9c7358a2f56
--- modules/Makefile
+++ modules/Makefile
LIB= statbar_modules
-SRCS= clock.c battery.c volume.c cputemp.c fanspeed.c mail.c network.c
+SRCS= clock.c battery.c volume.c mail.c network.c
MAN=
CFLAGS += -I../include -I/usr/local/include
blob - 1508f3c320ebade48d9adb42f878652334876862 (mode 644)
blob + /dev/null
--- modules/cputemp.c
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/sensors.h>
-
-#include "statbar.h"
-
-char cputemp_string[14];
-
-void
-get_cputemp(void)
-{
- int mib[5];
- struct sensor s;
- size_t s_len = sizeof(struct sensor);
- long temp_c = 0;
-
- mib[0] = CTL_HW;
- mib[1] = HW_SENSORS;
- mib[2] = 0; /* This should be discovered dynamically rather than hardcoded */
- mib[3] = SENSOR_TEMP;
- mib[4] = 0;
-
- if (sysctl(mib, 5, &s, &s_len, NULL, 0) == -1)
- perror("sysctl");
- else
- temp_c = (s.value - 273150000) / 1000000;
-
- (void)snprintf(cputemp_string, 14, "%s %3ld°C", CPUTEMP, temp_c);
-}
-
blob - f73fe2ffbb5ec2fcbe321530dfbe5bcfba150923 (mode 644)
blob + /dev/null
--- modules/fanspeed.c
+++ /dev/null
-#include <stdio.h>
-#include <string.h>
-
-#include <sys/sysctl.h>
-#include <sys/time.h>
-#include <sys/sensors.h>
-
-#include "statbar.h"
-char fanspeed_string[16];
-
-void
-get_fanspeed(void)
-{
- int mib[5];
- struct sensor s;
- size_t s_len = sizeof(struct sensor);
- int rpm = -1;
-
- mib[0] = CTL_HW;
- mib[1] = HW_SENSORS;
- mib[2] = 7; /* This should be discovered dynamically rather than hardcoded */
- mib[3] = SENSOR_FANRPM;
- mib[4] = 0;
-
- if (sysctl(mib, 5, &s, &s_len, NULL, 0) == -1)
- perror("sysctl");
- else
- rpm = s.value;
-
- (void)snprintf(fanspeed_string, 16, "%s %5d RPM", FANSPEED, rpm);
-}
-
blob - cde058e7605074a5c1d529255557f1e196ff03b3
blob + 2859a99ccb6eb86e9d8dbc839025bbb806b0cde4
--- src/fs.c
+++ src/fs.c
read_config(void)
{
char *config_full_path;
- time_t clock_ms;
- time_t battery_ms;
- time_t cputemp_ms;
- char **weather_location;
char **mail_ptr;
uid_t uid;
struct passwd *pw;
blob - 990ebf176a7a2f3d80a0cba669c559a1de3d6f7c
blob + c5459bffd2095a91b09ebb586437be58b169a07e
--- src/main.c
+++ src/main.c
enum clocks_e
{
CLOCK_CLOCK,
- CPUTEMP_CLOCK,
- FANSPEED_CLOCK,
CLOCKS_COUNT
};
struct timespec next_interval;
struct timespec clock_interval = { .tv_sec = 60 };
struct timespec battery_interval = { .tv_sec = 10 };
- struct timespec cputemp_interval = { .tv_sec = 2 };
- struct timespec fanspeed_interval = { .tv_sec = 3 };
struct pollfd pfd[NFDS];
struct pollfd *cmd_pfd = &pfd[0];
struct pollfd *batt_pfd = &pfd[1];
read_config();
(void)clock_gettime(CLOCK_BOOTTIME, &now);
normalize_clock_interval(&now, &clocks[CLOCK_CLOCK]);
- timespecadd(&now, &cputemp_interval, &clocks[CPUTEMP_CLOCK]);
- timespecadd(&now, &fanspeed_interval, &clocks[FANSPEED_CLOCK]);
get_clock();
batt_pid = start_privileged_battery_process(&batt_fd, &battery_interval);
vol_pid = start_volume_process(&vol_fd);
network_pid = start_network_process(&network_fd);
- get_cputemp();
- get_fanspeed();
cmd_pfd->fd = open_command_interface();
cmd_pfd->events = POLLIN;
(void)kill(batt_pid, SIGUSR1);
}
- /* CPU Temp */
- if (timespeccmp(&now, &clocks[CPUTEMP_CLOCK], >=))
- {
- get_cputemp();
- dirty = true;
- while (timespeccmp(&now, &clocks[CPUTEMP_CLOCK], >=))
- timespecadd(&clocks[CPUTEMP_CLOCK], &cputemp_interval, &clocks[CPUTEMP_CLOCK]);
- }
-
- /* Fan Speed */
- if (timespeccmp(&now, &clocks[FANSPEED_CLOCK], >=))
- {
- get_fanspeed();
- dirty = true;
- while (timespeccmp(&now, &clocks[FANSPEED_CLOCK], >=))
- timespecadd(&clocks[FANSPEED_CLOCK], &fanspeed_interval, &clocks[FANSPEED_CLOCK]);
- }
-
if (dirty)
{
- (void)dprintf(output_fd, "%s | %s | %s | %s | %s | %s%s\n",
+ (void)dprintf(output_fd, "%s | %s | %s | %s%s\n",
clock_string,
battery_string,
volume_string,
- cputemp_string,
- fanspeed_string,
network_string,
mail_string);
dirty = false;