A laptop battery-status notification daemon written in Rust.
Currently only supports Linux
Sarge reads the files in the /sys/class/power_supply directory, which contains information regarding the battery and power adapter. In its config file are defined a set of triggers which dictate when a notification will be shown. A trigger maybe defined for when a certain battery percentage is reached or for when the ac power is connected or disconnected.
Sarge uses D-Bus notifications to send its notifications. Desktop environments typically have this out of the box. If you use a discrete window-manager, then you might need to install a notification serer. I personally use Dunst. For further information, please refer to this Arch Wiki page.
Also, to build and install (or to use the script for that), you must have git and cargo installed and in your $PATH. For installing cargo, please look at the Rust install documentation.
Sarge can be built and installed by the following command:
bash <(wget -qO- https://raw.githubusercontent.com/RedDocMD/Sarge/master/build.sh)
Alternatively, you can download the script from here and run it.
Suppose you are in $HOME when you perform the install.
git clone https://github.com/RedDocMD/Sarge
cd Sarge
cargo build --release
The binary will be formed in target/release/sarge.
To automatically start this on login, make a file called sarge.sh in /etc/profile.d and make it executable. Add the line $HOME/Sarge/target/release/sarge, save and re-login.
cd /tmp
touch sarge.sh
echo "$HOME/Sarge/target/release/sarge &" > sarge.sh
sudo bash
cp sarge.sh /etc/profile.d/
chmod +x /etc/profle.d/sarge.sh
exit
Sarge looks in the following files, in order, for its config:
$XDG_CONFIG_HOME/sarge/sarge.yml$XDG_CONFIG_HOME/sarge.yml$HOME/.config/sarge/sarge.yml$HOME/.sarge.yml
If a config file is not found, Sarge uses its own default config. The default config is provided here.
The config file is to be written in YAML. The keys are as follows:
update_interval: The time-interval, in milisecond, at which Sarge will update the battery info.triggers: Array for the triggers, which is a set of the following keys:percentage: The battery percentage at which the trigger takes place.when: It is one of the following alternatives (case matters):Equal- when the battery percentage becomes equal topercentageAbove- when the battery percentage goes above thepercentageBelow- when the battery percentage goes below thepercentageCharging- when the AC adapter is plugged in.percentagekey is ignoredDischarging- when the AC adapter is unplugged.percentagekey is ignored
Sarge supports hot-reloading of the config file, which means that it watches for changes in its config file.
Sarge is released under the MIT license.