initial commit

This commit is contained in:
dzaczek 2023-10-13 22:29:49 +02:00
commit 81b9fd515f
7 changed files with 789 additions and 0 deletions

28
scripts/rpibat.sh Executable file
View file

@ -0,0 +1,28 @@
#!/bin/bash
# Define the path to the uevent file
UEVENT_FILE="/sys/class/power_supply/axp20x-battery/uevent"
# Check if the uevent file exists
if [ ! -f "$UEVENT_FILE" ]; then
echo "Battery info not available"
exit 1
fi
# Extract battery status and capacity from the uevent file
BATTERY_STATUS=$(grep -E "POWER_SUPPLY_STATUS" "$UEVENT_FILE" | cut -d'=' -f2)
BATTERY_CAPACITY=$(grep -E "POWER_SUPPLY_CAPACITY" "$UEVENT_FILE" | cut -d'=' -f2)
# Define font-awesome icons
ICON_CHARGING="\uf1e6" # plug icon
ICON_DISCHARGING="\uf242" # battery icon
# Check the battery status and output the appropriate icon and capacity
if [ "$BATTERY_STATUS" == "Charging" ]; then
echo -e "$ICON_CHARGING $BATTERY_CAPACITY%"
elif [ "$BATTERY_STATUS" == "Discharging" ]; then
echo -e "$ICON_DISCHARGING $BATTERY_CAPACITY%"
else
echo "Battery: $BATTERY_CAPACITY% | $BATTERY_STATUS"
fi

10
scripts/rpitemp.sh Executable file
View file

@ -0,0 +1,10 @@
#!/bin/bash
# Get the CPU temperature
cpu_temp_milli=$(cat /sys/class/thermal/thermal_zone0/temp)
# Convert to degrees Celsius
cpu_temp=$(awk -v temp="$cpu_temp_milli" 'BEGIN {printf "%.1f", temp/1000}')
# Output the temperature
echo "$cpu_temp"

21
scripts/rpiwireguard.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/bash
# Define the WireGuard interface
WG_INTERFACE="wg0"
# Define shield icons
ICON_UP="<span color='green'></span>" # Shield (use your desired icon)
ICON_DOWN="<span color='red'></span>" # Shield (use your desired icon)
# Check if the WireGuard interface is active
if ip link show dev "$WG_INTERFACE" &> /dev/null; then
# Check if there are any established peer connections
if [ "$(wg show "$WG_INTERFACE" endpoints | wc -l)" -gt 0 ]; then
echo "WG: $ICON_UP Connected"
else
echo "WG: $ICON_DOWN No Peers"
fi
else
echo "WG: $ICON_DOWN Down"
fi

17
scripts/wg_check.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
# Icons
ICON_UP=""
ICON_DOWN=""
# Check if WireGuard interface wg0 is up
if ip link show wg0 &> /dev/null; then
# If wg0 is up, display a green icon
echo $ICON_UP
echo
echo \#008000
#else
# # If wg0 is down, display a gray icon
# echo $ICON_DOWN
fi