Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions batsignal.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ Battery danger LEVEL (default 2). 0 disables this level
.B \-f LEVEL
Battery full LEVEL (default 0). 0 disables this level
.TP
.B \-q
Show the battery full notification only once per charge cycle
.TP
.B \-p
Show a message when the battery begins charging or discharging
.TP
Expand Down
6 changes: 5 additions & 1 deletion main.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Options:\n\
(default: 2)\n\
-f LEVEL full battery LEVEL\n\
(default: disabled)\n\
-q show battery full notification once\n\
-p show message when battery begins charging/discharging\n\
-W MESSAGE show MESSAGE when battery is at warning level\n\
-C MESSAGE show MESSAGE when battery is at critical level\n\
Expand Down Expand Up @@ -105,6 +106,7 @@ int main(int argc, char *argv[])
.battery_required = true,
.show_notifications = true,
.show_charging_msg = false,
.show_battery_full_once = false,
.help = false,
.version = false,
.battery_names = NULL,
Expand Down Expand Up @@ -229,7 +231,9 @@ int main(int argc, char *argv[])
notify(config.chargingmsg, NOTIFY_URGENCY_NORMAL, battery);

} else {
battery.state = STATE_AC;
if (!config.show_battery_full_once || battery.state != STATE_FULL) {
battery.state = STATE_AC;
}
close_notification();
}
}
Expand Down
5 changes: 4 additions & 1 deletion options.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void parse_args(int argc, char *argv[], Config *config)
signed int c;
optind = 1;

while ((c = getopt(argc, argv, ":hvboiew:c:d:f:pW:C:D:F:P:U:M:Nn:m:a:I:")) != -1) {
while ((c = getopt(argc, argv, ":hvboiew:c:d:f:qpW:C:D:F:P:U:M:Nn:m:a:I:")) != -1) {
switch (c) {
case 'h':
config->help = true;
Expand Down Expand Up @@ -173,6 +173,9 @@ void parse_args(int argc, char *argv[], Config *config)
config->full = strtoul(optarg, NULL, 10);
config->fixed = true;
break;
case 'q':
config->show_battery_full_once = true;
break;
case 'p':
config->show_charging_msg = 1;
config->fixed = true;
Expand Down
1 change: 1 addition & 0 deletions options.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ typedef struct Config {
bool battery_required;
bool show_notifications;
bool show_charging_msg;
bool show_battery_full_once;
bool help;
bool version;

Expand Down