Skip to content
Snippets Groups Projects
Commit ea50784b authored by Zámolyi Csaba Ferenc's avatar Zámolyi Csaba Ferenc
Browse files

Added config options for HID battery actions

parent 4b0ec900
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ The tresholds and the actions to take are both configurable in `/etc/systemcshee ...@@ -15,7 +15,7 @@ The tresholds and the actions to take are both configurable in `/etc/systemcshee
Why not? It was a long and rough day and around 2AM, after 5-6 beers, it seemed to be a good idea to Why not? It was a long and rough day and around 2AM, after 5-6 beers, it seemed to be a good idea to
write a daemon for a task I wanted, but mostly for my personal amusement. write a daemon for a task I wanted, but mostly for my personal amusement.
This is generally intended as a joke, although for me it serves real purpose. This is generally intended as a joke, although for me it serves real purpose.
I didn't want to use any 3rd party service for monitoring my battery level, I didn't want to use any 3rd party service for monitoring my battery level(s),
because I know exactly what I want and how I want to do it and what configuration options I wish. because I know exactly what I want and how I want to do it and what configuration options I wish.
Obviously this could have been done with a shell script in a cronjob, but it's not that fun. Obviously this could have been done with a shell script in a cronjob, but it's not that fun.
The task seemed easy enough to do for myself. This wants to be a small and easily usable software, and The task seemed easy enough to do for myself. This wants to be a small and easily usable software, and
...@@ -23,6 +23,11 @@ it would be really fun if other people used it or did something with it :slight_ ...@@ -23,6 +23,11 @@ it would be really fun if other people used it or did something with it :slight_
Also, this is for learning in a fun, but somewhat productive way. Also, this is for learning in a fun, but somewhat productive way.
### Features
For system batteries you can configure three different tresholds (half, low, critical) and for each a corresponding action to take in the config file. For any treshold you can choose ignore it, get a notification, sleep or shut down the system.
You can also monitor your wireless keyboard and/or mouse. At this time, only one device is supported, but later I want to add support for monitoring multiple wireless or other battery powered devices as well. `batteryd` can notify you if your keyboard or mouse is going to run out of power soon. You most probably want to get a notification, but nothing stops you from configuring sleep or shutdown for it as well :slight_smile:
### Configuration ### Configuration
`batteryd` can be configured with a `batteryd.conf` file located at `/etc/systemcshee/batteryd.conf` `batteryd` can be configured with a `batteryd.conf` file located at `/etc/systemcshee/batteryd.conf`
......
...@@ -4,40 +4,66 @@ ...@@ -4,40 +4,66 @@
# LICENSE: GNU GPL v3.0 # LICENSE: GNU GPL v3.0
# #
# #
# There are three available battery levels: HALF, LOW, CRITICAL and their percentage value can be configured # There are three available battery levels: HALF, LOW, CRITICAL
# The values must be between 0 and 100 (although using 0 would not make much sense) # and their percentage value can be configured.
# The values must be between 0 and 100 (but using 0 would not make sense)
# The following has to be true for a valid configuration: # The following has to be true for a valid configuration:
# TRESHOLD_HALF > TRESHOLD_LOW > TRESHOLD_CRITICAL # TRESHOLD_HALF > TRESHOLD_LOW > TRESHOLD_CRITICAL
# #
# The actions can be as follows: # The actions can be as follows:
# - "ignore": it does not do any action, and skips all other actions supplied for the given battery level. # - "ignore": it does not do any action, and skips all other actions
# If no action is supplied for a level, batteryd will default to "ignore" # supplied for the given battery level. If no action is
# - "notify": sends a notification to the user and informs them about the battery percentage via notify-send # supplied for a level, batteryd will default to "ignore".
# - "sleep": suspends system to RAM after a configured amount of time. (WAIT_TIME_SLEEP) # - "notify": sends a notification to the user and informs them about
# - "shutdown": gracefully shuts down the system after a configured amount of time. (WAIT_TIME_SHUTDOWN) # the battery percentage via notify-send.
# You can assign more actions to a battery level, separated by commas (no trailing comma and whitespace after comma allowed) # - "sleep": suspends system to RAM after a configured amount of time.
# The daemon will execute the actions in the order they are specified so "shutdown,notify" will not make any sense # (WAIT_TIME_SLEEP)
# if WAIT_TIME_SHUTDOWN is set to 0 # - "shutdown": gracefully shuts down the system after a configured
# amount of time. (WAIT_TIME_SHUTDOWN)
#
# You can assign more actions to a battery level, separated by commas
# (no trailing comma and whitespace after commas allowed).
# For example: ACTION_CRITICAL="notify,shutdown"
#
# The daemon will execute the actions in the order they are specified in,
# so "shutdown,notify" may not make any sense if
# WAIT_TIME_SHUTDOWN is set to 0
#
# If a "shutdown" or "sleep" action has been started, but in the meantime
# a charger was connected, the action is immediately aborted and the user
# is sent a notification that the sleep or shutdown has been cancelled.
# System battery name (/sys/class/power_supply/<name>, defaults to BAT0)
SYSTEM_BATTERY_NAME=BAT0
# HALF battery percentage treshold (usually 50%, but who knows!) # HID battery name (/sys/class/power_supply/<name>)
# Uncomment this option to monitor you battery powered HID
# HID_BATTERY_NAME=
# HALF battery percentage treshold (defaults to 50, but who knows!)
TRESHOLD_HALF=50 TRESHOLD_HALF=50
# Action(s) to do at HALF battery # Action(s) to do at HALF battery (defaults to ignore)
ACTION_HALF="notify" ACTION_HALF="notify"
# LOW battery percentage treshold (0-100) # LOW battery percentage treshold (0-100, defaults to 30)
TRESHOLD_LOW=30 TRESHOLD_LOW=30
# Action(s) to do at LOW battery # Action(s) to do at LOW battery (defaults to ignore)
ACTION_LOW="notify" ACTION_LOW="ignore"
# CRITICAL battery percentage treshold (0-100) # CRITICAL battery percentage treshold (0-100)
TRESHOLD_CRITICAL=15 TRESHOLD_CRITICAL=15
# Action(s) to do at CRITICAL battery # Action(s) to do at CRITICAL battery (defaults to notify)
ACTION_CRITICAL="notify,sleep" ACTION_CRITICAL="notify"
# Action(s) to do when HID battery is low (defaults to ignore)
ACTION_HID_LOW="ignore"
# Action(s) to do when HID battery is critical (defaults to notify)
ACTION_HID_CRITICAL="notify"
# Waiting times for actions (in seconds, maximum of 300) # Waiting times for actions (in seconds, maximum of 300)
# Waiting time for "sleep" action # Waiting time for "sleep" action (default is 30)
WAIT_TIME_SLEEP=30 WAIT_TIME_SLEEP=30
# Waiting time for "shutdown" action # Waiting time for "shutdown" action (default is 60)
WAIT_TIME_SHUTDOWN=60 WAIT_TIME_SHUTDOWN=60
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment