#!/bin/bash
# Get the battery percentage for battery 0
battery0_percent=$(cat /sys/class/power_supply/BAT0/capacity)
# Get the battery percentage for battery 1
battery1_percent=$(cat /sys/class/power_supply/BAT1/capacity)
# Threshold level
threshold=10
# Check if either battery is less than 10%
if [ "$battery0_percent" -lt "$threshold" ] || [ "$battery1_percent" -lt "$threshold" ]; then
# Display a Zenity warning
zenity --warning --text "Battery level is below 10% on one or both batteries!"
fi
当我的其中一个电池电量低于 10% 时,此脚本会发送警告。
我怎样才能在后台运行这个脚本,所以我会在需要时通知我。任何想法?