wireguard-android: Shortcut for Single Click Toogle of Tunnel

Matthias Meier matthias.j.meier at gmx.net
Fri Apr 18 16:20:07 UTC 2025


When toggling Wireguard Tunnel on Android at 2 or 3 clicks are needed, 
even when using the Wireguard Toogle Button at the Android Notification bar.
With the patch below single click solution is possible by using a 
Andorid Homescreen Shortcut which allows real single click toggle.

This solution needs only a small addition in AndroidManifest.xml and an 
additional shortcuts.xml:


diff --git a/ui/src/main/AndroidManifest.xml 
b/ui/src/main/AndroidManifest.xml
index 754992d5..3b6f2dce 100644
--- a/ui/src/main/AndroidManifest.xml
+++ b/ui/src/main/AndroidManifest.xml
@@ -63,6 +63,10 @@
              <intent-filter>
                  <action 
android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES" />
              </intent-filter>
+            <meta-data
+                android:name="android.app.shortcuts"
+                android:resource="@xml/shortcuts" />
+
          </activity>

          <activity
diff --git a/ui/src/main/res/xml/shortcuts.xml 
b/ui/src/main/res/xml/shortcuts.xml
index e69de29b..98dc1849 100644
--- a/ui/src/main/res/xml/shortcuts.xml
+++ b/ui/src/main/res/xml/shortcuts.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<shortcuts xmlns:android="http://schemas.android.com/apk/res/android">
+    <shortcut
+        android:shortcutId="shortcut_toggle"
+        android:enabled="true"
+        android:icon="@mipmap/ic_launcher"
+        android:shortcutShortLabel="@string/quick_settings_tile_action"
+        android:shortcutLongLabel="@string/quick_settings_tile_add_summary"
+        >
+        <intent
+            android:action="android.intent.action.VIEW"
+            android:targetPackage="com.wireguard.android.debug"
+ 
android:targetClass="com.wireguard.android.activity.TunnelToggleActivity" />
+    </shortcut>
+</shortcuts>





More information about the WireGuard mailing list