我正在使用 Ubuntu 18.04,并且已经为 gnome 环境编写了脚本。我需要知道我们能否为所有 Linux 桌面环境使用通用脚本?
下面是我的脚本,
#!/bin/bash
# This script has been tested in the Ubuntu 18.04.
MAXIMUM_IDLE_DELAY=300 # maximum session idle valuse for the power management in seconds
MAXIMUM_SCRN_LOCK_DELAY=300 # maximum screen-saver lock delay in seconds
MAXIMUM_DELAY=$(($MAXIMUM_IDLE_DELAY + $MAXIMUM_SCRN_LOCK_DELAY))
IS_ENABLED=$(gsettings get org.gnome.desktop.screensaver lock-enabled)
USER_IDLE_DELAY=$(gsettings get org.gnome.desktop.session idle-delay | cut -d ' ' -f2)
USER_SCRN_LOCK_DELAY=$(gsettings get org.gnome.desktop.screensaver lock-delay | cut -d ' ' -f2)
USER_TOTAL_DELAY=$(($(gsettings get org.gnome.desktop.session idle-delay | cut -d ' ' -f2) + $(gsettings get org.gnome.desktop.screensaver lock-delay | cut -d ' ' -f2)))
function screen_lock_Test(){
if [ "$IS_ENABLED" == "true" ] && [ "$USER_IDLE_DELAY" -gt 0 ];then
if [[ $USER_TOTAL_DELAY -le $MAXIMUM_DELAY ]];then
echo "Configurations matching with the given settings" 1>&2
return 0
else
echo "Screen lock settings takes too much time to lock down !!!!!" 1>&2
return 1
fi
else
echo "Screen lock configurations do not match with the given settings !!!!!" 1>&2
return 1
fi
}
screen_lock_Test
echo $?