Terkadang ketika menggunakan komputer kita lupa untuk mematikannya. Agar tidak lupa mematikan komputer saat ditinggal bepergian, kita dapat memanfaatkan gnome zenity untuk membuat program waktu shutdown. Copy dan paste script berikut ini pada text editor dan simpan dengan extensi sh.

=====================
#!/bin/bash
#
# Shutdown Timer Tool untuk Linux
#
# Depends on zenity
#
# Original by: Krytarik
# Modify by resacr

if [ -n “`ps ax |grep shutdown |egrep -v ‘grep|shutdown-timer’`” ]; then
zenity –title=”Blankon OI” –question –text=”Cancel Shutdown Timer?”
if [ “$?” = “0” ]; then
sudo shutdown -c
if [ “$?” = “0” ]; then
zenity –title=”Blankon OI” –info –text=”Shutdown cancelled.”
else
PASSWORD=`zenity –title=’Blankon OI’ –entry –text=’Please enter your password:’ –hide-text`
if [ -n “$PASSWORD” ]; then
echo $PASSWORD | sudo -S shutdown -c
if [ “$?” = “0” ]; then
zenity –title=”Blankon OI” –info –text=”Shutdown cancelled.”
else
zenity –title=”Blankon OI” –error –text=”Sorry, wrong password!”
fi
fi
fi
fi
else
TIMER=$(zenity –title=”Blankon OI” –scale –text=”Atur Waktu Shutdown Komputer (dalam menit):” –value=30 –min-value=1 –max-value=180 –step=5)
if [ -n “$TIMER” ]; then
sudo -b shutdown -h +$TIMER
if [ “$?” = “0” ]; then
zenity –title=”Blankon OI” –info –text=”Shutdown in $TIMER minutes!”
else
PASSWORD=`zenity –title=’Blankon OI’ –entry –text=’Please enter your password:’ –hide-text`
if [ -n “$PASSWORD” ]; then
echo $PASSWORD | sudo -Sb shutdown -h +$TIMER
if [ “$?” = “0” ]; then
zenity –title=”Blankon OI” –info –text=”Shutdown in $TIMER minutes!”
else
zenity –title=”Blankon OI” –error –text=”Sorry, wrong password!”
fi
fi
fi
fi
fi
=====================

Seperti ini tampilan programnya

Screenshot

Screenshot-1

Screenshot-2

Selamat mencoba 🙂

Sumber : https://marisharingilmu.wordpress.com/2014/06/29/zenity-membuat-program-shutdown-timer-pc/

The following two tabs change content below.
Penulis di www.marisharingilmu.wordpress.com. Email : resarahadian@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *