Skip to content
Snippets Groups Projects
Commit 0c0e5f52 authored by Thomas Bellman's avatar Thomas Bellman
Browse files

Class for disabling suspend when closing laptop lid.

At least modern Fedora and RHEL versions by default suspend your
laptop when you close the lid.  Some people, including me, don't
like that behaviour.  Add a class console::lid::ignore_close that
disables that; currently only implements this for systemd-based
systems, though.

Whether this belongs in the console module is debatable, but at the
moment I don't have any better place to hide it.
parent 9216b504
No related branches found
No related tags found
No related merge requests found
# Copyright © 2017 Thomas Bellman, Linköping, Sweden
# Licensed under the GNU LGPL v3+; see the README file for more information.
/*
* Some systems are configured to suspend the machine when the laptop
* lid is being closed. This class disables that behaviour.
*
* Currently only implemented for systemd-based systems.
*/
class console::lid::ignore_close
{
case "${::osfamily}:${::operatingsystem}:${::initsystem}" {
/^.*:systemd$/: {
include console::lid::ignore_close::systemd
}
default: {
fail("Don't know how to disable suspend on lid close.")
}
}
}
# Helper for console::lid::ignore_close
class console::lid::ignore_close::systemd
{
augeas {
'console::lid::ignore_close::systemd':
incl => '/etc/systemd/logind.conf',
lens => 'Systemd.lns',
context => '/files/etc/systemd/logind.conf',
changes => [ 'set Login/HandleLidSwitch/value "ignore"' ],
notify => Service['systemd-logind'];
}
service {
'systemd-logind':
enable => true, ensure => running,
hasstatus => true, hasrestart => true;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment