diff --git a/batsignal.1.in b/batsignal.1.in index 4729268..e9d4fbc 100644 --- a/batsignal.1.in +++ b/batsignal.1.in @@ -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 diff --git a/main.c b/main.c index 6529f13..8faba10 100644 --- a/main.c +++ b/main.c @@ -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\ @@ -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, @@ -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(); } } diff --git a/options.c b/options.c index de2508e..ac40043 100644 --- a/options.c +++ b/options.c @@ -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; @@ -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; diff --git a/options.h b/options.h index b5f6389..401e5aa 100644 --- a/options.h +++ b/options.h @@ -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;