1. 程式人生 > >Linux 命令列關閉開啟顯示器及xset: unable to open display ""解決方法

Linux 命令列關閉開啟顯示器及xset: unable to open display ""解決方法

在遠端連線Linux等時,基本用不到顯示器,所以希望能遠端將顯示屏關閉
xset -display :0.0 dpms force off這個命令讓顯示屏進入休眠狀態
xset -display :0.0 dpms force on開啟顯示屏

sleep 1 && xset dpms force off這個命令關閉螢幕
出現了報錯:xset: unable to open display “”
解決方法:輸入如下命令

export DISPLAY=:0
xset q

之後再輸入sleep 1 && xset dpms force off

不再報錯

Reference:
https://askubuntu.com/questions/476036/xset-unable-to-open-display