Fixed git ignore, updated much functionality, updated the procress_monitor to work, updated install.sh, added license, updated Makefile, updated install.sh, updated README.md, all that
This commit is contained in:
175
README.md
175
README.md
@@ -1,57 +1,73 @@
|
||||
# Battery 0 Dameon
|
||||
A battery daemon running the GTK framework built in C. Application monitors file structure /sys/class/power_suppply/BAT0/capacity file and if you have it its accounts for BAT1 (I'm pretty sure. In theory it does but I have not tested it as I dont have that file structure).
|
||||
# Battery Monitor Daemon
|
||||
|
||||
A battery monitor daemon built in C using the GTK framework. The application monitors your system's battery level and provides notifications when the battery is low or critically low. It also implements battery-saving features like reducing screen brightness and managing background processes to help preserve battery life.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Features](#features)
|
||||
- [Installation](#installation)
|
||||
- [Dependencies](#dependencies)
|
||||
- [Building the Application](#building-the-application)
|
||||
- [Installing the Application](#installing-the-application)
|
||||
- [Building and Installing the Application](#building-and-installing-the-application)
|
||||
- [Configuration](#configuration)
|
||||
- [Adjusting Battery Thresholds](#adjusting-battery-thresholds)
|
||||
- [Configuring Process Management](#configuring-process-management)
|
||||
- [Uninstallation](#uninstallation)
|
||||
- [Contributing](#contributing)
|
||||
|
||||
## features
|
||||
## Features
|
||||
|
||||
- GTK notification for 15 percent or less, and GTK notification for 5 percent or less.
|
||||
- to change, go to src/battery_monitor.c, change #define THRESHOLD_LOW or #define THRESHOLD_CRITICAL to custom values.
|
||||
- Dynamic battery percentage changing depending on last read value.
|
||||
- When above THRESHOLD_HIGH, checks every 5 minutes.
|
||||
- When Below critical, checks every 30 seconds.
|
||||
- When low, checks every minute.
|
||||
- Logging file created in /tmp/battery_monitor.log
|
||||
- Battery saving mode changes brightness to help preserve battery
|
||||
- Battery saving mode attempt to manage background procress is still in progress.
|
||||
---
|
||||
|
||||
## Installation
|
||||
- **Configurable Battery Thresholds**: Receive notifications when the battery level falls below user-defined thresholds for low and critical levels. Adjust these thresholds easily via a configuration file.
|
||||
|
||||
- **Dynamic Monitoring Interval**: The application adjusts its battery level check interval based on the current battery percentage to optimize performance and responsiveness.
|
||||
|
||||
- **Battery Saving Mode**:
|
||||
- Reduces screen brightness to 50% when the battery is low.
|
||||
- Suspends high CPU-consuming processes and user daemons to conserve battery life.
|
||||
- Allows users to specify which processes to ignore during suspension.
|
||||
|
||||
- **Logging**: Activity is logged to `/tmp/battery_monitor.log` for debugging and monitoring purposes.
|
||||
|
||||
- **Systemd Service**: Runs as a user-level systemd service, starting automatically upon login.
|
||||
|
||||
- **Version Checking**: Supports version checking for both the application and the accompanying scripts.
|
||||
|
||||
---
|
||||
|
||||
## Installation
|
||||
|
||||
### Dependencies
|
||||
|
||||
### Dependencies
|
||||
Ensure you have the following dependencies installed on your system:
|
||||
|
||||
- **gcc**: GNU Compiler Collection for compiling the C code.
|
||||
- **make**: Utility for directing compilation.
|
||||
- **GTK+**: Library for creating Graphical User Interfaces
|
||||
- **Standard C Headers**: Standard Libraries found in glibc
|
||||
- **pkg-config**: Helper tool used during compilation.
|
||||
- **GTK+ 3 Development Libraries**: Library for creating graphical user interfaces.
|
||||
|
||||
**On Debian/Ubuntu:**
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get install build-essential libgtk-3-dev
|
||||
sudo apt-get install build-essential pkg-config libgtk-3-dev
|
||||
```
|
||||
|
||||
**On Fedora:**
|
||||
|
||||
```bash
|
||||
sudo dnf install gcc make gtk3-devel
|
||||
sudo dnf install gcc make pkgconf-pkg-config gtk3-devel
|
||||
```
|
||||
|
||||
**On Arch Linux:**
|
||||
|
||||
```bash
|
||||
sudo pacman -S base-devel gtk3
|
||||
sudo pacman -S base-devel pkgconf gtk3
|
||||
```
|
||||
|
||||
### Building the Application
|
||||
### Building and Installing the Application
|
||||
|
||||
1. **Clone the Repository**
|
||||
|
||||
@@ -60,45 +76,124 @@ sudo pacman -S base-devel gtk3
|
||||
cd bat0daemon
|
||||
```
|
||||
|
||||
2. **Build the Application**
|
||||
2. **Run the Installation Script**
|
||||
|
||||
```bash
|
||||
make
|
||||
./install.sh
|
||||
```
|
||||
|
||||
This will compile the source code and create the executable in the base directory.
|
||||
The `install.sh` script will:
|
||||
|
||||
### Installing the Application
|
||||
- Check for and install any missing dependencies.
|
||||
- Build the application using `make`.
|
||||
- Install the `battery_monitor` binary to `/usr/local/bin`.
|
||||
- Install the `battery_daemon.sh` script to `/usr/local/bin`.
|
||||
- Set up a user-level systemd service to run the application automatically on login.
|
||||
- Create a default configuration file at `~/.config/battery_monitor/config.conf` if it does not exist.
|
||||
|
||||
Optionally, you can install the application system-wide:
|
||||
**Note**: The `install.sh` script may prompt for your password to use `sudo` for installation.
|
||||
|
||||
```bash
|
||||
make
|
||||
./install.sh
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
The application uses a configuration file located at `~/.config/battery_monitor/config.conf`. If the file does not exist, the `install.sh` script will create one with default values.
|
||||
|
||||
### Adjusting Battery Thresholds
|
||||
|
||||
Edit the configuration file to adjust battery thresholds:
|
||||
|
||||
```ini
|
||||
# ~/.config/battery_monitor/config.conf
|
||||
|
||||
threshold_low=25
|
||||
threshold_critical=5
|
||||
threshold_high=80
|
||||
```
|
||||
|
||||
- **threshold_low**: Battery percentage at which the application will send a low battery notification.
|
||||
- **threshold_critical**: Battery percentage at which the application will send a critical battery notification.
|
||||
- **threshold_high**: Battery percentage above which the application checks the battery level less frequently.
|
||||
|
||||
### Configuring Process Management
|
||||
|
||||
Specify processes to ignore when the application suspends high CPU-consuming processes or user daemons:
|
||||
|
||||
```ini
|
||||
ignore_processes_for_kill=process1, process2, process3
|
||||
ignore_processes_for_sleep=process4, process5, process6
|
||||
```
|
||||
|
||||
- **ignore_processes_for_kill**: List of processes to ignore when suspending high CPU-consuming processes.
|
||||
- **ignore_processes_for_sleep**: List of processes to ignore when suspending user daemons.
|
||||
|
||||
**Example**:
|
||||
|
||||
```ini
|
||||
ignore_processes_for_kill=firefox, code
|
||||
ignore_processes_for_sleep=dropbox, slack
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Uninstallation
|
||||
|
||||
To remove the application and its associated files:
|
||||
|
||||
1. **Remove the Executable**
|
||||
1. **Stop and Disable the Systemd Service**
|
||||
|
||||
If installed system-wide:
|
||||
```bash
|
||||
systemctl --user stop battery_monitor.service
|
||||
systemctl --user disable battery_monitor.service
|
||||
```
|
||||
|
||||
2. **Remove Installed Files**
|
||||
|
||||
```bash
|
||||
sudo rm /usr/local/bin/battery_monitor
|
||||
sudo rm /usr/local/bin/battery_daemon.sh
|
||||
```
|
||||
|
||||
3. **Remove the Systemd Service File**
|
||||
|
||||
```bash
|
||||
rm ~/.config/systemd/user/battery_monitor.service
|
||||
```
|
||||
|
||||
4. **Reload the Systemd Daemon**
|
||||
|
||||
```bash
|
||||
systemctl --user daemon-reload
|
||||
```
|
||||
|
||||
5. **Remove Configuration and Log Files (Optional)**
|
||||
|
||||
```bash
|
||||
rm -rf ~/.config/battery_monitor
|
||||
rm /tmp/battery_monitor.log
|
||||
```
|
||||
|
||||
6. **Clean Up Build Files**
|
||||
|
||||
```bash
|
||||
make clean
|
||||
```
|
||||
|
||||
2. **Delete Configuration and Data Files**
|
||||
|
||||
```bash
|
||||
sudo rm -rf ~/usr/local/bin/bat0daemon
|
||||
*add more*
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! If you have ideas for new features or improvements, feel free to fork the repository and submit a pull request. Let's make this application even better together.
|
||||
Contributions are welcome! If you have ideas for new features, improvements, or bug fixes, feel free to fork the repository and submit a pull request. Let's make this application even better together.
|
||||
|
||||
---
|
||||
|
||||
**Additional Notes**:
|
||||
|
||||
- **Battery Monitoring**: The application dynamically finds the battery device path, supporting systems with different battery naming conventions (e.g., `BAT0`, `BAT1`).
|
||||
|
||||
- **Process Suspension**: The application can suspend non-critical background processes to conserve battery life when in battery-saving mode. Critical system processes are automatically excluded.
|
||||
|
||||
- **Customization**: Users can tailor the application's behavior extensively through the configuration file.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user