16.04ではUnityを使用しています。何らかの理由で、バッテリー低下のポップアップ通知が表示されません。バッテリーが「ローバッテリー」側にあるかどうかを確認するには、上部パネルのバッテリーアイコンを使用する必要があります。16.04のデフォルトの動作は?または、低バッテリのポップアップが表示されませんか?
16.04ではUnityを使用しています。何らかの理由で、バッテリー低下のポップアップ通知が表示されません。バッテリーが「ローバッテリー」側にあるかどうかを確認するには、上部パネルのバッテリーアイコンを使用する必要があります。16.04のデフォルトの動作は?または、低バッテリのポップアップが表示されませんか?
回答:
indicator-power次のコマンドで再インストールを試みます:
sudo apt-get install --reinstall indicator-power
それでも問題が解決しない場合は、以前の回答の1つで提供されているバッテリー監視スクリプトを使用することを検討してください:https : //askubuntu.com/a/603322/295286
以下は、バッテリーの充電が一定の割合を超えたときに通知し、10%になるとシステムを一時停止するPythonスクリプトです。使い方は簡単です:
python battery_monitor.py INT
ここで、INTは、通知を受信する必要のある、希望するバッテリーのパーセントの整数値です30。
上記のコマンドをスタートアップアプリケーションに追加して、Unityセッションにログインするたびにこのスクリプトを開始することもできます。
チャットとコメントでのOPリクエストに従って、スクリプトは2つの引数を取ります。1つは放電通知用、2つ目は充電通知用です。
Github Gitstとしても利用可能
#!/usr/bin/env python
from gi.repository import Notify
import subprocess
from time import sleep, time
from sys import argv
import dbus
def send_notification(title, text):
    try:
        if Notify.init(argv[0]):
            n = Notify.Notification.new("Notify")
            n.update(title, text)
            n.set_urgency(2)
            if not n.show():
                raise SyntaxError("sending notification failed!")
        else:
            raise SyntaxError("can't initialize notification!")
    except SyntaxError as error:
        print(error)
        if error == "sending notification failed!":
            Notify.uninit()
    else:
        Notify.uninit()
def run_cmd(cmdlist):
    try:
        stdout = subprocess.check_output(cmdlist)
    except subprocess.CalledProcessError:
        pass
    else:
        if stdout:
            return stdout
def run_dbus_method(bus_type, obj, path, interface, method, arg):
    if bus_type == "session":
        bus = dbus.SessionBus()
    if bus_type == "system":
        bus = dbus.SystemBus()
    proxy = bus.get_object(obj, path)
    method = proxy.get_dbus_method(method, interface)
    if arg:
        return method(arg)
    else:
        return method()
def suspend_system():
    run_dbus_method('session',
                    'com.canonical.Unity',
                    '/com/canonical/Unity/Session',
                    'com.canonical.Unity.Session',
                    'Suspend', 'None')
def get_battery_percentage():
    output = run_cmd(['upower', '--dump']).decode().split('\n')
    found_battery = False
    for line in output:
        if 'BAT' in line:
            found_battery = True
        if found_battery and 'percentage' in line:
            return line.split()[1].split('%')[0]
def main():
    end = time()
    battery_path = ""
    for line in run_cmd(['upower', '-e']).decode().split('\n'):
        if 'battery_BAT' in line:
            battery_path = line
            break
    while True:
        notified = False
        while subprocess.call(['on_ac_power']) == 0:
            sleep(0.25)
            run_dbus_method('system', 'org.freedesktop.UPower',
                            battery_path, 'org.freedesktop.UPower.Device',
                            'Refresh', 'None')
            battery_percentage = int(get_battery_percentage())
            if battery_percentage == int(argv[2]) and not notified:
               subprocess.call( ['zenity', '--info','--text', 'Battery reached' + argv[2] + '%'  ]  ) 
               notified = True
        while subprocess.call(['on_ac_power']) == 1:
            sleep(0.25)
            run_dbus_method('system', 'org.freedesktop.UPower',
                            battery_path, 'org.freedesktop.UPower.Device',
                            'Refresh', 'None')
            battery_percentage = int(get_battery_percentage())
            if battery_percentage <= int(argv[1]):
                if battery_percentage <= 10:
                    send_notification('Low Battery',
                                      'Will suspend in 60 seconds')
                    sleep(60)
                    suspend_system()
                    continue
                if end < time():
                    end = time() + 600
                    send_notification('Low Battery', 'Plug in your charger')
if __name__ == '__main__':
    main()これは正常ではありません。16.04を実行していてポップアップが表示されますが、gnomeシェルを使用しています。
あなたはあなたにメッセージを与えるスクリプトを作ることができます。
battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
if [ $battery_level -le 10 ]
then
    notify-send "Battery low" "Battery level is ${battery_level}%!"
fi
次に、cronジョブを作成し、数分ごとに実行します。
crontab -eは、nanoエディターを選択し(cronジョブを作成したことがない場合のみ)、2を押してEnterキーを押します。その後、ファイルが開き、一番下までスクロールして新しい行を追加します。/2 * * * * my-script.sh  を押してctrl + xから、入力yして入力します。うまくいくはずです。申し訳ありませんが、コアファイルについての考えはありません。
                    はい、これは正常です。バッテリー通知を設定するための簡単なbashスクリプトを作成しました。
#!/usr/bin/env bash
# check if acpi is installed.
if [ `dpkg -l | grep acpi | grep -v acpi-support | grep -v acpid | grep -c acpi` -ne 1 ]; then
    echo "run 'sudo apt install acpi' then run '$0' again."
    exit
fi
if [ $# -eq 1 ] && [ "$1" == "--install" ]; then
    echo "installing battery notifier..."
    if [ ! -e "$HOME/bin" ]; then
        mkdir $HOME/bin
    fi  
    cp $0 $HOME/bin/bn.sh
    (crontab -l 2>/dev/null; echo "*/2 * * * * $HOME/bin/bn.sh") | crontab -
else
    # check if power adapter is plugged in, if not, check battery status.
    if [ -z "`acpi -a | grep on-line`" ]; then
        batlvl=`acpi -b | grep -P -o '[0-9]+(?=%)'`
        if [ $batlvl -le 15 ] && [ $batlvl -ge 11 ]; then
            notify-send "Battery is at $batlvl%. Please plug your computer in."
        elif [ $batlvl -le 10 ] && [ $batlvl -ge 6 ]; then
            notify-send "Battery is at $batlvl%. Computer will shutdown at 5%."
        elif [ $batlvl -le 5 ]; then
            notify-send "BATTERY CRITICALLY LOW, SHUTTING DOWN IN 3 SECONDS!"
            sleep 3
            shutdown -h now
        fi
    fi  
fi私もこれと私のgithubアカウントに関する説明を持っています。これがお役に立てば幸いです。
低バッテリー、フルバッテリーなどのためにそれを行う優れたアプリを見つけました。
これを読む
http://www.omgubuntu.co.uk/2016/07/ubuntu-battery-monitor-notifications
indicator-powerパッケージを再インストールしてみてください。必要に応じて、通知を