LoginSignup
16
14

More than 5 years have passed since last update.

Linux(systemd)を入れたノートPCを、閉じてもサスペンドさせないようにする

Posted at

完全に自分用備忘録です。
毎度毎度忘れるんですよねえ。

早速本題へ入ります。
使うのはみんな大好きCentOS7.1
設定変更するファイルは /etc/systemd/logind.conf になります。

中身はこんな感じですね。

/etc/systemd/logind.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# See logind.conf(5) for details

[Login]
#NAutoVTs=6
#ReserveVT=6
#KillUserProcesses=no
#KillOnlyUsers=
#KillExcludeUsers=root
#InhibitDelayMaxSec=5
#HandlePowerKey=poweroff
#HandleSuspendKey=suspend
#HandleHibernateKey=hibernate
#HandleLidSwitch=suspend
#PowerKeyIgnoreInhibited=no
#SuspendKeyIgnoreInhibited=no
#HibernateKeyIgnoreInhibited=no
#LidSwitchIgnoreInhibited=yes
#IdleAction=ignore
#IdleActionSec=30min

全部コメントアウトされていますね。
この中にある HandleLidSwitch の設定を変更します。
元々コメントアウトしているので新たに追記してしまっても構いません。

私はファイルを弄るのが面倒なので、一旦コピーを取ってからリダイレクトで新たに追記してしまいます。
「追記はしたくない!」って方は直接ファイル弄るなりsedを使うなりしてください。

$ cp -ip /etc/systemd/logind.confs{,.orig}
$ echo -e "\n###added 2015/10/01\nHandleLidSwitch=ignore\n###" >> /etc/systemd/logind.conf

diffで差分を取るとこんな感じになります。
末尾に数行追記されているだけです。

$ diff -c /etc/systemd/logind.conf{.orig,}
*** /etc/systemd/logind.conf.orig       2015-10-01 00:45:23.156545333 +0900
--- /etc/systemd/logind.conf    2015-10-01 00:42:58.362242628 +0900
***************
*** 24,26 ****
--- 24,30 ----
  #LidSwitchIgnoreInhibited=yes
  #IdleAction=ignore
  #IdleActionSec=30min
+
+ ###added 2015/10/01
+ HandleLidSwitch=ignore
+ ###

設定を即座に反映させたいので、 system-logind サービスの再起動を実施します。
これがなんとなく不安ならリブートしてみても良いですね。

$ systemctl restart systemd-logind

これでノートPCを閉じてもサスペンドされなくなりました。
めでたしめでたし。


参考URL:
ArchLinuxの電源管理

16
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
14