Ubuntu MATE 16.04 LTS 中的睡眠定時器暫停

Ubuntu MATE 16.04 LTS 中的睡眠定時器暫停

有沒有辦法(最好是使用 GUI)在 xx 分鐘後暫停我的電腦?我正在使用 Ubuntu MATE 16.04 LTS 並嘗試了一切,包括電源管理。

謝謝,菲利普

答案1

如果你不介意使用終端,你可以這樣做。

執行 :sleep 2h 45m 20s && systemctl suspend -i

它會在 2 小時 45 分 20 秒內暫停您的系統。

我寫了一個腳本來取得這樣的 GUI:

在此輸入影像描述

在此輸入影像描述

複製下面腳本的內容並將其保存在您的主目錄中 fast_suspend.sh

#!/bin/bash

#   Tested on : Ubuntu 16.04 LTS    
#   Date      : 19-May-2016
#                                                        
#   This program is distributed in the hope that it will be useful, 
#   but WITHOUT ANY WARRANTY; without even the implied warranty of  
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.            

set -- `zenity --title="Scheduled-action" \
    --forms \
    --text='<span foreground="green">Enter Relative time</span>'  \
    --add-entry="hours" \
    --add-entry="min" -\
    --add-entry="sec" \
    --separator=".0 " \
    --add-combo=action --combo-values="poweroff|restart|suspend|logout"`

hrs=$1
min=$2
sec=$3
action=$4

time=$hrs\h\ $min\m\ $sec\s

#Checking validity of the input :

re='^[0-9]*([.][0-9]+)?$'

if ! [[ $hrs =~ $re ]] || ! [[ $min =~ $re ]] || ! [[ $sec =~ $re ]]
then
    zenity  --error \
            --title="Invalid Input" \
            --text="You have entered an Invalid time! \n\nOnly positive integers supported"
            exit 1
fi



case $action in
    "poweroff")
        zenity --title=Confirm --question \
        --text="Your system is about to <span foreground=\"red\">$action</span> in ${hrs%%.*} hours ${min%%.*} minutes ${sec%%.*} seconds. \nAre you sure \?"
        if [ $? -eq 0 ]
        then 
            sleep $time && poweroff
        else
            exit
        fi  ;;

    "restart")
        zenity --title=Confirm --question \
        --text="Your system is about to <span foreground=\"red\">$action</span> in ${hrs%%.*} hours ${min%%.*} minutes ${sec%%.*} seconds. \nAre you sure \?"
        if [ $? -eq 0 ]
        then 
            sleep $time && reboot
        else
            exit
        fi  ;;
    "suspend")

        zenity --title=Confirm --question \
        --text="Your system is about to <span foreground=\"red\">$action</span> in ${hrs%%.*} hours ${min%%.*} minutes ${sec%%.*} seconds. \nAre you sure \?"
        if [ $? -eq 0 ]
        then 
            sleep $time && systemctl suspend -i
        else
            exit
        fi  ;;
    "logout")
        zenity --title=Confirm --question \
        --text="Your system is about to <span foreground=\"red\">$action</span> in ${hrs%%.*} hours ${min%%.*} minutes ${sec%%.*} seconds. \nAre you sure \?"
        if [ $? -eq 0 ]
        then 
            sleep $time && gnome-session-quit --logout --no-prompt
        else
            exit
        fi  ;;
esac

此外,您可以建立一個.desktop檔案來運行它。

複製下面的文字並將其另存為fast_suspend.desktop.

[Desktop Entry]
Type=Application
Terminal=false
Icon=
Name=fast_suspend
Exec=/home/your-user-name/fast_suspend.sh
Name[en_US]=fast_suspend

為這兩個檔案提供執行權限-execute:

chmod a+x ~/fast_suspend.sh ~/Desktop/fast_suspend.desktop

當您想再次啟動此視窗時,只需按兩下fast_suspend桌面上。

答案2

如果您正在尋找圖形工具,您可以嘗試關機

相關內容