Control WireGuard with Macros

sero23

New 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.
Thank u, i have now installed this app, made all the apps excluded for battery optimization, i tried with and without changing the tunnel value, with the name of my vpn, i tried with and without changing to ekorn, ckorn and vpn, but non of them work, sorry for asking to much.
 

Dimlos

Well-known member
The value of the intent extra must match the tunnel name.
Is Permissions were granted shown?
 

Attachments

  • wireguard.jpg
    wireguard.jpg
    64 KB · Views: 111
  • macrodroid.jpg
    macrodroid.jpg
    229.2 KB · Views: 114
  • taskerwgtunnel.jpg
    taskerwgtunnel.jpg
    139 KB · Views: 110
Last edited:

Rafffaga

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.
it's no working for me in my S20 FE...I'll delete and reinstall all again to verify.
thx
 

Dimlos

Well-known member
it's no working for me in my S20 FE...I'll delete and reinstall all again to verify.
This may not be very helpful, but we have additionally verified this with an A22 5G we have on hand, and we were able to confirm that it works fine with Samsung devices as well.
 

Rafffaga

New member
All reinstalled again
Automation worked the first time but never again when I leave home
I don't know what else to do😞
 

Dimlos

Well-known member
I don't know what else to do
We tried various things with the A22 5G but could not get it to work reliably.
I think it is probably taskkilled.
DontKillMyApp has not written a clear solution for Android 12 or Android 13, so I am at a loss.
 

Rafffaga

New member
A13
only works for me with S20 FE is activating manuallly after rebooting the smartphone. With the option ssid near or far. From that moment on, it works only.

Lo digo en castellano que mi inglés es pésimo....Me he dado cuenta que si activo y desactivo probando la acción desde macrodroid (después de cada reinicio en mi samsung s20 fe) ya funciona sólo, eso sí, con el disparador de SSID fuera de alcance o cerca.
Para el que le sirva ;-)
 

henne10

New member
All reinstalled again
Automation worked the first time but never again when I leave home
I don't know what else to do😞
Try it like in the attached screenshot, with kill background task it works for me:
 

Attachments

  • Screenshot_20230505-171522.png
    Screenshot_20230505-171522.png
    215.6 KB · Views: 66

lindend

New member
Could this functionality be added to MacroDroid with out having to use intents? Tasker has official support for Wireguard and you don't need to use intents to enable/disable tunnels anymore. Could this functionality be added to the Macrodroid roadmap?

I've got both MacroDroid and Tasker on my phone. Tasker is able to enable/disable tunnels but I can't get Macrodroid to work with any of the suggestions in this thread. Unclear if its because Tasker is on the machine or if there's something different in Android 13
 

Endercraft

Moderator (& bug finder :D)
Tasker probably uses intents when you use these actions. MacroDroid could do the same but it's best to keep it simple because not a lot of users need Wireguard tunnel automation.
 

henne10

New member
Here's what MacroDroid will need to do to allow this:

Add to the manifest XML:

<uses-permission android:name="com.wireguard.android.permission.CONTROL_TUNNELS"/>

Add to your program:
ActivityCompat.requestPermissions(this, new String[]{"com.wireguard.android.permission.CONTROL_TUNNELS"}, someRequestNumber)


After the permission is granted, you will be able to send tunnel up/down requests to WireGuard:

  • App: com.wireguard.android
  • Intent: com.wireguard.android.action.SET_TUNNEL_UP
  • Intent: com.wireguard.android.action.SET_TUNNEL_DOWN
  • Intent extra: "tunnel" = "SOME_TUNNEL_NAME"
 

Dimlos

Well-known member
MacroDroid does not have the authority to control WireGuard, so it must be routed through another app.
I don't think it is because it is Android 13 that it doesn't work. Is your device a Samsung?
It did not work well on my Samsung device.
 

lindend

New member
Tasker probably uses intents when you use these actions. MacroDroid could do the same but it's best to keep it simple because not a lot of users need Wireguard tunnel automation.
Yea, internally its using intents, but it provides actions that make them easy to use.
 

lindend

New member
Would I need to install the helper app even if Tasker is on the system?

As an experiment, I removed the permission from Tasker, and executing the intent in Macrodroid doesn't result in a permission request. I do get a permission failure in Tasker unless I add the permission.
 

Dimlos

Well-known member
If you like Tasker, you can send an intent from MacroDroid to Tasker and execute the task.
The verification result of Pixel 7 Pro worked. Maybe you missing some settings.
 
Last edited:

Dimlos

Well-known member
Since v5.37.x, you can control WireGuard directly from MacroDroid.
A sample macro is attached.
 

Attachments

  • Macro.jpg
    Macro.jpg
    433.2 KB · Views: 93
  • WireGuard_Control.macro
    6.1 KB · Views: 110
Top