What do you mean by installed wol.service. I ran:
foc@ubuntu22:~$ sudo --preserve-env systemctl edit --force --full wol-enable.service
Then I typed this in the file with nano:
Description=Wake-on-LAN for enp2s0
ExecStart=/sbin/ethtool -s enp2s0 wol g
ExecStop=/sbin/ethtool -s enp2s0 wol g
systemctl start wol.service
systemctl enable wol.service
systemctl is-enabled wol.service
I use vscode to create a ssh connection with the laptop. I manualy close the lid. The ssh connection keeps working becouse I edited the /etc/systemd/logind.conf file
Than I send the command sudo poweroff in vscode. The ssh connection breaks because it powers off.
Then I send a magic packet by the program Wake on LAN (Magic Packet) to the MAC address. I have also try'd with sending the magic packet by the web interface of the router. Both work if the lid is open when I power off the laptop. And both do not work if the lid is closed when I power off the laptop.
I don't know what you mean bij "In my case, I just changed the event, when lid is closed, shutdown immediately." I don't want to shutdown the laptop when the lid is closed as I want to keep using the laptop wether the lid is closed or not.
I can not reply to this threat. I am a new user of this form and I get the message that I am reply limited. What should I do. Edit this command or continue this converstation somewhere else?
My situation is this:
I have a old laptop that I would like to put away in a room to use as a test-server. In this case I want to be able to close the screen with the laptop still functioning because it doesn't need a screen as a server and it will only use electricity. I have this functionality working.
I also want to be able to remotely turn the "server" on and off, because I will use it for testing and it does not need to be always on. This way it uses less power and collects less dust inside it if it is not turnt on al the time. Turning it off is easy but turning it on not. I can use WOL to turn it on remotely, wich is exactly what I want. But then I ran into a problem. During testing I had the screen open, but when I put the laptop away to use it as a server and closed the screen the WOL stoped working. I eventualy found out that the problem of WOL not working only ocourd if the screen was closed at the time the laptop turned off. This could be fix in 2 ways by never turning it off (wich I do not prefer ) Or by always having the lid open (wich would cost electricy for the screen). The perfect solution whould be to be able to start the server with a magic packet even If the screen is closed.
I will go with your sugestion: Wake on LAN Persistance Issues 22.04 - #20 by pavlos_kairis
I have used the setterm command to let the screen go dark afther 2 minutes. This was not the solution that I was thinking of, but in practice it will make no difference so it is perfect. Thank you for your time to day @pavlos_kairis.