- Rust 97.2%
- Shell 2.8%
| src | oops | |
| .gitignore | Initial commit | |
| Cargo.lock | exit instead of killing if already running | |
| Cargo.toml | oops | |
| LICENSE | and some of this | |
| README.md | add multiplatform notices (my first Codeberg star yay) | |
what a catchy name rdsq/dtbd not a single vowel
Duct Tape Battery Daemon (dtbd)
What does a programmer do when they don't find a tool that they need and feel too lazy to search better? That's right, they write their own
So anyway, this is a thing for Linux that sends you notifications when your battery is low or it's time to unplug the charger
Usage
Install it:
cargo install --git https://codeberg.org/rdsq/dtbd
And then you just call it with ~/.cargo/bin/dtbd
For example, you can add this to Hyprland:
exec-once = ~/.cargo/bin/dtbd
Config
You can configure this thing (how unexpected!)
Normally it looks for config at ~/.config/dtbd/dtbd.toml but can be set explicitly with --config option
In a config file, you define the sectors of battery or something. So the thing looks like:
# this is the default config
[[low]]
percent = 20 # below which it sends a notification
message = "Battery low (20%)" # the text of the notification
[[low]]
percent = 10
message = "Battery low (10%)"
[[low]]
percent = 5
message = "Battery low (5%)"
subtitle = "your last warning " # additional text
[[charged]] # (you can skip this one if you prefer)
percent = 80 # above which sends a notification (but only when charging)
message = "Battery charged (80%)"
subtitle = "Take care of your battery health"
[general_low]
urgency = "normal" # can be "low" | "normal" | "critical"
icon = "battery-low-symbolic" # the icon of the notification, from default icon theme
[general_charged]
urgency = "normal" # can also be defined in each entry individually
icon = "battery-level-100-charged-symbolic" # this one too
Usage (complicated)
Since this is a duct tape battery daemon, it consists of a few components: dtbd-listener, dtbd-finder, dtbd-main
dtbd-listenerlistens toupowerand tries to guess when battery status updatesdtbd-finderfinds the battery directory on the systemdtbd-mainis the main thing that sends notifications
And dtbd is the duct tape of this battery daemon, putting it all together in its default order, though you can make your own. You can see the script at src/script.sh
If you want to test your configuration without waiting or ruining your battery, you can just run dtbd-main and pass any battery status you want to its stdin. It expects input in format <percent> <status>, for example 37 Discharging, or 37 d for short
Operating Systems
This project was created for Linux/XDG, so it assumes Linux, but because it is duct tape some components should theoretically work on other systems too, where "theoretically" means "untested and probably not something you'd want to do because that's out of scope of this project and you might not need it there"
- ✅
dtbd-listenershould work where UPower works, so XDG - ❌
dtbd-finderassumes Linux sysfs, so nope - ✅
dtbd-mainuses notify_rust which works on XDG (Linux, BSD, etc.) and to limited extent on macOS and Windows.dtbd-mainalso assumes XDG config directory conventions so maybe override that with--configon non XDG systems - ❌
dtbdrelies ondtbd-finder, so will not work by default