Answers:
您可以安装Caffeine来执行此操作:
sudo add-apt-repository ppa:caffeine-developers/ppa
sudo apt-get update
sudo apt-get install caffeine
然后在您的Dash中搜索咖啡因以启动它。它应该在重新启动后自动启动。
现在,咖啡因将在屏幕右上方显示一个指示器。单击它启用咖啡因(您的PC现在不会进入睡眠状态)。再次单击以禁用它,Ubuntu将遵循其通常的睡眠模式。
您也可以根据需要永久禁用睡眠。
System Settings
Brightness & Lock
Turn screen off when inactive for
选择Never
#!/bin/bash
# Cleanup any bad state we left behind if the user exited while flash was
# running
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled --type bool true
we_turned_it_off=0
while true; do
sleep 60
flash_on=0
for pid in `pgrep firefox` ; do
if grep libflashplayer /proc/$pid/maps > /dev/null ; then
flash_on=1
fi
ss_on=`gconftool-2 -g /apps/gnome-screensaver/idle_activation_enabled`
if [ "$flash_on" = "1" ] && [ "$ss_on" = "true" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool false
we_turned_it_off=1
elif [ "$flash_on" = "0" ] && [ "$ss_on" = "false" ] \
&& [ "$we_turned_it_off" = "1" ]; then
gconftool-2 -s /apps/gnome-screensaver/idle_activation_enabled \
--type bool true
we_turned_it_off=0
fi
done
done
将其另存为.sh文件,并将此文件添加到会话和启动中