Creating systemd Unit file

Create a unit file in the /etc/systemd/system/ directory and make sure it has correct file permissions. Execute as root:

# touch /etc/systemd/system/name.service
# chmod 664 /etc/systemd/system/name.service

Replace name with a name of the service to be created. Note that file does not need to be executable.

Open the name.service file created in the previous step, and add the service configuration options. The following is an example unit configuration for a network-related service:

[Unit]
Description=service_description
After=network.target

[Service]
ExecStart=path_to_executable
Type=forking

[Install]
WantedBy=default.target

Notify systemd that a new name.service file exists by executing the following command as root:

# systemctl daemon-reload
# systemctl enable name.service
# systemctl start name.service
Advertisements
Creating systemd Unit file

Network Manager restart after suspend/hibernate

Open a terminal and type the following:

sudo nano /etc/systemd/system/wifi-resume.service Now paste the script in there with a right click. Exit with CTRL + X and press Y to save. Now to activate it: sudo systemctl enable wifi-resume.service

Script:

#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target

Hope this helps. It works on my laptop.

Network Manager restart after suspend/hibernate