如何在不关闭屏幕(显示器)的情况下锁定?

由于最近的一个错误 ,每次我的屏幕关闭,我都无法重新开启。

目前,屏幕在计算机锁定后开始关闭 – 这实际上意味着我无法在不完全重启的情况下锁定计算机。

有没有办法锁定它,但没有显示器进入hibernate/关闭状态?

如果您需要或想要一个可以防止屏幕入睡的解决方案,但是一段时间后屏幕变暗/锁定,还有另一个解决方案:使用下面的脚本运行以下命令,而不是系统自带的dim / lock选项。背景。 您需要安装xprintidle

如何设置:

  • 禁用系统设置中的所有暗淡/锁定选项。 (亮度和锁定 “能量”设置中)

  • 安装xprintidle:

     sudo apt-get install xprintidle 
  • 找到您的屏幕名称; 在终端中运行:

     xrandr 

    在“连接”行中查找名称。 您的屏幕名称可以是例如VGA-1DVI-I-1

  • 复制下面的脚本,设置正确的screen_name,它应该锁定/调暗屏幕之前的空闲时间,并将其粘贴到空文件中。 将其另存为lock_dim.py

剧本

 #!/usr/bin/env python3 import subprocess import time seconds = 600 # number of seconds to wait before lock/dim the screen screen_name = "DVI-I-1" # example, replace it with your screen's name awake = True while True: curr_idle = subprocess.check_output(["xprintidle"]).decode("utf-8").strip() if awake == True: if int(curr_idle) > seconds*1000: command1 = "gnome-screensaver-command -l" command2 = "xrandr --output "+screen_name+" --brightness 0.1" subprocess.call(["/bin/bash", "-c", command1]) subprocess.call(["/bin/bash", "-c", command2]) awake = False else: pass elif awake == False: if int(curr_idle) > seconds*1000: pass else: command3 = "xrandr --output "+screen_name+" --brightness 1" subprocess.call(["/bin/bash", "-c", command3]) awake = True time.sleep(2) 

通过打开终端测试脚本并键入:

 python3 /path/to/lock_dim.py 

如果它可以正常工作,请将其添加到启动应用程序:打开Dash>“启动应用程序”>“添加”,添加命令:

 python3 /path/to/lock_dim.py 

转到系统首选项 > 亮度和锁定 ,然后将“在非活动时关闭屏幕”更改为从不

现在点击右上角的设置图标点击您的帐户用户名,您的屏幕将被锁定,永不hibernate。