4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

RaspberryPiでディスプレイを自動的にスリープにする

Last updated at Posted at 2019-05-27

RaspberryPi(というかRaspbian)は使用していない時にデフォルトではディスプレイの画面を黒くするだけでディスプレイをスリープにしません。
別件でRaspberryPiのドキュメントを見ていたところ偶然自動的にディスプレイをスリープにする方法を見つけたので紹介します。
(この機能一体いつからあった?)

TL; DR

(共通)
/boot/config.txtに下記を追記

/boot/config.txt
hdmi_blanking=1

(GUI版のみ)

sudo apt install xscreensaver
# インストール後左上のメニューからスクリーンセーバーの設定を行う。

(CUI版のみ)
/boot/cmdline.txtの文の最後にconsoleblank=ディスプレイを消灯するまでの秒数を追加

/boot/cmdline.txt(例)
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait consoleblank=300
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=34e8ad56-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait consoleblank=30

hdmi_blankingを有効にする

RaspberyPiの公式の資料に以下のようなことが書いてあります。

hdmi_blanking

The hdmi_blanking command allows you to choose whether the HDMI output should be switched off when DPMS is triggered. This is to mimic the behaviour of other computers. After a specific amount of time, the display will become blank and go into low-power/standby mode due to receiving no signal.

NOTE: This feature may cause issues when using applications which don't use the framebuffer, such as omxplayer.

簡単に行ってしまえばこのオプションを設定するとディスプレイを消灯することができるということです。

ただし、注意書きにあるように、一部のアプリケーションでは問題が発生することがあります。

このオプションを1にして/boot/config.txtに追記し、設定すると有効化されます。

/boot/config.txt
hdmi_blanking=1

(GUI版のみ)スクリーンセーバーを有効化する

上記の設定を行っただけではコンピュータを使用していないかどうかのチェックをしてくれません。そこでスクリーンセーバーの仕組みを利用して使用していない時にディスプレイを消灯する命令を送るように設定します。
スクリーンセーバーの機能を提供するxscreensaver をインストールします。

sudo apt install xscreensaver

その後アプリケーションのメニューにある設定の中のスクリーンセーバーの設定を開き、ディスプレイがスリープになるまでの時間を設定します。

(CUI版のみ)

CUI版ではcodline.txtの設定を変更します。
1行目にズラーと書かれているコマンドの最後にconsoleblank=300を追記します。300の部分を画面が消灯するまでの秒数に変更してください。
変更すると下記のようになると思います。

/boot/cmdline.txt(例)
dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait consoleblank=300

あとがき

数年前にも同じように悩んだ結果無理やり画面を消灯するという方法で乗り切っていました。この方法ならWindowsやMacと同じようにできますね。
もし間違いなどがあればご指摘いただければ幸いです。
(余裕があればGUI版の方にスクショを貼るかもしれません)

Reference

4
6
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
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?