You are not logged in.

#1 2022-05-01 07:55:08

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

[SOVLED] systemd's system-sleep hook doesn't run

I have some scripts that I want to run after coming out of suspend mode, so I've created some scripts in /lib/systemd/system-sleep, but they never run. Here's the inside of one of the scripts I stole from the internet:

/lib/systemd/system-sleep/debug:
#!/bin/sh
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    echo deez nutz > /home/sv-cheats-1/suspend
    ;;
  post/*)
    echo "Waking up from $2..."
    echo nutz deez > /home/sv-cheats-1/suspend
    # Place your post suspend (resume) commands here, or `exit 0` if no post suspend action required
    ;;
esac

Upon coming out of suspend there is no new text added to the text file via "echo", so I guess it doesn't work. Any ideas as to why and how to fix/debug this?

Last edited by sv-cheats-1 (2022-05-01 20:06:31)

Offline

#2 2022-05-01 08:02:59

seth
Member
Registered: 2012-09-03
Posts: 58,791

Re: [SOVLED] systemd's system-sleep hook doesn't run

stat /lib/systemd/system-sleep/debug

Offline

#3 2022-05-01 08:03:37

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [SOVLED] systemd's system-sleep hook doesn't run


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#4 2022-05-01 08:13:10

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

I don't know why, but the below script seems to work as intended, don't know why the first one didn't work.

#!/bin/bash
case $1 in
pre) case $2 in
    hibernate)
            echo "Going to suspend to disk!"
            ;;
    hybrid-sleep)
            echo "Going to suspend to disk and ram!"
            ;;
    suspend)
            echo "Suspending to RAM." >> /home/sv-cheats-1/test
            /usr/bin/nmcli dev con enp5s0 >> /home/sv-cheats-1/test
            /usr/bin/warp-cli connect >> /home/sv-cheats-1/test
            ;;
    *)
            echo "Unexpected case"
            ;;
    esac ;;

post)
        echo "We are now resuming from $2."
        ;;
*)
        echo "Unexpected case"
        ;;
esac

Offline

#5 2022-05-01 08:15:18

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

Spoke too soon, doesn't work/works inconsistently

Offline

#6 2022-05-01 08:19:17

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

Here's the output of "journalctl -b -u systemd-suspend.service"

Apr 30 14:17:33 sv-cheats-1 systemd-sleep[2758]: System returned from sleep state.
Apr 30 14:17:33 sv-cheats-1 systemd-sleep[2801]: Error: Failed to add/activate new connection: Connection 'enp5s0' is not available on device enp5s0 because device is strictly unmanaged
Apr 30 14:17:33 sv-cheats-1 [2792]: /usr/lib/systemd/system-sleep/enableWarp failed with exit status 4.
Apr 30 14:17:33 sv-cheats-1 systemd[1]: systemd-suspend.service: Deactivated successfully.
Apr 30 14:17:33 sv-cheats-1 systemd[1]: Finished System Suspend.

Last edited by sv-cheats-1 (2022-05-01 08:19:35)

Offline

#7 2022-05-01 08:23:36

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

seth wrote:
stat /lib/systemd/system-sleep/debug

Renamed script to network sorry

stat /lib/systemd/system-sleep/network
  File: /lib/systemd/system-sleep/network
  Size: 591       	Blocks: 8          IO Block: 4096   regular file
Device: 259,6	Inode: 2892860     Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-05-01 11:06:14.678797150 +0300
Modify: 2022-05-01 11:06:13.052119330 +0300
Change: 2022-05-01 11:06:13.068786112 +0300
 Birth: 2022-05-01 11:06:13.052119330 +0300

Last edited by sv-cheats-1 (2022-05-01 10:46:34)

Offline

#8 2022-05-01 14:04:29

seth
Member
Registered: 2012-09-03
Posts: 58,791

Re: [SOVLED] systemd's system-sleep hook doesn't run

Apr 30 14:17:33 sv-cheats-1 systemd-sleep[2801]: Error: Failed to add/activate new connection: Connection 'enp5s0' is not available on device enp5s0 because device is strictly unmanaged

Doesn't suggest that the script doesn't run - just that it fails?

/lib/systemd/system-sleep/debug:
#!/bin/bash
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    date >> /home/sv-cheats-1/suspend
    echo "deez nutz" >> /home/sv-cheats-1/suspend
    ;;
  post/*)
    echo "Waking up from $2..."
    date >> /home/sv-cheats-1/suspend
    echo "nutz deez" >> /home/sv-cheats-1/suspend
    # Place your post suspend (resume) commands here, or `exit 0` if no post suspend action required
    ;;
esac

Offline

#9 2022-05-01 18:14:28

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

seth wrote:

Apr 30 14:17:33 sv-cheats-1 systemd-sleep[2801]: Error: Failed to add/activate new connection: Connection 'enp5s0' is not available on device enp5s0 because device is strictly unmanaged

Doesn't suggest that the script doesn't run - just that it fails?

/lib/systemd/system-sleep/debug:
#!/bin/bash
case $1/$2 in
  pre/*)
    echo "Going to $2..."
    # Place your pre suspend commands here, or `exit 0` if no pre suspend action required
    date >> /home/sv-cheats-1/suspend
    echo "deez nutz" >> /home/sv-cheats-1/suspend
    ;;
  post/*)
    echo "Waking up from $2..."
    date >> /home/sv-cheats-1/suspend
    echo "nutz deez" >> /home/sv-cheats-1/suspend
    # Place your post suspend (resume) commands here, or `exit 0` if no post suspend action required
    ;;
esac

Looks like it, seems like nmcli can't manage the device for some reason?

Offline

#10 2022-05-01 19:32:50

seth
Member
Registered: 2012-09-03
Posts: 58,791

Re: [SOVLED] systemd's system-sleep hook doesn't run

I guess that's because of the S3 - what are you trying to do there itfp? Why are you trying to manipulate the network while entering the sleep?

Offline

#11 2022-05-01 19:36:46

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

seth wrote:

I guess that's because of the S3 - what are you trying to do there itfp? Why are you trying to manipulate the network while entering the sleep?

I've setup warp vpn on my system and I've noticed that if I suspend the system the VPN disconnects. I had looked up and found a way to run script after coming out of suspend so I've setup that script. It worked for a while until one day it stopped working for some reason and would break the entire connection. I decided to add the

nmcli dev con enp5s0

to mediate that.

Offline

#12 2022-05-01 19:37:41

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

Jesus, I've made the script run in the wrong time omg gimme a second

Offline

#13 2022-05-01 19:45:05

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

Ok, so I've changed things so that they are where they should be:

#!/bin/bash
case $1 in
pre) case $2 in
    hibernate)
            echo "Going to suspend to disk!"
            ;;
    hybrid-sleep)
            echo "Going to suspend to disk and ram!"
            ;;
    suspend)
            echo "Suspending to RAM."
            ;;
    *)
            echo "Unexpected case"
            ;;
    esac ;;

post)
        echo "We are now resuming from $2."
        /usr/bin/nmcli dev con enp5s0 >> /home/sv-cheats-1/test
        /usr/bin/warp-cli connect >> /home/sv-cheats-1/test
        ;;
*)
        echo "Unexpected case"
        ;;
esac

Here's the output of "journalctl -b -u systemd-suspend.service"

May 01 22:38:24 sv-cheats-1 systemd-sleep[17371]: System returned from sleep state.
May 01 22:38:24 sv-cheats-1 systemd-sleep[17484]: We are now resuming from suspend.
May 01 22:38:24 sv-cheats-1 systemd-sleep[17491]: Error: Failed to add/activate new connection: Connection 'enp5s0' is not available on device enp5s0 because device is strictly unmanaged
May 01 22:38:24 sv-cheats-1 systemd[1]: systemd-suspend.service: Deactivated successfully.
May 01 22:38:24 sv-cheats-1 systemd[1]: Finished System Suspend.

The connection is still broken, still need to do things manually after resume.

Offline

#14 2022-05-01 19:48:28

seth
Member
Registered: 2012-09-03
Posts: 58,791

Re: [SOVLED] systemd's system-sleep hook doesn't run

This is probably running too early, https://wiki.archlinux.org/title/Networ … dispatcher ?

Offline

#15 2022-05-01 20:06:15

sv-cheats-1
Member
Registered: 2022-02-15
Posts: 47

Re: [SOVLED] systemd's system-sleep hook doesn't run

seth wrote:

This is probably running too early, https://wiki.archlinux.org/title/Networ … dispatcher ?

Oh yeah, now we're rolling! Thank you very much seth! It works! You are ny hero!

Offline

Board footer

Powered by FluxBB