App-Notifier-Service

 view release on metacpan or  search on metacpan

lib/App/Notifier/Service.pm  view on Meta::CPAN

            # I'm the child.
            if ( fork() eq 0 )
            {
                # I'm the grandchild.
                system { $cmd_line[0] } @cmd_line;
            }
            POSIX::_exit(0);
        }
        else
        {
            waitpid( $pid, 0 );
        }
        $c->render( text => "Success.\n" );
    }
    else
    {
        $c->log("Unknown Command ID '$cmd_id'.");
        return "Unknown Command ID.\n";
    }
};

get '/' => sub {
    my $c = shift;
    $c->render( text => "OK\n" );
};

builder
{
    # enable 'Deflater';
    app->start;
};

# "true";

# start;

__END__

=pod

=encoding utf-8

=head1 NAME

App::Notifier::Service - an HTTP service for the notifier application for
notifying that an event (such as the finish of a task) occured.

=head1 VERSION

version 0.0902

=head1 SYNOPSIS

    # Prepare a YAML file in ~/.app_notifier.yml with content like this:

    $ cat <<EOF > ~/.app_notifier.yml
    commands:
        # These entries contain command lines that get invoked after the
        # notification is received. They can be either strings or arrays.
        default:
            - /home/shlomif/bin/desktop-finish-cue
        shine:
            - /home/shlomif/bin/desktop-finish-cue
            - "--song"
            - "/home/music/Music/dosd-mp3s/Carmen and Camille - Shine 4U"
            - "--message"
            - type: "text_param"
              param_name: "msg"
    EOF

    # Run the Mojo application from the distribution's root directory.
    plackup ./bin/app.psgi

    # Alternatively run the following Perl code:
    use App::Notifier::Service;
    start;

    # When you want to notify that an event occured:
    $ curl 'http://127.0.0.1:3000/notify'
    $ curl 'http://127.0.0.1:3000/notify?cmd_id=shine'

=head1 AUTHOR

Shlomi Fish, L<https://www.shlomifish.org/> .

=head1 ACKNOWLEDGEMENTS

=head1 COPYRIGHT & LICENSE

Copyright 2012 Shlomi Fish.

This program is distributed under the MIT (X11) License:
L<http://www.opensource.org/licenses/mit-license.php>

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan

=head1 SUPPORT

=head2 Websites

The following websites have more information about this module, and may be of help to you. As always,
in addition to those websites please use your favorite search engine to discover more resources.



( run in 0.934 second using v1.01-cache-2.11-cpan-d7f47b0818f )