Home Forums Wiki Doc Install Extras Screenshots Source Code Projects Blog Users Groups Register
Glx-Dock / Cairo-Dock List of forums Applets | Applets PowerManager
The latest stable release is the *3.4.0* : How to install it here.
Note: We just switched from BZR to Git on Github! (only to host the code and your future pull requests)
Applets | Applets

Subjects Author Language Messages Last message
[Locked] PowerManager
Page : 1 2 3 ...14 15 16 17 18
necropotame Français 348 lylambda [Read]
01 March 2010 à 13:43

Gege, Wednesday 28 May 2008 à 22:08


Subscription date : 03 February 2008
Messages : 361
j'ai refais un petit ddd.
Le backtrace est le meme que celui plus haut.
Je poste le rapport pour la ligne "get_stats" du backtrace:

#include <string.h>
#include <dirent.h>
#include <dbus/dbus-glib.h>

#include "powermanager-draw.h"
#include "powermanager-struct.h"
#include "powermanager-dbus.h"

#define MY_BATTERY_DIR "/proc/acpi/battery"
#define MY_DEFAULT_BATTERY_NAME "BAT0"

static DBusGProxy *dbus_proxy_power = NULL;
static DBusGProxy *dbus_proxy_stats = NULL;
static DBusGProxy *dbus_proxy_battery = NULL;

CD_APPLET_INCLUDE_MY_VARS

static gchar* power_battery_name(void) {
GError *erreur = NULL;
GDir *dir = g_dir_open (MY_BATTERY_DIR, 0, &erreur);
if (erreur != NULL)
{
cd_warning ("Attention : %s", erreur->message);
g_error_free (erreur);
return MY_DEFAULT_BATTERY_NAME;
}

GString *sBatteryStateFilePath = g_string_new ("");
gchar *cContent = NULL, *cPresentLine;
gsize length=0;
const gchar *cBatteryName;
gchar *cBatteryFound = NULL;
do
{
cBatteryName = g_dir_read_name (dir);
if (cBatteryName == NULL)
break ;

g_string_printf (sBatteryStateFilePath, "%s/%s/state", MY_BATTERY_DIR, cBatteryName);
length=0;
cd_debug (" examen de la batterie '%s' ...", sBatteryStateFilePath->str);
g_file_get_contents(sBatteryStateFilePath->str, &cContent, &length, &erreur);
if (erreur != NULL)
{
cd_warning("Attention : %s", erreur->message);
g_error_free(erreur);
erreur = NULL;
}
else // on cherche la ligne "present: yes"
{
cPresentLine = g_strstr_len (cContent, -1, "present");
cd_debug (" -> %s", cPresentLine);
if (cPresentLine != NULL)
{
cPresentLine += 7;
gchar *str = strchr (cPresentLine, '\n'); // on garde que cette ligne.
if (str != NULL)
*str = '\0';
if (g_strstr_len (cContent, -1, "yes") != NULL) // on l'a trouvee !
{
cBatteryFound = g_strdup (cBatteryName);
break;
}
}
}
g_free (cContent);
}
while (1);
g_dir_close (dir);
return cBatteryFound;
}

gboolean dbus_connect_to_bus (void)
{
cd_message ("");

if (cairo_dock_bdus_is_enabled ())
{
dbus_proxy_power = cairo_dock_create_new_session_proxy (
"org.freedesktop.PowerManagement",
"/org/freedesktop/PowerManagement",
"org.freedesktop.PowerManagement"
);

dbus_proxy_stats = cairo_dock_create_new_session_proxy (
"org.freedesktop.PowerManagement",
"/org/freedesktop/PowerManagement/Statistics",
"org.freedesktop.PowerManagement.Statistics"
);

dbus_g_proxy_add_signal(dbus_proxy_power, "OnBatteryChanged",
G_TYPE_BOOLEAN,
G_TYPE_INVALID);

dbus_g_proxy_connect_signal(dbus_proxy_power, "OnBatteryChanged",
G_CALLBACK(on_battery_changed), NULL, NULL);

gchar *cBatteryName = power_battery_name();
if (cBatteryName == NULL) // on n'a pas trouve de batterie nous-meme.
{
cBatteryName = MY_DEFAULT_BATTERY_NAME; // utile ? si on a rien trouve, c'est surement qu'il n'y a pas de batterie non ?
cd_warning ("No battery were found, trying with default one : %s", cBatteryName);
detect_battery ();
}
else
{
cd_message ("Battery Name : %s", cBatteryName);
gchar *batteryPath = g_strdup_printf ("/org/freedesktop/Hal/devices/acpi_%s", power_battery_name());
cd_debug (" batteryPath : %s", batteryPath);
dbus_proxy_battery = cairo_dock_create_new_system_proxy (
"org.freedesktop.Hal",
batteryPath,
"org.freedesktop.Hal.Device"
);
cd_debug (" acquisition de la batterie -> %x", dbus_proxy_battery);
myData.battery_present = (dbus_proxy_battery != NULL); // a priori toujours vrai.
g_free (batteryPath);
g_free (cBatteryName);
}

return TRUE;
}
return FALSE;
}

void dbus_disconnect_from_bus (void)
{
cd_message ("");
if (dbus_proxy_power != NULL)
{
dbus_g_proxy_disconnect_signal(dbus_proxy_power, "OnBatteryChanged",
G_CALLBACK(on_battery_changed), NULL);
cd_message ("OnBatteryChanged deconnecte");
g_object_unref (dbus_proxy_power);
dbus_proxy_power = NULL;
}
if (dbus_proxy_battery != NULL)
{
g_object_unref (dbus_proxy_battery);
dbus_proxy_battery = NULL;
}
if (dbus_proxy_stats != NULL)
{
g_object_unref (dbus_proxy_stats);
dbus_proxy_stats = NULL;
}
}

gboolean get_on_battery(void)
{
dbus_g_proxy_call (dbus_proxy_power, "GetOnBattery", NULL,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &myData.on_battery,
G_TYPE_INVALID);
}

void on_battery_changed(DBusGProxy *proxy, gboolean onBattery, gpointer data)
{
myData.on_battery = onBattery;

update_stats();
update_icon();
}

gboolean update_stats(void)
{
if(myData.battery_present)
{
get_on_battery();
myData.battery_charge = get_stats("charge");
myData.battery_time = get_stats("time");
cd_debug ("PowerManager [On Battery]: %d", myData.on_battery);
update_icon();
}
/*present: yes
capacity state: ok
charging state: discharging
present rate: 15000 mW
remaining capacity: 47040 mWh
present voltage: 15000 mV*/
return TRUE;
}

int get_stats(gchar *dataType)
{
GValueArray *gva;
GValue *gv;
GPtrArray *ptrarray = NULL;
GType g_type_ptrarray;
int i;
int x, y, col; /// mettre des nom comprehensibles...

g_type_ptrarray = dbus_g_type_get_collection ("GPtrArray",
dbus_g_type_get_struct("GValueArray",
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INVALID));

dbus_g_proxy_call (dbus_proxy_stats, "GetData", NULL,
G_TYPE_STRING, dataType,
G_TYPE_INVALID,
g_type_ptrarray, &ptrarray,
G_TYPE_INVALID);

for (i=0; i< ptrarray->len; i++) /// il semble que seule la derniere valeur ait de l'interet ....
{
gva = (GValueArray *) g_ptr_array_index (ptrarray, i);
gv = g_value_array_get_nth (gva, 0);
x = g_value_get_int (gv);
g_value_unset (gv);
gv = g_value_array_get_nth (gva, 1);
y = g_value_get_int (gv);
g_value_unset (gv);
gv = g_value_array_get_nth (gva, 2);
col = g_value_get_int (gv);
g_value_unset (gv);
g_value_array_free (gva);
}
g_ptr_array_free (ptrarray, TRUE);

cd_debug ("PowerManager [%s]: %d", dataType, y);
return y; /// a quoi servent x et col alors ??
}

void detect_battery(void)
{
if (dbus_proxy_battery != NULL)
dbus_g_proxy_call (dbus_proxy_battery, "GetPropertyBoolean", NULL,
G_TYPE_STRING,"battery.present",
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &myData.battery_present,
G_TYPE_INVALID);
}

void power_halt(void)
{
dbus_g_proxy_call (dbus_proxy_power, "Shutdown", NULL,
G_TYPE_INVALID,
G_TYPE_INVALID);
}
void power_hibernate(void)
{
dbus_g_proxy_call (dbus_proxy_power, "Hibernate", NULL,
G_TYPE_INVALID,
G_TYPE_INVALID);
}
void power_suspend(void)
{
dbus_g_proxy_call (dbus_proxy_power, "Suspend", NULL,
G_TYPE_INVALID,
G_TYPE_INVALID);
}
void power_reboot(void)
{
dbus_g_proxy_call (dbus_proxy_power, "Reboot", NULL,
G_TYPE_INVALID,
G_TYPE_INVALID);
}


S'il en faut une autre...

fabounet, Thursday 29 May 2008 à 03:51


Subscription date : 30 November 2007
Messages : 17118
sauf que ligne 206 il n'y a rien
il faudrait que tu cliques sur "get_stats" dans le backtrace, il te placera dans le fichier et tu pourras même avoir les valeurs des différents paramètres au moment du bug.

Gege, Thursday 29 May 2008 à 18:01


Subscription date : 03 February 2008
Messages : 361
Tu as modifié quelque chose aujourd'hui ? Depuis la MAJ il y a une heure pour moi, ca ne plante plus.

Le probleme est maintenant que l'applet m'affiche une batterie vide, et 0min/0% de charge... (Je prie pour que ce ne soit pas la faute de kde )

Mav, Thursday 29 May 2008 à 18:18


Subscription date : 29 November 2007
Messages : 3146
Bizarre chez moi il passe nikel
Question bête : KDE a DBUS ou pas ?

Gege, Thursday 29 May 2008 à 18:24


Subscription date : 03 February 2008
Messages : 361
oui kde a dbus

fabounet, Thursday 29 May 2008 à 18:47


Subscription date : 30 November 2007
Messages : 17118
il a DBus mais est-ce qu'il l'utilise pour mettre à jour les infos de la batterie ? d'ailleurs qui fait ça, ce serait pas gnome-power-manager par hasard ?

Gege, Thursday 29 May 2008 à 19:14


Subscription date : 03 February 2008
Messages : 361
j'ai recherché et apparement ce n'est pas dbus qui s'occupe de ca dans kde. Y'a pas moyen que l'applet cherche lui meme quel utilitaire s'occupe de la batterie ?

nochka85, Thursday 29 May 2008 à 19:37


Subscription date : 29 November 2007
Messages : 7408
EXCELLENT l'integration des "décorations" dans Rhythmbox !

-> Par contre, va falloir que je retouche un tout petit peu le theme CD Box pour y faire appaître le "rond de fixation" central lorsqu'il n'y a pas de jaquette ou que rhythmbox n'est pas utilisé -> Je m'occupe de çà ce soir

Gege, Thursday 29 May 2008 à 19:38


Subscription date : 03 February 2008
Messages : 361
EXCELLENT l'integration des "décorations" dans Rhythmbox !




Ca me rassure je suis pas le seul a me planter de topic parfois

nochka85, Thursday 29 May 2008 à 19:54


Subscription date : 29 November 2007
Messages : 7408
OUPS !!!!! ....... -> Bon, quand vous lirez ceci , imaginez que vous êtes dans le topis de l'applet Rhythmbox

PS: Bon, je ne ré-écris pas dans Rhythmbox -> De toute façon, VOUS êtes censés TOUT lire !

fabounet, Friday 30 May 2008 à 02:55


Subscription date : 30 November 2007
Messages : 17118
Gege : le problème c'est que je sais même pas quel programme envoie ces données sur le DBus, et même si je le savais pour Gnome et KDE, rien ne dit qu'ils utilisent les mêmes messages. Bref il faudrait avoir une doc pour KDE4.

ChAnGFu, Sunday 15 June 2008 à 16:59


Subscription date : 17 January 2008
Messages : 1526
J'ai rajouté le support des alertes sonores pour les étourdis comme moi qui ne voit pas les info-bulles.
Bien sur il est désactivé par défaut pour ne pas gêner ceux qui apprécie le silence

fabounet, Monday 16 June 2008 à 02:55


Subscription date : 30 November 2007
Messages : 17118
c'est bien ça
au fait tu sais si dans les fichiers batterie de /proc y'a la charge totale ? j'ai trouvé la charge restante, mais pas le total (utile pour la jauge)
l'idée étant de se passer de DBus qui a pas l'air de faire son boulot chez tout le monde pareil.
au fait (bis) t'as pu trouver la fuite mémoire ?

ChAnGFu, Monday 16 June 2008 à 03:47


Subscription date : 17 January 2008
Messages : 1526
Tien voici toutes les infos nécessaires:
[changfu@changfu-laptop:~$] cat /proc/acpi/battery/BAT0/state
present: yes
capacity state: ok
charging state: charging
present rate: 1 mA
remaining capacity: 4547 mAh
present voltage: 12449 mV
[changfu@changfu-laptop:~$] cat /proc/acpi/battery/BAT0/info
present: yes
design capacity: 5200 mAh
last full capacity: 4685 mAh
battery technology: rechargeable
design voltage: 11100 mV
design capacity warning: 520 mAh
design capacity low: 157 mAh
capacity granularity 1: 52 mAh
capacity granularity 2: 52 mAh
model number: DELL XT8168
serial number: 1455
battery type: LION
OEM info: Sanyo
[changfu@changfu-laptop:~$]


Il y a tout dedans:
Total = design capacity
En charge = remaining capacity

Après il faudra faire un calcule mais ce sera pas compliquer.

fabounet, Monday 16 June 2008 à 15:31


Subscription date : 30 November 2007
Messages : 17118
merci !

fabounet, Monday 04 August 2008 à 16:10


Subscription date : 30 November 2007
Messages : 17118
bon je suis en train de virer DBus de PM pour la partie récupération des stats.
donc ça va sûrement buguer, je compte sur vous
après il faudra voir si du coup ça règle les problèmes rencontrés par certains.

Gege, Monday 04 August 2008 à 16:33


Subscription date : 03 February 2008
Messages : 361
KDE ?

fabounet, Tuesday 05 August 2008 à 11:22


Subscription date : 30 November 2007
Messages : 17118
si ça marchait pas sous KDE, alors ça devrait marcher du coup
j'ai pas encore commité, ce soir sûrement.

nochka85, Monday 22 September 2008 à 21:20


Subscription date : 29 November 2007
Messages : 7408
J'ai toujours ce problème sur mon Eeepc sous Eeexubuntu que j'avais signalé dans un autre post : Je ne peux plus affiché le temps ... j'ai toujours -:-- qui s'affiche...
Dans /proc/acpi/battery/BAT0/state j'ai çà :

present: yes
capacity state: ok
charging state: charging
present rate: unknown
remaining capacity: 80 mAh
present voltage: 8372 mV


.... ok, je sais que c'est le "present rate: unknown" qui pose problème ... mais le VRAI soucis, c'est que cela marchait TRES BIEN avant ... De plus, le quick info de la charge dans le panel xfce me donne bien un temps restant (en charge OU en décharge) ...

fabounet, Tuesday 23 September 2008 à 12:31


Subscription date : 30 November 2007
Messages : 17118
hmm, alors il doit y'avoir cette info autre part.
tu aurais pas un autre fichier du même genre ? (dans /proc/battery par exemple ?)

Applets | Applets

Subjects Author Language Messages Last message
[Locked] PowerManager
Page : 1 2 3 ...14 15 16 17 18
necropotame Français 348 lylambda [Read]
01 March 2010 à 13:43


Glx-Dock / Cairo-Dock List of forums Applets | Applets PowerManager Top

Online users :

Powered by ElementSpeak © 2007 Adrien Pilleboue, 2009-2013 Matthieu Baerts.
Dock based on CSS Dock Menu (Ndesign) with jQuery. Icons by zgegball
Cairo-Dock is a free software under GNU-GPL3 licence. First stable version created by Fabounet.
Many thanks to TuxFamily for the web Hosting and Mav for the domain name.