[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 01/07: Introduced define macros for /sys/ .. ACPI dirs and files; increased version for next releases
noreply at xfce.org
noreply at xfce.org
Mon Oct 22 23:22:35 CEST 2018
This is an automated email from the git hooks/post-receive script.
t i m y s t e r y p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository panel-plugins/xfce4-sensors-plugin.
commit b44822f06d23e7daf4c439170c35afeeef3140e1
Author: Fabian <timystery at arcor.de>
Date: Sun Oct 21 21:36:06 2018 +0200
Introduced define macros for /sys/ .. ACPI dirs and files; increased version for next releases
---
configure.ac.in | 4 ++--
include/acpi.h | 13 ++++++++++++-
lib/acpi.c | 18 +++++++++---------
3 files changed, 23 insertions(+), 12 deletions(-)
diff --git a/configure.ac.in b/configure.ac.in
index 741566b..c55591c 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -10,10 +10,10 @@ m4_define([libxfce4sensors_verinfo], [5:1:0])
m4_define([xfce4_sensors_version_major], [1])
m4_define([xfce4_sensors_version_minor], [3])
-m4_define([xfce4_sensors_version_micro], [1])
+m4_define([xfce4_sensors_version_micro], [90])
m4_define([xfce4_sensors_version_nano], [])
m4_define([xfce4_sensors_version_build], [@REVISION@])
-m4_define([xfce4_sensors_version_tag], [git]) dnl may be set to 'git'
+m4_define([xfce4_sensors_version_tag], []) dnl may be set to 'git'
m4_define([xfce4_sensors_version], [xfce4_sensors_version_major().xfce4_sensors_version_minor().xfce4_sensors_version_micro()ifelse(xfce4_sensors_version_nano(), [], [], [.xfce4_sensors_version_nano()])ifelse(xfce4_sensors_version_tag(), [git], [xfce4_sensors_version_tag()-xfce4_sensors_version_build()], [xfce4_sensors_version_tag()])])
diff --git a/include/acpi.h b/include/acpi.h
index a314911..ef4611c 100644
--- a/include/acpi.h
+++ b/include/acpi.h
@@ -30,9 +30,20 @@
#define ACPI_FILE_BATTERY_STATE "state"
#define ACPI_FILE_BATTERY_INFO "info"
#define ACPI_FILE_FAN "state"
-
#define ACPI_INFO "info"
+#define SYS_PATH "/sys/class/"
+#define SYS_POWER_MODEL_NAME "model_name"
+#define SYS_DIR_THERMAL "thermal"
+#define SYS_FILE_THERMAL "temp"
+#define SYS_DIR_POWER "power_supply"
+#define SYS_FILE_ENERGY "energy_now"
+#define SYS_FILE_ENERGY_MIN "alarm"
+#define SYS_FILE_ENERGY_MAX "energy_full"
+#define SYS_FILE_POWER "power_now"
+#define SYS_FILE_VOLTAGE "voltage_now"
+#define SYS_FILE_VOLTAGE_MIN "voltage_min_design"
+
/* Gtk/Glib includes */
#include <glib.h>
diff --git a/lib/acpi.c b/lib/acpi.c
index 6650494..9823e79 100644
--- a/lib/acpi.c
+++ b/lib/acpi.c
@@ -111,7 +111,7 @@ read_thermal_zone (t_chip *ptr_chip)
TRACE ("enters read_thermal_zone");
#ifdef HAVE_SYSFS_ACPI
- if ((chdir ("/sys/class/") == 0) && (chdir ("thermal/") == 0))
+ if ((chdir (SYS_PATH) == 0) && (chdir (SYS_DIR_THERMAL) == 0))
#else
if ((chdir (ACPI_PATH) == 0) && (chdir (ACPI_DIR_THERMAL) == 0))
#endif
@@ -128,7 +128,7 @@ read_thermal_zone (t_chip *ptr_chip)
continue;
#ifdef HAVE_SYSFS_ACPI
- str_filename = g_strdup_printf ("/sys/class/thermal/%s/temp", ptr_dirent->d_name);
+ str_filename = g_strdup_printf ("/%s/%s/%s/%s", SYS_PATH, SYS_DIR_THERMAL, ptr_dirent->d_name, SYS_FILE_THERMAL);
#else
str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH,
ACPI_DIR_THERMAL, ptr_dirent->d_name,
@@ -254,7 +254,7 @@ get_battery_zone_value (gchar *str_zone)
TRACE ("enters get_battery_zone_value for %s", str_zone);
#ifdef HAVE_SYSFS_ACPI
- str_filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", str_zone);
+ str_filename = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_POWER, str_zone, SYS_FILE_ENERGY);
#else
str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH, ACPI_DIR_BATTERY,
str_zone, ACPI_FILE_BATTERY_STATE);
@@ -309,7 +309,7 @@ read_battery_zone (t_chip *ptr_chip)
TRACE ("enters read_battery_zone");
#ifdef HAVE_SYSFS_ACPI
- if ((chdir ("/sys/class") == 0) && (chdir ("power_supply") == 0)) {
+ if ((chdir (SYS_PATH) == 0) && (chdir (SYS_DIR_POWER) == 0)) {
#else
if ((chdir (ACPI_PATH) == 0) && (chdir (ACPI_DIR_BATTERY) == 0)) {
#endif
@@ -321,7 +321,7 @@ read_battery_zone (t_chip *ptr_chip)
{ /* have a battery subdirectory */
#ifdef HAVE_SYSFS_ACPI
- str_filename = g_strdup_printf ("/sys/class/power_supply/%s/model_name", ptr_dirent->d_name);
+ str_filename = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_POWER, ptr_dirent->d_name, SYS_POWER_MODEL_NAME);
#else
str_filename = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH,
ACPI_DIR_BATTERY, ptr_dirent->d_name,
@@ -356,7 +356,7 @@ read_battery_zone (t_chip *ptr_chip)
fclose (ptr_file);
}
g_free (str_filename);
- str_filename = g_strdup_printf ("/sys/class/power_supply/%s/energy_now", ptr_dirent->d_name);
+ str_filename = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_POWER, ptr_dirent->d_name, SYS_FILE_ENERGY);
ptr_file = fopen (str_filename, "r");
if (ptr_file) {
@@ -369,7 +369,7 @@ read_battery_zone (t_chip *ptr_chip)
fclose (ptr_file);
}
g_free (str_filename);
- str_filename = g_strdup_printf ("/sys/class/power_supply/%s/alarm", ptr_dirent->d_name);
+ str_filename = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_POWER, ptr_dirent->d_name, SYS_FILE_ENERGY_MIN);
ptr_file = fopen (str_filename, "r");
if (ptr_file) {
if (fgets (buffer, 1024, ptr_file)!=NULL)
@@ -449,7 +449,7 @@ get_battery_max_value (gchar *str_filename, t_chipfeature *ptr_chipfeature)
TRACE ("enters get_battery_max_value");
#ifdef HAVE_SYSFS_ACPI
- str_pathtofile = g_strdup_printf ("/sys/class/power_supply/%s/energy_full", str_filename);
+ str_pathtofile = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_POWER, str_filename, SYS_FILE_ENERGY_MAX);
#else
str_pathtofile = g_strdup_printf ("%s/%s/%s/%s", ACPI_PATH,
ACPI_DIR_BATTERY, str_filename,
@@ -630,7 +630,7 @@ refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused)
switch (cf->class) {
case TEMPERATURE:
#ifdef HAVE_SYSFS_ACPI
- str_zone = g_strdup_printf ("/sys/class/thermal_zone/%s/temp", cf->devicename);
+ str_zone = g_strdup_printf ("%s/%s/%s/%s", SYS_PATH, SYS_DIR_THERMAL, cf->devicename, SYS_FILE_THERMAL);
ptr_file = fopen(str_zone, "r");
if (ptr_file)
{
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list