diff --git a/pushover.conf-example b/pushover.conf-example index c282695..3ea5f01 100644 --- a/pushover.conf-example +++ b/pushover.conf-example @@ -1,2 +1,8 @@ token = TOKENTOKEN user = USERUSER +[pushover application] +token = TOKENTOKEN +user = USERUSER +[application] +token = TOKENTOKEN +user = USERUSER diff --git a/pushover.pl b/pushover.pl index 551a02b..6297c43 100755 --- a/pushover.pl +++ b/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");