Wallpapers New script for wireguard check

This commit is contained in:
dzaczek 2023-10-14 19:02:39 +02:00
parent 6eac617ecd
commit d4e96d6f7e
6 changed files with 49 additions and 2 deletions

2
config
View file

@ -13,7 +13,7 @@
exec --no-startup-id xrandr --output DSI-1 --rotate right
exec_always --no-startup-id feh --bg-scale ~/Pictures/uconsole.jpg
exec_always --no-startup-id feh --bg-scale ~/.config/i3/wallp/mur1.png
set $mod Mod1

View file

@ -139,7 +139,7 @@ separator=true
#
[wireguard]
command=~/.config/i3/scripts/wg_check.sh
command=~/.config/i3/scripts/wghand.sh
interval=10

47
scripts/wghand.sh Executable file
View file

@ -0,0 +1,47 @@
#!/bin/bash
# Run the command and capture the output
ICON_UP=""
ICON_DOWN=""
# Run the command and capture the output
output=$(sudo wg show wg0)
# Extract the last handshake time in the format "X seconds/minutes/hours ago"
last_handshake_string=$(echo "$output" | grep "latest handshake" | awk '{print $3, $4}')
# Function to extract seconds from the time string
extract_seconds() {
local time_string="$1"
local seconds=0
if [[ $time_string == *"seconds"* ]]; then
seconds=$(echo "$time_string" | awk '{print $1}')
elif [[ $time_string == *"minutes"* ]]; then
minutes=$(echo "$time_string" | awk '{print $1}')
seconds=$((minutes * 60))
elif [[ $time_string == *"hours"* ]]; then
hours=$(echo "$time_string" | awk '{print $1}')
seconds=$((hours * 3600))
fi
echo "$seconds"
}
# Get the number of seconds from the time string
last_handshake_seconds=$(extract_seconds "$last_handshake_string")
# Check if the last handshake is smaller than 1 minute (60 seconds)
if [ "$last_handshake_seconds" -lt 50 ]; then
echo $ICON_UP
echo
echo \#008000
fi

BIN
wallp/aple.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
wallp/mur1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
wallp/mur2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB