2009-02-16 14:15:42 · Author: 五帝 · Tagged with:
Linux,
Gnome |
Comments
首先,我得说一下我是 Linux 新手,这个解决方法只是能用而已。
gnome-power-manager 没低电量提示的问题困扰了我将近半个月的时间,期间曾按网上大多数人提供的方法修改 gconf 配置中的 /apps/gnome-power-manager/general/use_time_for_policy 的值为 false,让 gnome-power-manager 使用电量百分比作为判断依据,但没有效果。
后来仔细得浏览了一下
这个页面,发现
Joakim Andersson 所写的回复,非常明确得指出了问题所在。但继续往后浏览,发现有管理者说
这个问题已于去年9月修复。而这个页面讨论的似乎是 Ubuntu 库里的版本,经过检验发现我这 Arch Linux 里装的 gnome-power-manager 虽然是最新的 2.24.4 版,但是这个问题依然没有解决。
运行 gconf-editor,修改 /apps/gnome-power-manager/general/debug 的值为 true,开启额外的调试信息输出。执行
$ gnome-power-manager --verbose
观察其详细信息,会发现当电量百分比低于设定值时,会有一句
profile is not accurate. Not doing policy action
这就是 bugs 反应页面里提到的那个原因。
到 gnome 的 ftp 里下载一份
2.24.4 版本的 gnome-power-manager,解压缩。经过搜索,发现上面提到的那个除错信息在 src/gpm-cell-array.c 的 gpm_cell_array_emit_system_action() 函数内
static gboolean
gpm_cell_array_emit_system_action (GpmCellArray *cell_array,
GpmWarningsState warnings_state)
{
gfloat accuracy;
GpmCellUnit *unit;
g_return_val_if_fail (GPM_IS_CELL_ARRAY (cell_array), FALSE);
/* do we trust the profile enough to make a decision? */
unit = &(cell_array->priv->unit);
if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile,
unit->is_discharging);
if (accuracy < GPM_PROFILE_GOOD_TRUST) {
egg_debug ("profile is not accurate. Not doing policy action");
return FALSE;
}
}
/* we are not primary, or we are primary with a trusted profile */
if (warnings_state == GPM_WARNINGS_ACTION) {
egg_debug ("** EMIT: charge-action");
g_signal_emit (cell_array, signals [CHARGE_ACTION], 0, unit->percentage);
} else if (warnings_state == GPM_WARNINGS_CRITICAL) {
egg_debug ("** EMIT: charge-critical");
g_signal_emit (cell_array, signals [CHARGE_CRITICAL], 0, unit->percentage);
} else if (warnings_state == GPM_WARNINGS_LOW) {
egg_debug ("** EMIT: charge-low");
g_signal_emit (cell_array, signals [CHARGE_LOW], 0, unit->percentage);
}
return TRUE;
}
而经过搜索 CHARGE_LOW,发现似乎低电量的信号只能由这个函数发出,但很明显当 accuracy < GPM_PROFILE_GOOD_TRUST 时,就直接 return FALSE 了,所以不管 use_time_for_policy 是 true 还是 false,只要 accuracy 的值不够高,低电量提示就不可能出现。知道了这些,下面的工作就好办了,把涉及到 profile 准确度的几行注释掉,同时保证 /apps/gnome-power-manager/general/use_time_for_policy 的值为 false,程序就能正常工作了。
将定义 accuracy 变量的语句和为 unit 赋值的语句下方的 if 语句都注释掉
static gboolean
gpm_cell_array_emit_system_action (GpmCellArray *cell_array,
GpmWarningsState warnings_state)
{
//gfloat accuracy;
GpmCellUnit *unit;
g_return_val_if_fail (GPM_IS_CELL_ARRAY (cell_array), FALSE);
/* do we trust the profile enough to make a decision? */
unit = &(cell_array->priv->unit);
/*
if (unit->kind == GPM_CELL_UNIT_KIND_PRIMARY) {
accuracy = gpm_profile_get_accuracy_average (cell_array->priv->profile,
unit->is_discharging);
if (accuracy < GPM_PROFILE_GOOD_TRUST) {
egg_debug ("profile is not accurate. Not doing policy action");
return FALSE;
}
}
*/
然后编译安装。经过测试,低电量提示可以正常显示了。
参考:
1.
Bug #135548 in gnome-power-manager...2.
Brian Jones - Re: Autoconf problems?3.
Charles Wilson - Re: 'can not find install-sh' when running configure4.
Re: difficulties with gnome-doc-utils.make5.
automake: 7.3.9.1 required file `./ltmain.sh' not found6.
Automake(1) - 一蓑烟雨任平生 Le blogspot de Leizhige - CSDNBlog