commit de9fb1cd473b1a3a8044dcfe6ee7e774c8971f4a from: mischa date: Mon Jun 05 16:28:06 2023 UTC add sections to config file, supporting multiple pushover apps in the same config file commit - fc2d48d2bb7ae09b42afed03e02d7162eb3c564c commit + de9fb1cd473b1a3a8044dcfe6ee7e774c8971f4a blob - c2826956e241b5d1f6d26591012727acf5dc7362 blob + 3ea5f019c672a9ebf9a3dde2fbdd6368a4edcbbf --- pushover.conf-example +++ pushover.conf-example @@ -1,2 +1,8 @@ token = TOKENTOKEN user = USERUSER +[pushover application] +token = TOKENTOKEN +user = USERUSER +[application] +token = TOKENTOKEN +user = USERUSER blob - 551a02b1a0696392d9f0709fe7eac42ddf9a50fc blob + 6297c433590b0bfe34270619bda6a8a6e33ce33a --- pushover.pl +++ pushover.pl @@ -28,22 +28,24 @@ GetOptions( "title=s" => \(my $TITLE = "Notification"), "priority=i" => \(my $PRIORITY = 0), "config=s" => \(my $CONFIG), + "application=s" => \(my $APPLICATION = '_'), ); my $USAGE = <<"END_USAGE"; -Usage: $0 [-m message] [-t title] [-p priority] +Usage: $0 -m message [-t title] [-p priority] [-a application] [-c config] Options: --m | --message text --t | --title text (default: Notification) --p | --priority [0|1] (default: 0) --c | --config text +-m | --message text +-t | --title text | (default: Notification) +-p | --priority [0|1] (default: 0) +-a | --application text (default: root property of config) +-c | --config text (no default) END_USAGE $MESSAGE || die($USAGE); my @config_files = $CONFIG || grep { -e } ('./_pushover.conf', './.pushover.conf', './pushover.conf', "$ENV{'HOME'}/_pushover.conf", "$ENV{'HOME'}/.pushover.conf", "$ENV{'HOME'}/pushover.conf"); my $config = Config::Tiny->read($config_files[-1], 'utf8'); -my $TOKEN = $config->{_}->{token} || die("$USAGE\nError: TOKEN not found.\n"); -my $USER = $config->{_}->{user} || die("$USAGE\nError: USER not found.\n"); +my $TOKEN = $config->{$APPLICATION}->{token} || die("$USAGE\nError: TOKEN not found.\n"); +my $USER = $config->{$APPLICATION}->{user} || die("$USAGE\nError: USER not found.\n"); my $http = HTTP::Tiny->new; my %HEADERS = ("Content-Type" => "application/json");