Control WireGuard with Macros

tja42

New member
Hello,

is it somehow possible to control WireGuard with macros?
I want it to automatically connect to my home when I leave my wifi and disconnect when I enter it.
I have this app installed:
 

dhj49er

Well-known member
I don't have wireguard app installed and hence not familiar with it.
I use a VPN that supports the wireguard protocol and can control this in macros using UI integration method.
I expect this method could be used on the wireguard app.
 

teemue

New member
You can't control WG directly (macrodroid does not ask for the permission to control WG and the permission is needed). Luckily there is a workaround: install this tool (Tasker app is not needed) and use it as a bridge to redirect intents to WireGuard. APK is found in app/release folder.
 

tja42

New member
Thanks. This seems to be exactly what I need.

Unfortunately. I does not work here. I granted permissions to your app, imported your macro, changed the tunnel name. But when I test it just nothing happens here.
 

teemue

New member
I'm not the dev :)

Try creating a simple macro with only 'send intent'- action. No need to use the macro from github.

And make sure you have enabled 'Allow remote control apps' in Wireguard's settings.
 

tja42

New member
Meanwhile I am on Android 11 with Fairphone 4.
But I still so not know how to make it work.
Is this even correct?
 

Attachments

  • Screenshot_20211208-113143.png
    Screenshot_20211208-113143.png
    139.4 KB · Views: 147

pautvivz

New member
Check in Wireguard's settings that allow remote control apps is enabled.

On https://github.com/blurayne/TaskerWgTunner there is probably a mistake on App Intend Config net.evolution515.taskerwgtunnel/.MainActivity$IntentReceiver

It should be net.evolution515.taskerwgtunnel.MainActivity$IntentReceiver

as it is in https://github.com/blurayne/TaskerWgTunner/blob/main/macrodroid/Connect_to_Asgard.macro

So the settings for MacroDroid are

Target
Broadcast

Action
com.wireguard.android.action.SET_TUNNEL_UP

Package
net.evolution515.taskerwgtunnel

Class
net.evolution515.taskerwgtunnel.MainActivity$IntentReceiver

Extra 1
Enter parameter name
tunnel

Enter value
ckorn
 
Last edited:

Dimlos

Well-known member
I made a Macro of Send Intent Actions, why don't you try it with this?
Try editing the tunnel name from VPN to ekorn and do the Test actions

It is also important to set up each app so that it is not task-killed!
 

Attachments

  • Connect_to_VPN.macro
    1.4 KB · Views: 399
  • Disconnect_VPN.macro
    1 KB · Views: 274

tja42

New member
I made a Macro of Send Intent Actions, why don't you try it with this?
Try editing the tunnel name from VPN to ekorn and do the Test actions

It is also important to set up each app so that it is not task-killed!
Thank you!
These macros work! But as you said there is an error when the wireguard app ist not running.
It works after I start the wireguard app manually.
How can I prevent wireguard to bei task killed?Screenshot_20220227-022021.png
 

tja42

New member
Thanks it works now.
Wireguard is started when I leave my home and disconnected when I come home again.
 

sero23

New member
I made a Macro of Send Intent Actions, why don't you try it with this?
Try editing the tunnel name from VPN to ekorn and do the Test actions

It is also important to set up each app so that it is not task-killed!
Hi Dimlos,

Can you maybe help me out with this problem: i have downloaded your files and tried with ecorn en ckorn as you stated. But i can't get it to work, i have all the optimization settings turned off, i have the external control option turned on in wireguard. I want something like when wifi disconnect or turned off, then turn on vpn and same for turning it off when wifi connected turn of. I tried to change the empty trigger, with and without but i can't get it to work. Do i need to fill in something in your files which routes to a specific name or something? I am a bit off a noob but can follow certain instructions.
 

Dimlos

Well-known member
It worked on Android 13 in my verification. is the Allow remote control apps in WireGuard checked?
You also need to install the Tasker WireGuard Automation app and the intent extra must match the tunnel name.
 

sero23

New member
It worked on Android 13 in my verification. is the Allow remote control apps in WireGuard checked?
You also need to install the Tasker WireGuard Automation app and the intent extra must match the tunnel name.
Yes the Allow remote control apps in WireGuard is checked. I am on android 10. I don't have tasker installed, someone also stated that it is not necessary in the comments here. Also the 2 files on the github page are not working, i am logged in and when i press i get a page not found error 404. Can you maybe share the files/apps needed? Thank you in advance

Edit; i have now installed Tasker, but still can't get it to work
 
Last edited:

Dimlos

Well-known member
We share with you the "Tasker WireGuard Automation" application, which we have confirmed to work on Android 10.
Please install and launch it and press the REQUEST PERMISSION button.
Please use the previously uploaded macros.
 
Top