{"id":16165973,"url":"https://github.com/luisnquin/battery-notifier","last_synced_at":"2025-06-13T14:02:03.255Z","repository":{"id":219366121,"uuid":"748873302","full_name":"luisnquin/battery-notifier","owner":"luisnquin","description":"A customizable battery notifier for Linux kernels focused in BAT0 and BAT1. The missing part of your WM.","archived":false,"fork":false,"pushed_at":"2024-04-07T03:36:11.000Z","size":6503,"stargazers_count":11,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T12:56:37.900Z","etag":null,"topics":["battery","battery-percentage","compositor","daemon","hyprland","i3","laptop","linux","nixos","sway","systemd","window-manager"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luisnquin.png","metadata":{"files":{"readme":".github/README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-26T23:24:36.000Z","updated_at":"2025-02-03T21:06:35.000Z","dependencies_parsed_at":"2024-10-27T19:28:45.464Z","dependency_job_id":null,"html_url":"https://github.com/luisnquin/battery-notifier","commit_stats":{"total_commits":53,"total_committers":1,"mean_commits":53.0,"dds":0.0,"last_synced_commit":"6532d55469db14044258e6690939587179d759e6"},"previous_names":["luisnquin/battery-notifier"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luisnquin%2Fbattery-notifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luisnquin%2Fbattery-notifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luisnquin%2Fbattery-notifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luisnquin%2Fbattery-notifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luisnquin","download_url":"https://codeload.github.com/luisnquin/battery-notifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955715,"owners_count":20374372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["battery","battery-percentage","compositor","daemon","hyprland","i3","laptop","linux","nixos","sway","systemd","window-manager"],"created_at":"2024-10-10T02:52:45.808Z","updated_at":"2025-06-13T14:02:03.185Z","avatar_url":"https://github.com/luisnquin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Battery notifier\n\nIs a customizable daemon designed to report the battery status of your laptop when using window managers. It can be utilized as a [systemd](https://wiki.archlinux.org/title/systemd) service or managed through the `exec` dispatcher of your preferred window manager/compositor.\n\n![Demo](./.github/assets/demo.gif)\n\nThis project follows the [Power supply class specification](https://docs.kernel.org/power/power_supply_class.html#attributes-properties-detailed) defined in the [Linux Kernel Documentation](https://docs.kernel.org/).\n\n## Features\n\n- **Lightweight**: Minimal impact on system resources (3.75 MiB of consumption on my computer).\n- **Configurable notification levels**: Customize three different notification levels – *reminder*, *warning*, and *threat*.\n- **Adjustable check interval:** Set the check interval to your liking, ensuring timely updates on your battery status.\n- **Custom notification icon**: Choose your preferred icon.\n- **Good configuration defaults**: Comes with well-considered default settings.\n\n## Why?\n\nWindow managers lack dedicated programs to notify the battery status of your computer. This project aims to fill that gap by providing a fully customizable solution that operates as a daemon, offering both battery status reporting and built-in performance features.\n\n## Configuration\n\nConfiguration files should be located in the `$XDG_CONFIG_FILE`. If undefined, the default location is `$HOME/.config`.\n\n```toml\n# battery-notifier/config.toml\n\ninterval_ms = 700 # 0.7s\nicon_path = \"/absolute/path/to/alternative/icon\"\n\n[reminder]\nthreshold = 30\ntitle = \"Battery somewhat low\"\ncontent = \"Battery capacity is at ${{capacity}}%.\\nConsider plugging in your laptop to avoid running out of power.\"\n\n[warn]\nthreshold = 15\ntitle = \"Battery low\"\ncontent = \"Battery capacity is critically low at ${{capacity}}%.\\nPlease plug in your laptop.\"\n\n[threat]\nthreshold = 5\ntitle = \"Battery in critical state\"\ncontent = \"Battery capacity is extremely low at ${{capacity}}%.\\nConnect your laptop to a power source urgently to prevent data loss and unexpected shutdown.\"\n```\n\nAdjust the values to suit your preferences.\n\n## Installation\n\n\u003cdetails open\u003e\n\u003csummary\u003e\u003cb\u003eUbuntu\u003c/b\u003e\u003c/summary\u003e\n\u003cbr\u003e\n\n```sh\n$ git clone https://github.com/luisnquin/battery-notifier.git\n$ cd battery-notifier\n# Install necessary build dependencies.\n$ apt update \u0026\u0026 apt install cmake g++ cargo -y\n# Install the program binary. Default location is $HOME/.cargo/bin.\n$ cargo install --path .\n# Install systemd unit in your computer\n$ mkdir -p $HOME/.config/systemd/user/\n$ sed 's#ExecStart=battery-notifier#ExecStart=$HOME/.cargo/bin/battery-notifier#' systemd/battery-notifier.service \u003e \"$HOME/.config/systemd/user/battery-notifier.service\"\n$ systemctl --user enable battery-notifier.service\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eHome Manager\u003c/b/\u003e\u003c/summary\u003e\n\nIf you use [Home Manager](https://github.com/nix-community/home-manager) to manage your user environment, integrating the battery notifier into your configuration is straightforward.\n\n```nix\n# flake.nix\n{\n  inputs = {\n    nixpkgs.url = \"nixpkgs/nixos-unstable\";\n    home-manager = {\n      url = \"github:nix-community/home-manager\";\n      inputs.nixpkgs.follows = \"nixpkgs\";\n    };\n    battery-notifier = {\n      url = \"github:luisnquin/battery-notifier\";\n      inputs.nixpkgs.follows = \"nixpkgs\";\n    };\n  };\n\n  outputs = {\n    self,\n    home-manager,\n    battery-notifier,\n    nixpkgs,\n    ...\n  }: let\n    system = \"x86_64-linux\";\n    username = \"xyz\";\n\n    pkgs = import nixpkgs {inherit system;};\n  in {\n    homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {\n      inherit pkgs;\n\n      modules = [\n        battery-notifier.homeManagerModule.default\n        {\n          services.battery-notifier = {\n            enable = true;\n            settings = {\n              icon_path = ../assets/icons/battery-notifier.png; # Nix path\n              interval_ms = 700;\n              reminder = {threshold = 30;};\n              threat = {threshold = 5;};\n              warn = {threshold = 15;};\n            };\n          };\n        }\n      ];\n    };\n  };\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cb\u003eNixOS\u003c/b/\u003e\u003c/summary\u003e\n\n```nix\n# flake.nix\n{\n  inputs = {\n    nixpkgs.url = \"nixpkgs/nixos-unstable\";\n    battery-notifier = {\n      url = \"github:luisnquin/battery-notifier\";\n      inputs.nixpkgs.follows = \"nixpkgs\";\n    };\n  };\n\n  outputs = {\n    self,\n    battery-notifier,\n    nixpkgs,\n    ...\n  }: let\n    system = \"x86_64-linux\";\n    hostname = \"nixos\";\n\n    pkgs = import nixpkgs {inherit system;};\n  in {\n    nixosConfigurations.\"${hostname}\" = nixpkgs.lib.nixosSystem {\n      inherit pkgs;\n\n      modules = [\n        battery-notifier.nixosModules.default\n        {\n          services.battery-notifier = {\n            enable = true;\n            settings = {\n              icon_path = ../assets/icons/battery-notifier.png; # Nix path\n              interval_ms = 700;\n              reminder = {threshold = 30;};\n              threat = {threshold = 5;};\n              warn = {threshold = 15;};\n            };\n          };\n        }\n      ];\n    };\n  };\n}\n```\n\n\u003c/details\u003e\n\n## Reference\n\n### `services.battery-notifier` module reference\n\nApplicable for the supplied home-manager and nixos configuration options.\n\n#### `services.battery-notifier.enable`\n\n**Type:** [Boolean](https://nixos.org/manual/nix/stable/language/values#type-boolean)\n\nTo enable the battery-notifier systemd service. It already has its own defaults so this can be enough for you.\n\n#### `services.battery-notifier.settings`\n\n**Type:** [Attribute set](https://nixos.org/manual/nix/stable/language/values#attribute-set)\n\nUser preferences of the program.\n\n#### `services.battery-notifier.settings.interval_ms`\n\n**Type:** [Number](https://nixos.org/manual/nix/stable/language/values#type-number)\n\nThe number of milliseconds the program will wait to check again your **BAT(0|1)** file.\n\n#### `services.battery-notifier.settings.icon_path`\n\n**Type:** [Nix path](https://nixos.org/manual/nix/stable/language/values#type-path) or [String](https://nixos.org/manual/nix/stable/language/values#type-string)\n\nAbsolute path to the icon to use in the notification message.\n\n#### `services.battery-notifier.settings.\u003cbound\u003e`\n\n**Type:** [Attribute set](https://nixos.org/manual/nix/stable/language/values#attribute-set)\n\nSettings for the different alert levels whose respectively are:\n\n- **reminder** [1st alert]\n- **warn** [2nd alert]\n- **threat** [final alert]\n\nEnsure consistent threshold values across all levels, or the module assertion **will fail**.\n\n#### `services.battery-notifier.settings.\u003cbound\u003e.threshold`\n\n**Type:** [Number](https://nixos.org/manual/nix/stable/language/values#type-number)\n\nNumber between **0 and 100** (careful) that will determine the capacity of the computer and whether it has just entered or exited.\n\n#### `services.battery-notifier.settings.\u003cbound\u003e.title`\n\n**Type:** [String](https://nixos.org/manual/nix/stable/language/values#type-string)\n\nTitle of the notification message displayed when the battery enters a specific **bound**.\n\n#### `services.battery-notifier.settings.\u003cbound\u003e.content`\n\nContent of the notification message displayed when the battery enters a specific **bound**.\n\n### CLI reference\n\n```text\nA customizable battery notifier for Linux kernels focused in BAT0 and BAT1\n\nUsage: battery-notifier [OPTIONS]\n\nOptions:\n  -d, --debug-file \u003cDEBUG_FILE\u003e    To simulate battery states (yaml)\n  -c, --config-file \u003cCONFIG_FILE\u003e  The config file path (toml)\n  -h, --help                       Print help\n  -V, --version                    Print version\n```\n\n## Development\n\nTo develop and contribute to the project, use standard Cargo commands such as **build**, **run**, and **add**.\n\n### Debugging\n\nAlmost always you'll need to check that some behaviors are working as expected or not.\nFor this you can create or modify a [debug file](./debug.yaml) and pass it via CLI arguments.\n\n```sh\n# Start the program using the debug file as a mock.\n$ cargo run -- --debug-file=./debug.yaml\n```\n\nThis command serves as a **manual test suite**, so after any changes, ensure to run the program using the original debug file.\n\n## Troubleshooting\n\n- **I'm not receiving audio alerts**: Check that the [soloud-rs](https://github.com/MoAlyousef/soloud-rs?tab=readme-ov-file#backends) package is being compiled with the\naudio backend that you're using. **By default** soloud-rs is compiled to only use [miniaudio](https://miniaud.io/).\n\n## Contributing\n\nFeel free to create a new issue or pull request if you see something to improve.\n\nAnyway, this project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/), so please align with that.\n\n## License\n\n[MIT](./.github/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluisnquin%2Fbattery-notifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluisnquin%2Fbattery-notifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluisnquin%2Fbattery-notifier/lists"}