GitBucket
4.20.0
Toggle navigation
Sign in
Files
Branches
1
Tags
Issues
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
Jonathan
/
pmf-suspend
Browse code
Updated help text.
master
1 parent
a2c511a
commit
eb304f912cb4358f9ee7c4259031ddbfb184266a
Jonathan Ström
authored
on 8 Mar 2017
Patch
Showing
2 changed files
README.md
pmf-suspend
Ignore Space
Show notes
View
README.md
0 → 100644
### Installation Run this command in your terminal to install pmf-suspend to your path. `sudo ./pmf-suspend-install` ### Usage pmf-suspend Suspend system instantly pmf-suspend [help|--help] Show this message pmf-suspend 1 2 3 Timer will be set to 1s, 2m, 3h pmf-suspend 0 30 Timer will be set to 30 mintues ### Info Author: Livila Version: 1.0 This program is used for when you want to suspend your computer with a timer. As pm-suspend does not lock the screen on several of the latest versions, this will do that automatically when the timer is finished. The command pmf-suspend stands for power manager (fix) suspend. In order to suspend the system this program must be run as root.
Ignore Space
Show notes
View
pmf-suspend
#!/bin/bash # Help if [[ $1 == "help" || $1 == "--help" ]]; then echo -e "Usage: pmf-suspend Suspend system pmf-suspend [help|--help] Show this message pmf-suspend 1 2 3 Timer will be set to 1s, 2m, 3h pmf-suspend 0 30 Timer will be set to 30 mintues Info: Author: Livila Version: 1.0 Use this program when you want to suspend your computer with a timer. As pm-suspend itself does not lock the screen on the latest versions. This will do that automatically when the timer is finished. The command pmf-suspend stands for Power Manager (Fix) suspend. In order to suspend the system this program must be run as root. "; exit 1 fi # Check if the user is using sudo. if [[ $EUID -ne 0 ]]; then echo "This script must be run as root, use \"sudo pmf-suspend\" instead." 1>&2 exit 1 fi # Calulcate time if [ "$3" != "" ]; then hour=$(($3 * 3600)); fi if [ "$2" != "" ]; then minute=$(($2 * 60)); fi if [ "$1" != "" ]; then second=$(($1)); fi # Print time and count down suspendText="Suspending computer in: " runCountdown() { total=$(( $hour + $minute + $second )) while [ $total -gt 0 ] do sleep 1 & printf "\r$suspendText%02d:%02d:%02d" $((total/3600)) $(( (total/60)%60)) $((total%60)) total=$(( $total - 1 )) wait done # Setting timer to 00:00:00 when it is finished printf "\r$suspendText%02d:%02d:%02d" 00 00 00 echo } # Set user user="stina" if [ $1 != "" ]; then runCountdown fi # Execute scripts # Lock screen sudo -u $user gnome-screensaver-command --lock # Suspend computer sudo pm-suspend
#!/bin/bash # Help if [[ $1 == "help" || $1 == "--help" ]]; then echo -e "Usage: pmf-suspend Suspend system pmf-suspend [help|--help] Show this message pmf-suspend 1 2 3 Timer will be set to 1s, 2m, 3h pmf-suspend 0 30 Timer will be set to 30 mintues Info: Author: Livila Version: 1.0 This program is used for when you want to suspend your computer with a timer. As pm-suspend does not lock the screen, this will do that automatically when the timer is finished. The command pmf-suspend stands for power manager (fix) suspend. In order to suspend the system this program must be run as root."; exit 1 fi # Check if the user is using sudo. if [[ $EUID -ne 0 ]]; then echo "This script must be run as root, use \"sudo pmf-suspend\" instead." 1>&2 exit 1 fi # Calulcate time if [ "$3" != "" ]; then hour=$(($3 * 3600)); fi if [ "$2" != "" ]; then minute=$(($2 * 60)); fi if [ "$1" != "" ]; then second=$(($1)); fi # Print time and count down suspendText="Suspending computer in: " runCountdown() { total=$(( $hour + $minute + $second )) while [ $total -gt 0 ] do sleep 1 & printf "\r$suspendText%02d:%02d:%02d" $((total/3600)) $(( (total/60)%60)) $((total%60)) total=$(( $total - 1 )) wait done # Setting timer to 00:00:00 when it is finished printf "\r$suspendText%02d:%02d:%02d" 00 00 00 echo } # Set user user="stina" if [ $1 != "" ]; then runCountdown fi # Execute scripts # Lock screen sudo -u $user gnome-screensaver-command --lock # Suspend computer sudo pm-suspend
Show line notes below