This script WORK if i test him, but suspending manjaro make lan disconnected IMMEDIATLY (red X on lan icon) i use sleep 5 to see what’s happening while service running:
click suspend
lan disconnect immediatly
remote command error beaucause lan is disconnected
5 seconds pass
system will suspend
My question: there is a way to tell at service “don’t stop ethernet when suspend?” Or configure lan to NOT disable when suspend system? Modify suspend rules?
Create a file /lib/systemd/system-sleep/my_script.sh with the following content:
#!/bin/bash
case $1/$2 in
pre/*)
# commands to be executed before suspend, hibernate, etc. goes below
echo "This example does nothing"
;;
post/*)
# commands to be executed on wake, resume, etc. goes below
echo "Nothing to see here"
;;
esac
I’m almost certain that this WantedBy=network-online.target will make your script be executed as soon as your network is marked “online”, so remove that
Note: Don’t blindly copy over your config from your previous script in the other thread which had different requirements and goals…
The sequence of units used when booting, are not the same as those used to suspend nor resume from a suspended state…
as soon as i can i will try with your precious suggestions!!!
@TriMoon I’m almost certain that this WantedBy=network-online.target will make your script be executed as soon as your network is marked “online”, so remove that
i didn’t understand why i shouldn’t tell to the script to run when my network is online, like a check.
That line is not a check, it tells systemd to execute your script when the network comes online.
But your script’s functionality is to put your TV OFF right?
So think about powering off your TV when you boot your PC, is that correct behavior you want?
Checks that must be valid before a service is run, are using different keywords, and none of them can check for presence of a service on a remote machine…
Hi,
no way, i try all you suggest (thx) and read all tutorial.
Best explanation is:
According to a reply from systemd-devel mailing list, this is impossible using solely systemd while using Network Manager as Network Manager listens for the sleep signal on its own. A workaround is to put what you need to run into:
/etc/NetworkManager/dispatcher.d/pre-down.d/
i think this workaround not working well… imagine various network failure scenario and monitor flip on/off… not good.
But let’s move on to the positive results! Now i can turn off the tv during shutdown and during system startup, not bad at all!
PS: Is there a way to politely ask the manjaro developers to make script working before the network off while suspend? It could be useful to everyone.
Seems like you want to speak to the network manager or systemd devs…or maybe they need to speak to each other.
Anyway, if you aren’t already, you could use this to suspend. Bind it to a key combo if you want.
#!/usr/bin/bash
lgtv MyTv off ssl
systemctl suspend
A systemd service should work for resume. It’s late and I’m feeling too lazy to write one right now, maybe tomorrow (assuming you haven’t already got one).
Alternatively use a different network manager. Then this service should work, assuming the other network managers don’t do the same (at least systemd-networkd should hopefully work ).
[Unit]
Description=Turn off screen before suspend
Before=suspend.target
[Service]
ExecStart=/usr/bin/lgtv MyTv off ssl
Type=oneshot
[Install]
WantedBy=suspend.target
EDIT:
Here’s a resume service that should work, you may need to tweak the sleep time. I haven’t found a way to only use Before, After etc yet.
[Unit]
Description=Turn on TV after suspend
After=suspend.target
[Service]
ExecStartPre=/usr/bin/sleep 5
ExecStart=/usr/bin/lgtv MyTv on ssl
Type=oneshot
[Install]
WantedBy=suspend.target
If you change the dependencies (eg WantedBy, and possibly Before, After etc) then you should disable and re-enable the service for the changes to take effect.
Hi,
only putting script in Network manager pre-down work. But it’s a bad workaround for me.
/etc/NetworkManager/dispatcher.d/pre-down.d/
I also create a commad to “cp” the script in pre-down folder when system sleep and “rm” at resume.
The script will move the file but won’t work, also try to launch modrpobe command to activate network, but sleep it’s absolutly prioritary than any others commands…
i am thinking to buy an ir usb adapter to control better TV.