PowerManagement::Any - Common interface to some power management tasks
This document describes version 0.006 of PowerManagement::Any (from Perl distribution PowerManagement-Any), released on 2019-06-10.
Usage:
prevent_sleep() -> [status, msg, payload, meta]
Prevent system from sleeping.
Will also prevent system from hybrid sleeping, suspending, or hibernating. The effect is permanent (survives reboot); you need to unprevent_sleep() to reverse the effect.
unprevent_sleep()
Note that this does not prevent screen blanking or locking (screensaver activating); see Screensaver::Any for routines that disable screensaver.
On systems that run Systemd, this is implemented by masking sleep.target. It automatically also prevents suspend.target, hybrid-sleep.target, and hibernate.target from activating. (Note that masking systemd-suspend.service should also achieve the same result.)
sleep.target
suspend.target
hybrid-sleep.target
hibernate.target
systemd-suspend.service
Not implemented yet for other systems. Patches welcome.
This function is not exported by default, but exportable.
No arguments.
Returns an enveloped result (an array).
First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (payload) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.
Return value: (any)
sleep_is_prevented(%args) -> [status, msg, payload, meta]
Check if sleep has been prevented.
The CLI return exit code 0 if sleep has been prevented.
See prevent_sleep() for more details.
prevent_sleep()
Arguments ('*' denotes required arguments):
quiet => true
Don't output anything on command-line, just return appropriate exit code.
unprevent_sleep() -> [status, msg, payload, meta]
Reverse the effect of prevent_sleep().
Please visit the project's homepage at https://metacpan.org/release/PowerManagement-Any.
Source repository is at https://github.com/perlancar/perl-PowerManagement-Any.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=PowerManagement-Any
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2019 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install PowerManagement::Any, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PowerManagement::Any
CPAN shell
perl -MCPAN -e shell install PowerManagement::Any
For more information on module installation, please visit the detailed CPAN module installation guide.