rocuan
April 11th, 2011, 05:38 AM
Are there limitations on what can be started from /etc/pm/sleep.d after system wakeup?
I wrote a perl script to randomly change my gnome desktop background http://ubuntuforums.org/showthread.php?p=10654538
I want to run that script when my laptop wakes up.
I followed this guide : http://ubuntuforums.org/showthread.php?t=1484156
and wrote this code
#!/bin/bash
. /usr/lib/pm-utils/functions
case "$1" in
hibernate|suspend) ;;
thaw|resume)
echo "woke up `date`" >> /var/log/wakeup.log
/usr/bin/perl /home/me/bin/perlscript 2> /var/log/wakeup_error.log ;;
*) ;;
esac
exit $?
I saved the script as 00_user_script in the /etc/pm/sleep.d folder & made it root executable
The wakeup.log file gets filled correctly so I think the code is solid
but
my perl script refuses to run.
To debug, I tried substituting pidgin to auto-load after wakeup.
/usr/bin/pidgin 2> /var/log/wakeup_error.log ;;I caught this error
(Pidgin:26174): Gdk-CRITICAL **: gdk_display_get_name: assertion `GDK_IS_DISPLAY (display)' failed
** (Pidgin:26174): WARNING **: cannot open display: unsetThis lead me to believe that it was calling pidgin too early, before gnome had "woken up"
So I thought maybe the sleep.d/script should call another shell script( startpidgin.sh ) that sleeps for a bit
#!/bin/bash
sleep 7
/usr/bin/pidgin 2>> /var/log/wakeup_error.log
but still get the same error.
I figured the sleep.d/00_user_script was waiting for startpidgin.sh to exit, so I installed dtach http://manpages.ubuntu.com/manpages/natty/man1/dtach.1.html
and tried again.
dtach -n /tmp/foo /home/me/bin/startpidgin 2> /var/log/wakeup_error.log
still throws same error
- If I run ps -e immediately after waking I see the startpidgin process is running & waiting, but pidgin fails to start
- I have varied the sleep time
- I have varied the script name : 99_user.sh, 60_user, 00_user, etc
but no love.
I assume the GDK environment is still undefined somehow so the script fails.
Thoughts? Options? Answers?
-puzzled
I wrote a perl script to randomly change my gnome desktop background http://ubuntuforums.org/showthread.php?p=10654538
I want to run that script when my laptop wakes up.
I followed this guide : http://ubuntuforums.org/showthread.php?t=1484156
and wrote this code
#!/bin/bash
. /usr/lib/pm-utils/functions
case "$1" in
hibernate|suspend) ;;
thaw|resume)
echo "woke up `date`" >> /var/log/wakeup.log
/usr/bin/perl /home/me/bin/perlscript 2> /var/log/wakeup_error.log ;;
*) ;;
esac
exit $?
I saved the script as 00_user_script in the /etc/pm/sleep.d folder & made it root executable
The wakeup.log file gets filled correctly so I think the code is solid
but
my perl script refuses to run.
To debug, I tried substituting pidgin to auto-load after wakeup.
/usr/bin/pidgin 2> /var/log/wakeup_error.log ;;I caught this error
(Pidgin:26174): Gdk-CRITICAL **: gdk_display_get_name: assertion `GDK_IS_DISPLAY (display)' failed
** (Pidgin:26174): WARNING **: cannot open display: unsetThis lead me to believe that it was calling pidgin too early, before gnome had "woken up"
So I thought maybe the sleep.d/script should call another shell script( startpidgin.sh ) that sleeps for a bit
#!/bin/bash
sleep 7
/usr/bin/pidgin 2>> /var/log/wakeup_error.log
but still get the same error.
I figured the sleep.d/00_user_script was waiting for startpidgin.sh to exit, so I installed dtach http://manpages.ubuntu.com/manpages/natty/man1/dtach.1.html
and tried again.
dtach -n /tmp/foo /home/me/bin/startpidgin 2> /var/log/wakeup_error.log
still throws same error
- If I run ps -e immediately after waking I see the startpidgin process is running & waiting, but pidgin fails to start
- I have varied the sleep time
- I have varied the script name : 99_user.sh, 60_user, 00_user, etc
but no love.
I assume the GDK environment is still undefined somehow so the script fails.
Thoughts? Options? Answers?
-puzzled