diff options
Diffstat (limited to 'lib/App/XScreenSaver')
-rw-r--r-- | lib/App/XScreenSaver/DBus/InhibitSleep.pm | 16 | ||||
-rw-r--r-- | lib/App/XScreenSaver/DBus/Saver.pm | 12 |
2 files changed, 24 insertions, 4 deletions
diff --git a/lib/App/XScreenSaver/DBus/InhibitSleep.pm b/lib/App/XScreenSaver/DBus/InhibitSleep.pm index ce205a7..226facf 100644 --- a/lib/App/XScreenSaver/DBus/InhibitSleep.pm +++ b/lib/App/XScreenSaver/DBus/InhibitSleep.pm @@ -4,6 +4,7 @@ use Moo; use experimental qw(signatures postderef); use curry; use Net::DBus; +use IPC::Run; use Log::Any; # VERSION # ABSTRACT: implements the logind "inhibitor locks" protocol @@ -96,16 +97,27 @@ sub _inhibit($self) { sub _going_to_sleep($self,$before) { if ($before) { $self->log->debug('locking'); - system(qw(xscreensaver-command -suspend)); + $self->_xscreensaver_command('-suspend'); $self->log->debug('locked'); $self->_set_inhibit_fd(undef); } else { $self->log->debug('woken up'); - system(qw(xscreensaver-command -deactivate)); + $self->_xscreensaver_command('-deactivate'); $self->_inhibit(); } return; } +sub _xscreensaver_command($self,$command) { + my ($out, $err); + IPC::Run::run( + ['xscreensaver-command',$command], + \undef, \$out, \$err, + ); + $self->log->tracef('xscreensaver-command %s said <%s>',$command,$out); + $self->log->warnf('xscreensaver-command %s errored <%s>',$command,$err) + if $err; +} + 1; diff --git a/lib/App/XScreenSaver/DBus/Saver.pm b/lib/App/XScreenSaver/DBus/Saver.pm index 9d30abd..6c3e761 100644 --- a/lib/App/XScreenSaver/DBus/Saver.pm +++ b/lib/App/XScreenSaver/DBus/Saver.pm @@ -5,6 +5,7 @@ use experimental qw(signatures postderef); use curry; use Log::Any; use Try::Tiny; +use IPC::Run; use App::XScreenSaver::DBus::SaverProxy; # VERSION # ABSTRACT: implements the "idle inhibition" protocol @@ -125,7 +126,7 @@ sub start($self) { $self->_prod_id( $self->reactor->add_timeout( - 60_000, + 5_000, Net::DBus::Callback->new( method => $self->curry::weak::_prod_screensaver ), @@ -206,7 +207,14 @@ sub _name_owner_changed($self,$bus_name,$old,$new) { sub _prod_screensaver($self) { $self->log->debug('prodding xscreensaver'); - system(qw(xscreensaver-command -deactivate)); + my ($out, $err); + IPC::Run::run( + [qw(xscreensaver-command -deactivate)], + \undef, \$out, \$err, + ); + $self->log->tracef('xscreensaver-command -deactivate said <%s>',$out); + $self->log->warnf('xscreensaver-command -deactivate errored <%s>',$err) + if $err; } 1; |