Skip to content

Commit

Permalink
Update README.md (#2)
Browse files Browse the repository at this point in the history
Fix readme and thresholds
  • Loading branch information
RyanMeulenkamp authored Oct 8, 2020
1 parent 382825e commit 0894eeb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
i3-battery-warning
==================
# i3-battery-warning

This is a simple battery warning script. It uses i3's nagbar to display warnings. Let this script run as a cronjob.

This is a simple battery warning script. It uses i3's nagbar to display warnings.
Open your crontab:

Let this script run as a cronjob.
```Shell
crontab -e
```

Open your crontab.
Add the following line to check battery status every minute:

$ crontab -e
```
*/1 * * * * /PATH/TO/YOUR/SCRIPT/i3-batwarn
```

Add the following line to check battery status every minute
If the need to trouble shoot arises one could pipe the cron job output to a file like:

*/1 * * * * /PATH/TO/YOUR/SCRIPT/i3batwarn.sh
```
*/1 * * * * /PATH/TO/YOUR/SCRIPT/i3-batwarn > /tmp/batterywarn.log
```

If the need to trouble shoot arises one could pipe the cron job output to a file like
If the script only works when invoked from terminal and not as a crobjob:

*/1 * * * * /PATH/TO/YOUR/SCRIPT/i3batwarn.sh > /tmp/batterywarn.log
```
*/1 * * * * DISPLAY=:0 /PATH/TO/YOUR/SCRIPT/i3-batwarn
```

If the script only works when invoked from terminal and not as a cronjob it might help to specify

DISPLAY=:0

in the cron tab (before calling this script).

screenshot
==========
## screenshot

![ScreenShot](screenshot.png)

fork changes
============
## fork changes

Added a pidfile where the pid of each (one max) nagbar is saved
and a check to kill the nagbar if the battery is above the limit.
This usually works but sometimes the nagbar has to be closed manually.
* Added a warning level in addition to existing threshold
* Check more often for the charger when de nagbar is active
* Major refactoring
6 changes: 3 additions & 3 deletions i3-batwarn
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#############################################

BATTERY="$(echo '/sys/class/power_supply/BAT'?)" # Battery file
WARNING_THRESHOLD='99' # Set energy limit in percent, where warning should be displayed
EMERGENCY_THRESHOLD='98' # Set energy limit in percent, where emergency should be displayed
WARNING_THRESHOLD='30' # Set energy limit in percent, where warning should be displayed
EMERGENCY_THRESHOLD='15' # Set energy limit in percent, where emergency should be displayed
LOCK_FILE='/var/lock/battery_state.lock' # Lock file location
PID_FILE="/run/user/${UID}/nagbar.pid" # Save pid for killing later
PID_FILE="/run/user/${UID}/nagbar.pid" # Save pid for killing later

# get battery status
get_status() {
Expand Down
Binary file modified screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0894eeb

Please sign in to comment.