pro1
October 31st, 2010, 12:25 PM
Hi!
I've written a small script to bring my Desktop PC into suspend (standby) mode by keyboard shortcut. You could use it like that:
make a directory in your home-dir called "bin"
copy the following script into ~/bin/gnome-suspend.sh and make it executable (chmod +x gnome-suspend.sh)
associate a keyboard shortcut in your Gnome preferences
Best regards, pro...
#!/bin/bash
# avoid multiple execution
[ $(pgrep -c "gnome-suspend") -ne 1 ] && exit 0
# countdown to suspend mode in seconds
TIMEOUT=30
(
for i in $(seq 1 $TIMEOUT); do
let "p=100*i/TIMEOUT"
echo $p
let "t=TIMEOUT-i"
echo "# System is brought to suspend mode in $t seconds ..."
sleep 1
done
) | zenity --progress --title="System shutdown" --percentage=0 --auto-close
# shutdown aborted
[ "$?" -ne 0 ] && exit 0
# suspend mode
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower \
/org/freedesktop/UPower org.freedesktop.UPower.Suspend
I've written a small script to bring my Desktop PC into suspend (standby) mode by keyboard shortcut. You could use it like that:
make a directory in your home-dir called "bin"
copy the following script into ~/bin/gnome-suspend.sh and make it executable (chmod +x gnome-suspend.sh)
associate a keyboard shortcut in your Gnome preferences
Best regards, pro...
#!/bin/bash
# avoid multiple execution
[ $(pgrep -c "gnome-suspend") -ne 1 ] && exit 0
# countdown to suspend mode in seconds
TIMEOUT=30
(
for i in $(seq 1 $TIMEOUT); do
let "p=100*i/TIMEOUT"
echo $p
let "t=TIMEOUT-i"
echo "# System is brought to suspend mode in $t seconds ..."
sleep 1
done
) | zenity --progress --title="System shutdown" --percentage=0 --auto-close
# shutdown aborted
[ "$?" -ne 0 ] && exit 0
# suspend mode
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower \
/org/freedesktop/UPower org.freedesktop.UPower.Suspend