Very nice, I didn't know that you could wake computers with unicast packets.
For my use case, I run a Raspberry Pi that is on the same local network as my PC. When I connect to the Pi to forward my PC's RDP port to my laptop's loopback interface, the Pi sends a normal magic packet to wake my PC. All that was needed was an entry like this in my laptop's .ssh/config:
Host remote-desktop
HostName raspberry-pi
User pi
Port 1234
IdentityFile ~/.ssh/raspberry-pi-key
LocalForward 3389 my-pc.local:3389
SessionType default
RemoteCommand wakeonlan -i 192.168.178.255 11:22:33:44:55:66; cat
Each time the RDP port is forwarded, the wakeonlan command is run on the Raspberry Pi. The 'cat' at the end keeps the command from exiting so that the RDP port keeps being forwarded. (I also configured the NOPASSWD option for wakeonlan in /etc/sudoers so that no root privileges are needed to run it.)
There's also the "exec" keyword that lets you run a command in a "Match" block like so:
Match host my-pc.local exec "wakeonlan -i 192.168.178.255 11:22:33:44:55:66"
This doesn't cover the case when the connecting machine is in another network but it does avoid a hop. Perhaps you could also run another SSH command in the exec condition that connects to the Pi and has it send the WoL packet.
For my use case, I run a Raspberry Pi that is on the same local network as my PC. When I connect to the Pi to forward my PC's RDP port to my laptop's loopback interface, the Pi sends a normal magic packet to wake my PC. All that was needed was an entry like this in my laptop's .ssh/config:
Each time the RDP port is forwarded, the wakeonlan command is run on the Raspberry Pi. The 'cat' at the end keeps the command from exiting so that the RDP port keeps being forwarded. (I also configured the NOPASSWD option for wakeonlan in /etc/sudoers so that no root privileges are needed to run it.)