Autostarting startupapplications after wake ubuntu 18.04

Hey there here a quick guide for setting up hibernate and more important autostarting the programs you placed in the autostarting tool.

  1. Set up hibernate:

I used this guide (Note: this is in german, but there are plenty of guides for this)
After that with
sudo hibernate
my system correctly hibernates and wakes up.

  1. Add hibernate button to gnome

I used this extension:
But other then in the stated, I need to place the file contents in /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
and install the gnome-extension from here

  1. Autostart Programs

Now it works, with a few missing pieces, all my programs that starts, when my user logs in (the program that are specified in the startupprograms tool) are not starting except for signal, soo lets starts them:

Place a script for starting all programs in /lib/systemd/system-sleep/. And make it executable.

sudo touch /lib/systemd/system-sleep/ 
sudo chown +x /lib/systemd/system-sleep/ 

in there, place a case structure like this


case "$1" in
        pre) #place here stuff done before going to sleep/hibernate
        post) #place here stuff done on wake

I could just placed all my startup applications in here, but then I have to extends this file if I want more programs to startup, and I already have a list. It is in this directory /home/user/.config/autostart/*.desktop here the ubuntu startupapplication stores every entry.

therefore I want all the .desktop to execute, but this is not really intended, (
the intended way is not possible to use, because the directory is not the installed applications directory therefore my startup.desktops are not found with gtk-launch <app-name>

but the deprecated way is working, I placed the skript following script /home/user/file/path/to/your/ on my pc and make it executable.

$(grep '^Exec' $1 | tail -1 | sed 's/^Exec=//' | sed 's/%.//' \
| sed 's/^"//g' | sed 's/" *$//g') &

I really don’t understand what this is exactly is doing, but I have to say grep is reeally powerful ^^

and call this file for all .desktop Files in /home/user/.config/autostart

The /lib/systemd/system-sleep/ is now


case "$1" in
        pre) #place here stuff done before going to sleep
        post) #place here stuff done on wake
                for filename in /home/user/.config/autostart/*.desktop; do
                        if [ "$filename" != "/home/user/.config/autostart/signal-desktop.desktop" ]; then #exclude signal, because signal manages to startup
                                /home/user/file/path/to/your/ $filename
                        sleep 1 # sometime the script gets hung up

now all my startup applications resume after wake.
More elegantly would be if wake would also wake those programs, but yeah.
If someone has a solution for this, it would be very appreciate for you to share.

Credits : (I of course did not come up with all this stuff)
starting .desktop Files from terminal
starting on wake (answered Jun 5 '20 at 8:32)