I need to open browser on a certain page each time the laptop wakes up from hibernate / sleep and on boot.

I've created a script wakeUp.sh in folder /lib/systemd/system-sleep/ made chmod 777 /lib/systemd/system-sleep/wakeUp.sh to give all rights to the file for sure.

Now the script it self (where I try to make the browser open on page after I close-open the laptop lid [sleep-wakeup]):

echo "$@" > /tmp/wakeUpParams.txt
case $1/$2 in
    chromium-browser --no-sandbox http://google.com 1>/home/liza/out.txt 2>/home/liza/err.txt
    echo "$@" > /tmp/AfterBrowserLaunch.txt

In the script, I save the output of the incoming parameters to a /tmp folder, and after I close/open the lid I find these params in txt file:

post suspend

Thus the param $1 = post and $2 = suspend

If I run the script from terminal:

sudo ./wakeUp.sh


sudo ./wakeUp.sh post suspend

It runs successfully. So it executes the line where the browser is opened.

If I close/open the lid, the params in wakeUpParams.txt are still post suspend and the echo "$@" > /tmp/AfterBrowserLaunch.txt line also executes, but the browser still doesn't launch.

Now to the errors:

When I execute the script via terminal the browser launches but I get errors in the err.txt file:

    Home directory not accessible: Permission denied
[13870:13961:0316/181921.003202:ERROR:bus.cc(394)] Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")

(chromium-browser:13870): LIBDBUSMENU-GLIB-WARNING **: Unable to get session bus: Unknown or unsupported transport 'disabled' for address 'disabled:'
[13870:13870:0316/181922.813336:ERROR:gpu_process_transport_factory.cc(1009)] Lost UI shared context.
[13968:14061:0316/181923.018813:ERROR:cmd_buffer_helper.cc(158)] ContextResult::kFatalFailure: CommandBufferHelper::AllocateRingBuffer() failed

The out.txt is empty.

When the lid is closed/opened:

  • out.txt - empty
  • err.txt - empty ( Why no errors here? )

I also execute chromium-browswer with --no-sandbox params chromium-browser --no-sandbox because it wouldn't start without this param from terminal due to some security issues. Is this normal way to start it? Because the browser says in a yellow message pop-out: "You are using an unsupported command-line flag: --no-sandbox. Stability and security will suffer." Is this the best way to execute chromium-browser from the command-line?

Update 1

I changed chromium-browser to a simple text editor gedit and it still won't start even Gedit on open/close lid, while the script from terminal runs without problem... So I suppose it's not a problem with Chromium...

Update 2

Starting to understand that it's a bad idea to mess with launching GUI from systemd. See Launching Chromium on startup with systemd - Unix & Linux

  • 1
    The scripts /lib/systemd/system-sleep/ get run as root I believe, my guess is that chrome does not like that. If you runs the script as your user, it should work. I'm not sure how to do that through. – JonasCz - Reinstate Monica Mar 16 '18 at 17:33
  • 1
    I changed chromium-browser to a simple text editor "gedit" and it still won't start even "Gedit" on open/close lid ... While the script from terminal runs without problem ... So I suppose it's not the problem with chromium .... – Dmitriy Klyushin Mar 16 '18 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.