I have a script that sends the PC to sleep and wakes on the 1st of the month:
Code:
#!/bin/bash
#current system time and waketime
old=`date '+%H:%M'`
new=11:55
THISYEAR=`date +'%Y' -d 'now'`
NEXTMONTH=`date +'%m' -d 'next month'`
#if next month is January, increment the year by 1
if [ $NEXTMONTH == 01 ]
then
THISYEAR=`date +'%Y' -d '1 year'`
fi
#current system date and wake date(1st of next month)
olddate=`date +%Y-%m-%d`
newdate=$THISYEAR"-"$NEXTMONTH"-01"
IFS=: read old_hour old_min <<< "$old"
IFS=: read hour min <<< "$new"
# convert the date in seconds from Unix EPOCH time
sec_old=$(date -d "$olddate $old_hour:$old_min:00" +%s)
sec_new=$(date -d "$newdate $hour:$min:00" +%s)
DIFFERENCE=$(( (sec_new - sec_old) ))
#lock the screen
#gnome-screensaver-command -l
#suspend the system and wake in this many seconds
sudo rtcwake -m mem -s $DIFFERENCE
This is saved as /home/steve/SuspendWake.sh
From the terminal, if I type
Code:
/home/steve/SuspendWake.sh
the script runs as expected.
I have created a desktop launcher to run the script above but it asks me for a password. If I change the desktop launcher command to
Code:
sudo /home/steve/SuspendWake.sh
it still asks for a password, as does:
Code:
gksudo /home/steve/SuspendWake.sh
I have tried adding to visudo as follows:
Code:
Steve ALL= NOPASSWD: /home/Steve/SuspendWake.sh
but still no luck!
Can anyone help getting the launcher to run without asking for a password?
Thanks
Bookmarks