linux-cli-community
linux-cli-community copied to clipboard
Auto reconnect when woken from suspend [Enhancement]
Is your feature request related to a problem? Please describe. I use the CLI client to connect to VPN on my Linux laptop. After waking up from a suspend, the client doesn't reconnect VPN automatically. Instead, the killswitch comes into play and I have no internet. This is annoying as I need to explicitly reconnect to the VPN.
Describe the solution you'd like Automatically reconnect on wakeup from suspend.
Describe alternatives you've considered
Fiddling with systemd
services to reconnect when woken up from suspend/hibernate.
Additional context Lenovo Carbon X1 with Manjaro Linux. ProtonVPN CLI: v2.2.4
I am not good in bash scripts, but I've tried the following (I use Linux Manjaro, the KDE edition):
- Create the script.
#!/bin/bash
dbus-monitor --session "type='signal',interface='org.kde.ScreenSaver'" |
(while true; do
read X
if echo $X | grep "boolean false" &>/dev/null; then
sudo protonvpn r
fi
done)
- Run it in background.
The script worked once or more (reconnected after wakeup, to be clear - after unlock), but now it does not work anymore. I was not able to fix it yet.
Also, maybe the following script will be as an example https://gist.github.com/lowstz/1770403
One more example of starting/stopping the processes after wakeup/unlock (works on any Linux distribution): https://github.com/folixg/pause-on-lock/blob/master/pause-on-lock. I am sure that someone who knows the bash language can adapt the code to reconnect VPN.
You could add 2 additional services to stop vpn on sleep and restart on wake up, something like this
# pvpnd-sleep.service
[Unit]
Description=Stop pvpnd.service on sleep
Before=sleep.target
[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl stop pvpnd
[Install]
WantedBy=sleep.target
# pvpnd-resume.service
[Unit]
Description=Resume pvpnd.service on wake up from suspend
After=suspend.target
[Service]
ExecStartPre=/usr/bin/sleep 5
ExecStart=/usr/bin/systemctl restart pvpnd
[Install]
WantedBy=suspend.target
pvpnd.service
is the described on doc https://github.com/ProtonVPN/linux-cli/blob/master/USAGE.md#via-systemd-service
Stop pvpnd.service on sleep
Why to do that at all? Is not enough only to restart the service after wakeup/unlock?
The Linux clients are currently being rewriten, thus, no new further commits will be made for the current CLI.