diff options
Diffstat (limited to 'lib/App/XScreenSaver')
-rw-r--r-- | lib/App/XScreenSaver/DBus.pm | 91 | ||||
-rw-r--r-- | lib/App/XScreenSaver/DBus/Logind.pm | 119 | ||||
-rw-r--r-- | lib/App/XScreenSaver/DBus/Saver.pm | 144 | ||||
-rw-r--r-- | lib/App/XScreenSaver/DBus/SaverProxy.pm | 30 |
4 files changed, 244 insertions, 140 deletions
diff --git a/lib/App/XScreenSaver/DBus.pm b/lib/App/XScreenSaver/DBus.pm index e36d0b6..907739f 100644 --- a/lib/App/XScreenSaver/DBus.pm +++ b/lib/App/XScreenSaver/DBus.pm @@ -6,41 +6,21 @@ use Net::DBus::Reactor; use Log::Any; use App::XScreenSaver::DBus::Logind; use App::XScreenSaver::DBus::Saver; -# VERSION +our $VERSION = '1.0.5'; # VERSION # ABSTRACT: tie xscreensaver into dbus -=head1 SYNOPSIS - - use App::XScreenSaver::DBus; - App::XScreenSaver::DBus->new->run; - -=attr C<reactor> - -the event loop - -=cut has reactor => ( is => 'lazy', builder => sub { Net::DBus::Reactor->main() }, ); -=attr C<logind> - -instance of L<< C<App::XScreenSaver::DBus::Logind> >>. - -=cut has logind => ( is => 'lazy', builder => sub { App::XScreenSaver::DBus::Logind->new() }, ); -=attr C<saver> - -instance of L<< C<App::XScreenSaver::DBus::Saver> >>. - -=cut has saver => ( is => 'lazy', @@ -49,20 +29,9 @@ has saver => ( }, ); -=attr C<log> - -a logger - -=cut has log => ( is => 'lazy', builder => sub { Log::Any->get_logger } ); -=method C<run> - -registers the DBus services and runs the event loop; this method does -not return - -=cut sub run($self) { $self->logind->start(); @@ -71,3 +40,61 @@ sub run($self) { } 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +App::XScreenSaver::DBus - tie xscreensaver into dbus + +=head1 VERSION + +version 1.0.5 + +=head1 SYNOPSIS + + use App::XScreenSaver::DBus; + App::XScreenSaver::DBus->new->run; + +=head1 ATTRIBUTES + +=head2 C<reactor> + +the event loop + +=head2 C<logind> + +instance of L<< C<App::XScreenSaver::DBus::Logind> >>. + +=head2 C<saver> + +instance of L<< C<App::XScreenSaver::DBus::Saver> >>. + +=head2 C<log> + +a logger + +=head1 METHODS + +=head2 C<run> + +registers the DBus services and runs the event loop; this method does +not return + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2021 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software, licensed under: + + The GNU Affero General Public License, Version 3, November 2007 + +=cut diff --git a/lib/App/XScreenSaver/DBus/Logind.pm b/lib/App/XScreenSaver/DBus/Logind.pm index 21b3fb7..45de75f 100644 --- a/lib/App/XScreenSaver/DBus/Logind.pm +++ b/lib/App/XScreenSaver/DBus/Logind.pm @@ -6,53 +6,24 @@ use curry; use Net::DBus; use IPC::Run; use Log::Any; -# VERSION +our $VERSION = '1.0.5'; # VERSION # ABSTRACT: implements the logind "inhibitor locks" and "session lock" protocols -=head1 SYNOPSIS - - use Net::DBus::Reactor; - use App::XScreenSaver::DBus::Logind; - my $is = App::XScreenSaver::DBus::Logind->new; - $is->start; - - Net::DBus::Reactor->new->run; - -=attr C<bus> - -the DBus system bus - -=cut has bus => ( is => 'lazy', builder => sub { Net::DBus->system() } ); -=attr C<logind_srv> - -the (e)logind DBus service - -=cut has logind_srv => ( is => 'lazy', builder => sub { shift->bus->get_service('org.freedesktop.login1') }, ); -=attr C<logind_obj> - -the (e)logind DBus object - -=cut has logind_obj => ( is => 'lazy', builder => sub { shift->logind_srv->get_object('/org/freedesktop/login1') }, ); -=attr C<session_obj> - -the (e)logind session DBus object - -=cut has session_obj => ( is => 'lazy', @@ -62,29 +33,12 @@ has session_obj => ( }, ); -=attr C<inhibit_fd> - -the file descriptor that logind gives us when we ask for a lock; we -close it to release the lock - -=cut has inhibit_fd => ( is => 'rwp' ); -=attr C<log> - -a logger - -=cut has log => ( is => 'lazy', builder => sub { Log::Any->get_logger } ); -=method C<start> - -starts listening to the C<PrepareForSleep> signal from (e)logind, and -takes the lock - -=cut sub start($self) { $self->logind_obj->connect_to_signal( @@ -153,3 +107,74 @@ sub _xscreensaver_command($self,$command) { } 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +App::XScreenSaver::DBus::Logind - implements the logind "inhibitor locks" and "session lock" protocols + +=head1 VERSION + +version 1.0.5 + +=head1 SYNOPSIS + + use Net::DBus::Reactor; + use App::XScreenSaver::DBus::Logind; + my $is = App::XScreenSaver::DBus::Logind->new; + $is->start; + + Net::DBus::Reactor->new->run; + +=head1 ATTRIBUTES + +=head2 C<bus> + +the DBus system bus + +=head2 C<logind_srv> + +the (e)logind DBus service + +=head2 C<logind_obj> + +the (e)logind DBus object + +=head2 C<session_obj> + +the (e)logind session DBus object + +=head2 C<inhibit_fd> + +the file descriptor that logind gives us when we ask for a lock; we +close it to release the lock + +=head2 C<log> + +a logger + +=head1 METHODS + +=head2 C<start> + +starts listening to the C<PrepareForSleep> signal from (e)logind, and +takes the lock + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2021 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software, licensed under: + + The GNU Affero General Public License, Version 3, November 2007 + +=cut diff --git a/lib/App/XScreenSaver/DBus/Saver.pm b/lib/App/XScreenSaver/DBus/Saver.pm index c6df80d..c36bece 100644 --- a/lib/App/XScreenSaver/DBus/Saver.pm +++ b/lib/App/XScreenSaver/DBus/Saver.pm @@ -7,63 +7,27 @@ use Log::Any; use Try::Tiny; use IPC::Run; use App::XScreenSaver::DBus::SaverProxy; -# VERSION +our $VERSION = '1.0.5'; # VERSION # ABSTRACT: implements the "idle inhibition" protocol -=head1 SYNOPSIS - - use Net::DBus::Reactor; - use App::XScreenSaver::DBus::InhibitSleep; - - my $reactor = Net::DBus::Reactor->new; - my $s = App::XScreenSaver::DBus::Saver->new(reactor => $reactor); - $s->start; - - $reactor->run; - -=attr C<reactor> - -the event loop - -=cut has reactor => ( is => 'ro', required => 1 ); -=attr C<bus> - -the DBus session bus - -=cut has bus => ( is => 'lazy', builder => sub { Net::DBus->session() } ); -=attr C<dbus_srv> - -the DBus manager DBus service - -=cut has dbus_srv => ( is => 'lazy', builder => sub { shift->bus->get_service('org.freedesktop.DBus') }, ); -=attr C<dbus_obj> - -the DBus manager DBus object - -=cut has dbus_obj => ( is => 'lazy', builder => sub { shift->dbus_srv->get_object('/org/freedesktop/DBus') }, ); -=attr C<service> - -the DBus service we export - -=cut has service => ( is => 'lazy', @@ -73,25 +37,12 @@ has service => ( }, ); -=attr C<paths> - -the paths at which we export our DBus object - -there's two of them because different applications expect this object -at different paths - -=cut has paths => ( is => 'ro', default => sub { [qw(/ScreenSaver /org/freedesktop/ScreenSaver)] }, ); -=attr C<log> - -a logger - -=cut has log => ( is => 'lazy', builder => sub { Log::Any->get_logger } ); @@ -99,16 +50,6 @@ has _proxies => ( is => 'rw' ); has _prod_id => ( is => 'rw' ); has _inhibits => ( is => 'rw', default => sub { +{} } ); -=method C<start> - -Exports our object to the session bus, and starts listening for -C<NameOwnerChanged> events. - -Those events are emitted when a client attaches or detaches from the -bus. A client may die before releasing the idle inhibition, so we want -to be notified when that happens, and release that inhibition. - -=cut sub start($self) { # export to dbus @@ -212,3 +153,86 @@ sub _prod_screensaver($self) { } 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +App::XScreenSaver::DBus::Saver - implements the "idle inhibition" protocol + +=head1 VERSION + +version 1.0.5 + +=head1 SYNOPSIS + + use Net::DBus::Reactor; + use App::XScreenSaver::DBus::InhibitSleep; + + my $reactor = Net::DBus::Reactor->new; + my $s = App::XScreenSaver::DBus::Saver->new(reactor => $reactor); + $s->start; + + $reactor->run; + +=head1 ATTRIBUTES + +=head2 C<reactor> + +the event loop + +=head2 C<bus> + +the DBus session bus + +=head2 C<dbus_srv> + +the DBus manager DBus service + +=head2 C<dbus_obj> + +the DBus manager DBus object + +=head2 C<service> + +the DBus service we export + +=head2 C<paths> + +the paths at which we export our DBus object + +there's two of them because different applications expect this object +at different paths + +=head2 C<log> + +a logger + +=head1 METHODS + +=head2 C<start> + +Exports our object to the session bus, and starts listening for +C<NameOwnerChanged> events. + +Those events are emitted when a client attaches or detaches from the +bus. A client may die before releasing the idle inhibition, so we want +to be notified when that happens, and release that inhibition. + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2021 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software, licensed under: + + The GNU Affero General Public License, Version 3, November 2007 + +=cut diff --git a/lib/App/XScreenSaver/DBus/SaverProxy.pm b/lib/App/XScreenSaver/DBus/SaverProxy.pm index 69a689c..af4ec17 100644 --- a/lib/App/XScreenSaver/DBus/SaverProxy.pm +++ b/lib/App/XScreenSaver/DBus/SaverProxy.pm @@ -5,10 +5,38 @@ use warnings; # this is the interface name use Net::DBus::Exporter qw(org.freedesktop.ScreenSaver); use parent 'Net::DBus::ProxyObject'; -# VERSION +our $VERSION = '1.0.5'; # VERSION # ABSTRACT: proxy dbus object dbus_method('Inhibit',['string','string','caller'],['uint32']); dbus_method('UnInhibit',['uint32','caller'],[]); 1; + +__END__ + +=pod + +=encoding UTF-8 + +=head1 NAME + +App::XScreenSaver::DBus::SaverProxy - proxy dbus object + +=head1 VERSION + +version 1.0.5 + +=head1 AUTHOR + +Gianni Ceccarelli <dakkar@thenautilus.net> + +=head1 COPYRIGHT AND LICENSE + +This software is Copyright (c) 2021 by Gianni Ceccarelli <dakkar@thenautilus.net>. + +This is free software, licensed under: + + The GNU Affero General Public License, Version 3, November 2007 + +=cut |