22.5. 配置自动退出
闲置一段时间的用户会话可以自动终止。您可以通过设置相应的 GSettings 键,根据机器是否通过电池运行还是通过主电源运行来设置不同的行为,然后锁定它。
如果空闲会话自动结束了,用户可能会丢失未保存的数据。
要为电源供电的机器设置自动退出:
流程
在
/etc/dconf/db/local.d/00-autologout文件中为机器范围的设置创建一个本地数据库:[org/gnome/settings-daemon/plugins/power] # Set the timeout to 900 seconds when on mains power sleep-inactive-ac-timeout=900 # Set action after timeout to be logout when on mains power sleep-inactive-ac-type='logout'
[org/gnome/settings-daemon/plugins/power] # Set the timeout to 900 seconds when on mains power sleep-inactive-ac-timeout=900 # Set action after timeout to be logout when on mains power sleep-inactive-ac-type='logout'Copy to Clipboard Copied! Toggle word wrap Toggle overflow 覆盖用户设置,并防止用户在
/etc/dconf/db/local.d/locks/autologout文件中更改它:# Lock automatic logout settings /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-type
# Lock automatic logout settings /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout /org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-typeCopy to Clipboard Copied! Toggle word wrap Toggle overflow 更新系统数据库:
dconf update
# dconf updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 在系统范围的设置生效前,用户必须退出并重新登录。
下面的 GSettings 键值得关注的:
org.gnome.settings-daemon.plugins.power.sleep-inactive-ac-timeout
如果计算机是通过 AC 电源运行的,则它在休眠前需要处于非活动状态的秒数。
org.gnome.settings-daemon.plugins.power.sleep-inactive-ac-type
如果计算机通过 AC 电源运行,则超时时会发生什么。
org.gnome.settings-daemon.plugins.power.sleep-inactive-battery-timeout
如果计算机通过电源运行,它在休眠前需要处于非活动状态的秒数。
org.gnome.settings-daemon.plugins.power.sleep-inactive-battery-type
如果计算机通过电池运行,超时时会发生什么。
如果要列出键的可用值,请使用以下流程:
流程
-
对所需的键运行
gsettings range命令。例如: