首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在关键的电池级别上冬眠/暂停-我应该在哪里设置它从MATE GUI?

在关键的电池级别上冬眠/暂停-我应该在哪里设置它从MATE GUI?
EN

Ask Ubuntu用户
提问于 2018-10-29 11:25:19
回答 2查看 2.9K关注 0票数 3

我为我的笔记本买了新电池。它正在运行Ubuntu 16.04.5LTS。

这种新型电池容量正常,充电时间长:)

但我有一个小问题:当电池电量低于某个级别时,笔记本电脑就会立即关机。我记得,它通常是用旧电池挂起来的。

使用新电池,我可以手动挂起,所有与挂起相关的测试(如pm-is-supported --suspendpm-is-supported --hibernatepm-is-supported --suspend-hybrid)都返回0,因此支持这些操作。

要获得更多的预测结果,我已经重新设置了所有设置

代码语言:javascript
复制
gsettings reset-recursively org.mate.power-manager

因此,我的GSettings报告如下:

代码语言:javascript
复制
$ gsettings list-recursively | egrep "critical|action|low|time" | grep -i power | sort -u
org.mate.power-manager action-critical-battery 'hibernate'
org.mate.power-manager action-critical-ups 'shutdown'
org.mate.power-manager action-low-ups 'hibernate'
org.mate.power-manager action-sleep-type-ac 'suspend'
org.mate.power-manager action-sleep-type-battery 'hibernate'
org.mate.power-manager idle-dim-time 10
org.mate.power-manager info-history-time 21600
org.mate.power-manager notify-low-capacity true
org.mate.power-manager notify-low-power true
org.mate.power-manager percentage-action 2
org.mate.power-manager percentage-critical 3
org.mate.power-manager percentage-low 10
org.mate.power-manager show-actions true
org.mate.power-manager time-action 120
org.mate.power-manager time-critical 300
org.mate.power-manager time-low 1200
org.mate.power-manager use-time-for-policy true

/etc/UPower/UPower.conf中,我有默认值:

代码语言:javascript
复制
$ cat /etc/UPower/UPower.conf | grep -v ^# | egrep "Critical|Low|Action|Time"
PercentageLow=10
PercentageCritical=3
PercentageAction=2
TimeLow=1200
TimeCritical=300
TimeAction=120
CriticalPowerAction=HybridSleep

MATE Power Management Preferences (mate-power-preferences)没有设置关键电池级别的GUI元素:

我应该将hibernate或MATE GUI挂起的关键电池级别设置在哪里?通过GSettings或Dconf改变值会改变UPower.conf中的值吗?在关键的电池水平上,我还应该在哪里设置动作?

更新: 1.笔记本电脑型号为华硕UX32A。cat /sys/class/power_supply/BAT0/uevent的输出:

代码语言:javascript
复制
POWER_SUPPLY_NAME=BAT0
POWER_SUPPLY_STATUS=Discharging
POWER_SUPPLY_PRESENT=1
POWER_SUPPLY_TECHNOLOGY=Li-ion
POWER_SUPPLY_CYCLE_COUNT=481
POWER_SUPPLY_VOLTAGE_MIN_DESIGN=7400000
POWER_SUPPLY_VOLTAGE_NOW=7400000
POWER_SUPPLY_POWER_NOW=11151000
POWER_SUPPLY_ENERGY_FULL_DESIGN=48248000
POWER_SUPPLY_ENERGY_FULL=50038000
POWER_SUPPLY_ENERGY_NOW=46346000
POWER_SUPPLY_CAPACITY=92
POWER_SUPPLY_CAPACITY_LEVEL=Normal
POWER_SUPPLY_MODEL_NAME=UX32-65
POWER_SUPPLY_MANUFACTURER=ASUSTeK
POWER_SUPPLY_SERIAL_NUMBER= 

以及upower --dump的输出:

代码语言:javascript
复制
Device: /org/freedesktop/UPower/devices/line_power_AC0
  native-path:          AC0
  power supply:         yes
  updated:              Sun Nov  4 12:43:52 2018 (233 seconds ago)
  has history:          no
  has statistics:       no
  line-power
    warning-level:       none
    online:              no
    icon-name:          'ac-adapter-symbolic'

Device: /org/freedesktop/UPower/devices/battery_BAT0
  native-path:          BAT0
  vendor:               ASUSTeK
  model:                UX32-65
  power supply:         yes
  updated:              Sun Nov  4 12:45:52 2018 (113 seconds ago)
  has history:          yes
  has statistics:       yes
  battery
    present:             yes
    rechargeable:        yes
    state:               discharging
    warning-level:       none
    energy:              46.509 Wh
    energy-empty:        0 Wh
    energy-full:         46.916 Wh
    energy-full-design:  48.248 Wh
    energy-rate:         11.514 W
    voltage:             7.4 V
    time to empty:       4.0 hours
    percentage:          92%
    capacity:            81.4562%
    technology:          lithium-ion
    icon-name:          'battery-full-symbolic'
  History (charge):
    1541324752  92.000  discharging
  History (rate):
    1541324752  11.514  discharging

Device: /org/freedesktop/UPower/devices/DisplayDevice
  power supply:         yes
  updated:              Sun Nov  4 12:45:52 2018 (113 seconds ago)
  has history:          no
  has statistics:       no
  battery
    present:             yes
    state:               discharging
    warning-level:       none
    energy:              46.509 Wh
    energy-full:         46.916 Wh
    energy-rate:         11.514 W
    time to empty:       4.0 hours
    percentage:          92%
    icon-name:          'battery-full-symbolic'

Daemon:
  daemon-version:  0.99.4
  on-battery:      yes
  lid-is-closed:   no
  lid-is-present:  yes
  critical-action: HybridSleep

2.我的系统上没有安装其他类型的TLP。3.我重新安排了所有的设置,没有运气。今天我问了关于Ubuntu-Ubuntu。社区的问题

EN

回答 2

Ask Ubuntu用户

回答已采纳

发布于 2018-11-25 14:26:07

我仍然找不到GUI解决方案来解决我的问题。所以我转向了半GUI解决方案。

我使用其他电池电平指示器解决了这个问题--它被命名为fdpowermon

描述: ACPI fdpowermon笔记本电脑的简单电池电源监视器是一个简单的perl脚本,它在与freedesktop.org规范兼容的系统托盘中安装一个图标。每隔三秒,fdpowermon就会打电话给acpi,找出当前的电池电量。它将acpi命令的输出设置为工具提示文本,并将酌情更新已使用的图标。此外,当电源达到给定级别时,fdpowermon还可以选择性地调用perl子程序。但是,默认情况下不提供或启用此类子程序。

所以我已经安装好了

代码语言:javascript
复制
sudo apt-get install fdpowermon

并为此应用程序创建了配置文件夹:

代码语言:javascript
复制
mkdir -p ~/.config/fdpowermon/

在这里放了两个文件:

1.带有修改主题(在discharging数组中注意到第三个元素20:battery-low.png,它将用于Perl脚本中的挂起):

代码语言:javascript
复制
cat << \EOF > ~/.config/fdpowermon/theme.cfg 
[mytheme]
steps = 8
dir = /usr/share/icons/oxygen/22x22/status
# The below line makes fdpowermon not show an icon when the power is
# connected and the battery is completely full. This is by design,
# because that's how the author likes to use the software, and he is of
# the opinion that it's easier to ship software configured just the way
# he likes it rather than to have to reconfigure things.
#
# Requests are often made to change this default. This will not happen,
# but it's an easy change: just change the last entry in this "charging"
# configuration so that it says "100:battery-charging.png" rather than
# "99:battery-charging.png", and you're done!
charging = 0:battery-charging-low.png, 10:battery-charging-low.png, 20:battery-charging-caution.png, 30:battery-charging-caution.png, 50:battery-charging-040.png, 70:battery-charging-060.png, 90:battery-charging-080.png,100:battery-charging.png
discharging = 2:battery-missing.png:battery-low.png,10:battery-low.png, 20:battery-low.png,30:battery-caution.png,50:battery-040.png,70:battery-060.png,90:battery-080.png,100:battery-100.png
EOF

2.带有dbus挂起操作的Perl脚本文件:

代码语言:javascript
复制
cat << \EOF > ~/.config/fdpowermon/theme.pl
# Copy this file to ~/.config/fdpowermon/theme.pl.
#
# If you don't like the 'default' theme, define a new one by copying
# /etc/fdpowermon/theme.cfg to ~/.config/fdpowermon/theme.cfg and
# renaming/adjusting the 'default' theme there to something new.
# Don't forget to replace "default" below with your new theme name.
#
# See the manpage fdpowermon(1) for full details on what you can do
# here.

# define a suspend action
sub suspend {
    system("dbus-send --print-reply --system --dest=org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager.Suspend boolean:true");
}

# initialize our theme, from /etc/fdpowermon/theme.cfg or
# ~/.config/fdpowermon/theme.cfg
my $theme = fdpowermon::theme::get_theme("mytheme");

# on the discharge event for the lowest element in the list of steps (0 = first
# in the index, "d" for discharge), call the "suspend" sub defined above
$theme->set_event( 2, \&suspend, 'd' );
EOF

( DBus挂起命令来自这个伟大的答案)。

最后我已经禁用了MATE Power Manager电池指示器

代码语言:javascript
复制
gsettings set org.mate.power-manager icon-policy 'never'

并创建了自动启动桌面文件,将fdpowermon显示在托盘中:

代码语言:javascript
复制
mkdir -p ~/.config/autostart

cat << EOF > ~/.config/autostart/fdpowermon.desktop 
[Desktop Entry]
Type=Application
Exec=fdpowermon
Hidden=false
X-MATE-Autostart-enabled=true
Name[en_US]=fdpowermon
Name=fdpowermon
Comment[en_US]=
Comment=
EOF

因此,我在托盘中有一个漂亮的电池图标。

系统自动挂在20%的电池水平(该级别是可配置的,但我的新电池似乎报告的低值错误)。

票数 1
EN

Ask Ubuntu用户

发布于 2018-11-04 14:05:06

GUI方法

出发地:在Linux 18肉桂中改变关键电池级别和动作您可以使用以下方法安装dconf-editor

代码语言:javascript
复制
$ sudo apt-get install dconf-editor

然后转到org ->肉桂->设置-守护进程->插件-> power

  • 默认设置为( %):
  • 关键电池动作: hibernate
  • 关键:2
  • 行动:2
  • 低: 10

锻炼要谨慎,心满意足。

原始答案和

下面的编辑

使用:

查看当前设置

代码语言:javascript
复制
$ gsettings list-recursively | grep critical
org.gnome.settings-daemon.plugins.power critical-battery-action 'shutdown'
org.gnome.settings-daemon.plugins.power percentage-critical 3
org.gnome.settings-daemon.plugins.power time-critical 300

更改您的critical-battery-action

代码语言:javascript
复制
$ gsettings set org.gnome.settings-daemon.plugins.power critical-battery-action 'suspend'

Linux配偶差异

在使用Linux时,您需要用org.gnome替换org.mate,并可能更改密钥。来自ArchWiki

电池放电

若要禁用电池放电通知,请运行:

代码语言:javascript
复制
$ gsettings set org.mate.power-manager.notify-discharging false

然而,在Ubuntu并没有类似的情况。

查找所有匹配电源设置

若要查找所有配偶电源设置,请使用:

代码语言:javascript
复制
$ gsettings list-recursively | grep power-manager

在Ubuntu中,您可以使用:

代码语言:javascript
复制
$ gsettings list-recursively | grep plugins.power
票数 2
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1088237

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档