0

I've bashed around on this one for awhile, no pun intended. I just want to open my todo list url in my browser every time my computer wakes from suspend. The command to do this normally is easy:

xdg-open https://complice.co/

...but that doesn't work, because "Please start Google Chrome as a normal user." Same if I try sensible-browser.

So then I try

sudo -H -u malcolm bash -c 'sensible-browser "https://complice.co/" >> "$LOGFILE"'

...and this totally works if I'm just in a terminal as root, but if I try to put it in a /etc/pm/sleep.d/ script, then it fails silently. I tried

sudo -H -u malcolm bash -c 'sleep 10; sensible-browser "https://complice.co/" >> "$LOGFILE"' 

...but it seems that the process is killed before sleep 10 finishes. (Based on trying sleep 10; echo "WAT" >> "$LOGFILE";)

This feels like it should be simple, but I'm pretty stuck.

1

1 Answer 1

0

What works for me is to place this script bellow into /etc/pm/sleep.d/ call it 70resumescript.sh, and give it executable permissions with sudo chmod +x scriptname.sh. In addition, I wrote the script with sudo nano scriptname.sh so that the script will be owned by root. So the script must have +x permission and be owned by root. Feel free to modify the scrip to suit your needs

#!/bin/sh

case "$1" in
    resume|thaw)
        # date >> /home/serg/LOG
        # echo "Script runs" >> /home/serg/LOG
        DISPLAY=:0 ; export DISPLAY
        sleep 4
        su serg -c 'firefox google.com'
        ;;
esac
1
  • If you like my answer, give me an upvote. Solved your problem ? Click the grey check-mark to accept my answer Jun 8, 2015 at 9:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .