Seeking Advice on KLWP Formulas for VPN Connection Status

Hello community,

I’m currently working on customizing my Android setup using KLWP, and I’m having difficulties with formulas to display VPN connection status. I’ve tried several formulations based on suggestions, but encountered errors such as not displaying as expected, staying blank even when connected to VPN, or consistently showing “VPN activated” regardless of the VPN status.

Here are three formulas I’ve attempted:

  1. $if(sh("ifconfig tun0", 1) = "ifconfig: tun0: No such device", "", "🔒")$

  2. $if(sh("ifconfig | grep tun0", 1) != "", "Connection Secured", "")$

  3. $if(sh("ifconfig tun0", 1) = "ifconfig: tun0: No such device", "🔓", "🔒")$

  4. $if(sh("ifconfig tun0") = "ifconfig: tun0: No such device", "VPN Disconnected", "VPN Connected")$

  5. $if(sh("route print | findstr") = "", "SSH Tunnel Disconnected", "SSH Tunnel Connected")$

I would appreciate any insights or suggestions to improve these formulas and correctly reflect the VPN connection status in KLWP. Thank you in advance for your help!

1 Like

I’m no expert on vpn at all, but for showing connection status a while ago I had to use package names for accurate status results

$if(ni(pcount, com.appatomic.vpnhub)>0, “ON”, if(ni(pcount, com.adguard.vpn)>0, “ON”, if(ni(pcount, com.psiphon3.subscription)>0, “ON”, “”)))$

1 Like

Thank you so much for your assistance! I sincerely appreciate your help.

I struggled not only with KLWP but also with Tasker, almost reaching the point of giving up.

The formula you provided worked flawlessly. I’m not an expert in any of these, but your guidance using package names for accurate status results made all the difference.

I am grateful for your expertise!
Here’s what I’m using to complement yours:

‘$if(ni(pcount, com.celzero.bravedns) > 0, “Connected to DNS + Firewall”, if(ni(pcount, > 0, “VPN Connected”, “Not VPN Connected”))$’

Again, thank you :blush:

Great news, you’re welcome

1 Like

This topic was automatically closed 25 days after the last reply. New replies are no longer allowed.