From 8240f7d218f9a93aca818e770da838bc9f628a98 Mon Sep 17 00:00:00 2001 From: nomadics9 Date: Thu, 24 Oct 2024 15:16:20 +0300 Subject: [PATCH] scripts --- scripts/brightness | 2 +- scripts/wg-status.sh | 12 ++++++++++++ scripts/wg-toggle.sh | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 scripts/wg-status.sh create mode 100755 scripts/wg-toggle.sh diff --git a/scripts/brightness b/scripts/brightness index c95f010..39f1657 100755 --- a/scripts/brightness +++ b/scripts/brightness @@ -1,4 +1,4 @@ -#!/bin/env/sh +#!/usr/bin/env bash down() { brightnessctl set 5%- diff --git a/scripts/wg-status.sh b/scripts/wg-status.sh new file mode 100755 index 0000000..3aa7371 --- /dev/null +++ b/scripts/wg-status.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# Get the interface name (assumes the interface is the first line output by `wg show`) +#interface=$(sudo wg show | grep '^interface:' | awk '{print $2}') +interface="nmd" +# Check if there is a recent handshake (this indicates the connection is active) +handshake=$(ip a show "$interface" | grep 'link') + +if [[ -n "$handshake" ]]; then + echo "🔒 $interface" +else + echo "🌀" +fi diff --git a/scripts/wg-toggle.sh b/scripts/wg-toggle.sh new file mode 100755 index 0000000..d697343 --- /dev/null +++ b/scripts/wg-toggle.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Get the interface name (change this to your actual WireGuard interface name if needed) +interface="nmd" + +handshake=$(ip a show "$interface" | grep 'link') + +# Check if WireGuard is up +if [[ -n "$handshake" ]]; then + # If it's up, bring it down + pkexec wg-quick down "$interface" + dunstify -a "WireGuard" "Disconnected from $interface" +else + # Otherwise, bring it up + pkexec wg-quick up "$interface" + dunstify -a "WireGuard" "Connected to $interface" +fi