summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changes3
-rw-r--r--MANIFEST2
-rw-r--r--META.json8
-rw-r--r--META.yml6
-rw-r--r--Makefile.PL2
-rw-r--r--lib/App/XScreenSaver/DBus.pm20
-rw-r--r--lib/App/XScreenSaver/DBus/Logind.pm (renamed from lib/App/XScreenSaver/DBus/InhibitSleep.pm)45
-rw-r--r--lib/App/XScreenSaver/DBus/Saver.pm6
-rw-r--r--lib/App/XScreenSaver/DBus/SaverProxy.pm4
-rwxr-xr-xscripts/xscreensaver-dbus6
-rw-r--r--t/00-compile.t2
-rw-r--r--t/author-pod-spell.t2
12 files changed, 70 insertions, 36 deletions
diff --git a/Changes b/Changes
index f8c6ca3..615dc8c 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+1.0.3 2021-05-06 15:16:13+01:00 Europe/London
+ - lock the screen when (e)logind says so
+
1.0.2 2021-05-01 11:47:33+01:00 Europe/London
- fix repository URL
diff --git a/MANIFEST b/MANIFEST
index 114e64c..ddfb4e9 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -7,7 +7,7 @@ META.yml
Makefile.PL
cpanfile
lib/App/XScreenSaver/DBus.pm
-lib/App/XScreenSaver/DBus/InhibitSleep.pm
+lib/App/XScreenSaver/DBus/Logind.pm
lib/App/XScreenSaver/DBus/Saver.pm
lib/App/XScreenSaver/DBus/SaverProxy.pm
perlcritic.rc
diff --git a/META.json b/META.json
index 59a3dbe..97d3bbb 100644
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
"Gianni Ceccarelli <dakkar@thenautilus.net>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150005",
+ "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010",
"license" : [
"agpl_3"
],
@@ -66,9 +66,9 @@
"web" : "https://www.thenautilus.net/cgit/xscreensaver-dbus/"
}
},
- "version" : "1.0.2",
- "x_generated_by_perl" : "v5.24.0",
- "x_serialization_backend" : "Cpanel::JSON::XS version 4.26",
+ "version" : "1.0.3",
+ "x_generated_by_perl" : "v5.32.0",
+ "x_serialization_backend" : "Cpanel::JSON::XS version 4.23",
"x_spdx_expression" : "AGPL-3.0"
}
diff --git a/META.yml b/META.yml
index 71bc53f..ef49f6a 100644
--- a/META.yml
+++ b/META.yml
@@ -10,7 +10,7 @@ build_requires:
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150005'
+generated_by: 'Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010'
license: open_source
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -37,7 +37,7 @@ requires:
warnings: '0'
resources:
repository: https://www.thenautilus.net/cgit/xscreensaver-dbus/
-version: 1.0.2
-x_generated_by_perl: v5.24.0
+version: 1.0.3
+x_generated_by_perl: v5.32.0
x_serialization_backend: 'YAML::Tiny version 1.73'
x_spdx_expression: AGPL-3.0
diff --git a/Makefile.PL b/Makefile.PL
index 688a711..3ea6d7d 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -41,7 +41,7 @@ my %WriteMakefileArgs = (
"IPC::Open3" => 0,
"Test::More" => 0
},
- "VERSION" => "1.0.2",
+ "VERSION" => "1.0.3",
"test" => {
"TESTS" => "t/*.t"
}
diff --git a/lib/App/XScreenSaver/DBus.pm b/lib/App/XScreenSaver/DBus.pm
index 86a6368..2a94677 100644
--- a/lib/App/XScreenSaver/DBus.pm
+++ b/lib/App/XScreenSaver/DBus.pm
@@ -4,10 +4,10 @@ use Moo;
use experimental qw(signatures postderef);
use Net::DBus::Reactor;
use Log::Any;
-use App::XScreenSaver::DBus::InhibitSleep;
+use App::XScreenSaver::DBus::Logind;
use App::XScreenSaver::DBus::Saver;
-our $VERSION = '1.0.2'; # VERSION
-# ABSTRACT: main application class
+our $VERSION = '1.0.3'; # VERSION
+# ABSTRACT: tie xscreensaver into dbus
has reactor => (
@@ -16,9 +16,9 @@ has reactor => (
);
-has inhibit_sleep => (
+has logind => (
is => 'lazy',
- builder => sub { App::XScreenSaver::DBus::InhibitSleep->new() },
+ builder => sub { App::XScreenSaver::DBus::Logind->new() },
);
@@ -34,7 +34,7 @@ has log => ( is => 'lazy', builder => sub { Log::Any->get_logger } );
sub run($self) {
- $self->inhibit_sleep->start();
+ $self->logind->start();
$self->saver->start();
$self->reactor->run;
}
@@ -49,11 +49,11 @@ __END__
=head1 NAME
-App::XScreenSaver::DBus - main application class
+App::XScreenSaver::DBus - tie xscreensaver into dbus
=head1 VERSION
-version 1.0.2
+version 1.0.3
=head1 SYNOPSIS
@@ -66,9 +66,9 @@ version 1.0.2
the event loop
-=head2 C<inhibit_sleep>
+=head2 C<logind>
-instance of L<< C<App::XScreenSaver::DBus::InhibitSleep> >>.
+instance of L<< C<App::XScreenSaver::DBus::Logind> >>.
=head2 C<saver>
diff --git a/lib/App/XScreenSaver/DBus/InhibitSleep.pm b/lib/App/XScreenSaver/DBus/Logind.pm
index 284ff47..0c2abee 100644
--- a/lib/App/XScreenSaver/DBus/InhibitSleep.pm
+++ b/lib/App/XScreenSaver/DBus/Logind.pm
@@ -1,4 +1,4 @@
-package App::XScreenSaver::DBus::InhibitSleep;
+package App::XScreenSaver::DBus::Logind;
use v5.20;
use Moo;
use experimental qw(signatures postderef);
@@ -6,8 +6,8 @@ use curry;
use Net::DBus;
use IPC::Run;
use Log::Any;
-our $VERSION = '1.0.2'; # VERSION
-# ABSTRACT: implements the logind "inhibitor locks" protocol
+our $VERSION = '1.0.3'; # VERSION
+# ABSTRACT: implements the logind "inhibitor locks" and "session lock" protocols
has bus => ( is => 'lazy', builder => sub { Net::DBus->system() } );
@@ -25,6 +25,15 @@ has logind_obj => (
);
+has session_obj => (
+ is => 'lazy',
+ builder => sub($self) {
+ my $session_path = $self->logind_obj->GetSessionByPID($$);
+ return $self->logind_srv->get_object($session_path);
+ },
+);
+
+
has inhibit_fd => ( is => 'rwp' );
@@ -36,6 +45,14 @@ sub start($self) {
'PrepareForSleep',
$self->curry::weak::_going_to_sleep,
);
+ $self->session_obj->connect_to_signal(
+ 'Lock',
+ $self->curry::weak::_lock,
+ );
+ $self->session_obj->connect_to_signal(
+ 'Unlock',
+ $self->curry::weak::_unlock,
+ );
$self->_inhibit();
return;
}
@@ -68,6 +85,16 @@ sub _going_to_sleep($self,$before) {
return;
}
+sub _lock($self) {
+ $self->log->debugf('locking the screen');
+ $self->_xscreensaver_command('-lock');
+}
+
+sub _unlock($self) {
+ $self->log->debugf('unlocking the screen');
+ $self->_xscreensaver_command('-deactivate');
+}
+
sub _xscreensaver_command($self,$command) {
my ($out, $err);
IPC::Run::run(
@@ -89,17 +116,17 @@ __END__
=head1 NAME
-App::XScreenSaver::DBus::InhibitSleep - implements the logind "inhibitor locks" protocol
+App::XScreenSaver::DBus::Logind - implements the logind "inhibitor locks" and "session lock" protocols
=head1 VERSION
-version 1.0.2
+version 1.0.3
=head1 SYNOPSIS
use Net::DBus::Reactor;
- use App::XScreenSaver::DBus::InhibitSleep;
- my $is = App::XScreenSaver::DBus::InhibitSleep->new;
+ use App::XScreenSaver::DBus::Logind;
+ my $is = App::XScreenSaver::DBus::Logind->new;
$is->start;
Net::DBus::Reactor->new->run;
@@ -118,6 +145,10 @@ the (e)logind DBus service
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
diff --git a/lib/App/XScreenSaver/DBus/Saver.pm b/lib/App/XScreenSaver/DBus/Saver.pm
index 196c418..ab6339a 100644
--- a/lib/App/XScreenSaver/DBus/Saver.pm
+++ b/lib/App/XScreenSaver/DBus/Saver.pm
@@ -7,7 +7,7 @@ use Log::Any;
use Try::Tiny;
use IPC::Run;
use App::XScreenSaver::DBus::SaverProxy;
-our $VERSION = '1.0.2'; # VERSION
+our $VERSION = '1.0.3'; # VERSION
# ABSTRACT: implements the "idle inhibition" protocol
@@ -67,7 +67,7 @@ sub start($self) {
$self->_prod_id(
$self->reactor->add_timeout(
- 5_000,
+ 60_000,
Net::DBus::Callback->new(
method => $self->curry::weak::_prod_screensaver
),
@@ -172,7 +172,7 @@ App::XScreenSaver::DBus::Saver - implements the "idle inhibition" protocol
=head1 VERSION
-version 1.0.2
+version 1.0.3
=head1 SYNOPSIS
diff --git a/lib/App/XScreenSaver/DBus/SaverProxy.pm b/lib/App/XScreenSaver/DBus/SaverProxy.pm
index 10fbb99..250d709 100644
--- a/lib/App/XScreenSaver/DBus/SaverProxy.pm
+++ b/lib/App/XScreenSaver/DBus/SaverProxy.pm
@@ -6,7 +6,7 @@ use experimental qw(signatures postderef);
# this is the interface name
use Net::DBus::Exporter qw(org.freedesktop.ScreenSaver);
use parent 'Net::DBus::Object';
-our $VERSION = '1.0.2'; # VERSION
+our $VERSION = '1.0.3'; # VERSION
# ABSTRACT: proxy dbus object
@@ -49,7 +49,7 @@ App::XScreenSaver::DBus::SaverProxy - proxy dbus object
=head1 VERSION
-version 1.0.2
+version 1.0.3
=head1 DESCRIPTION
diff --git a/scripts/xscreensaver-dbus b/scripts/xscreensaver-dbus
index 92ef192..51ed55e 100755
--- a/scripts/xscreensaver-dbus
+++ b/scripts/xscreensaver-dbus
@@ -1,10 +1,10 @@
-#!/usr/bin/env perl
+#!/usr/bin/perl
use strict;
use warnings;
use v5.20;
use Log::Any::Adapter Stdout => ( log_level => 'debug' );
use App::XScreenSaver::DBus;
-our $VERSION = '1.0.2'; # VERSION
+our $VERSION = '1.0.3'; # VERSION
# PODNAME: xscreensaver-dbus
# ABSTRACT: tie xscreensaver into dbus
@@ -23,7 +23,7 @@ xscreensaver-dbus - tie xscreensaver into dbus
=head1 VERSION
-version 1.0.2
+version 1.0.3
=head1 SYNOPSIS
diff --git a/t/00-compile.t b/t/00-compile.t
index 7421167..e810134 100644
--- a/t/00-compile.t
+++ b/t/00-compile.t
@@ -10,7 +10,7 @@ plan tests => 5 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'App/XScreenSaver/DBus.pm',
- 'App/XScreenSaver/DBus/InhibitSleep.pm',
+ 'App/XScreenSaver/DBus/Logind.pm',
'App/XScreenSaver/DBus/Saver.pm',
'App/XScreenSaver/DBus/SaverProxy.pm'
);
diff --git a/t/author-pod-spell.t b/t/author-pod-spell.t
index e3d5969..0da45ac 100644
--- a/t/author-pod-spell.t
+++ b/t/author-pod-spell.t
@@ -22,7 +22,7 @@ App
Ceccarelli
DBus
Gianni
-InhibitSleep
+Logind
Saver
SaverProxy
XScreenSaver