refactored batteries script, tscale_native uses core utils instead of rg and jq
This commit is contained in:
@ -27,7 +27,11 @@ markup=pango
|
||||
#interval=1
|
||||
|
||||
[tailscale]
|
||||
command=~/.config/i3blocks/tscale #echo TS: $(ip a show tailscale0 | rg "inet (\d+\.\d+\.\d+\.\d+)" -or '$1')
|
||||
command=~/.config/i3blocks/tscale_native #echo TS: $(ip a show tailscale0 | rg "inet (\d+\.\d+\.\d+\.\d+)" -or '$1')
|
||||
interval=5
|
||||
|
||||
[workvpn]
|
||||
command=~/.config/i3blocks/workvpn
|
||||
interval=5
|
||||
|
||||
[wthr]
|
||||
|
||||
37
i3/.config/i3blocks/tscale_native
Executable file
37
i3/.config/i3blocks/tscale_native
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
case $BLOCK_BUTTON in
|
||||
1) ~/.dotfiles/bin/rofi-tscale ;;
|
||||
esac
|
||||
|
||||
icon=""
|
||||
|
||||
if ! ip a show tailscale0 &>/dev/null; then
|
||||
icon=""
|
||||
out="$icon no tailscale"
|
||||
which tailscale &>/dev/null && out="$icon tailscale inactive"
|
||||
echo -e "$out\n$out\n#606060"
|
||||
exit
|
||||
fi
|
||||
|
||||
exitnode=$(tailscale status --json | awk '/"ExitNodeStatus": /,/}/')
|
||||
enstatus=""
|
||||
tsip=$(ip a show tailscale0 | grep -Po 'inet \K((\d+\.){3}\d+)')
|
||||
[ -z "$exitnode" ] && {
|
||||
[ -z "$tsip" ] && {
|
||||
icon=""
|
||||
text="$icon offline"
|
||||
color='#707070'
|
||||
} || {
|
||||
text="$icon $tsip"
|
||||
COLOR='#8080ff'
|
||||
}
|
||||
} || {
|
||||
enstatus=$(echo "$exitnode" | awk '/TailscaleIPs/,/]/' | grep -Po "(\d+\.){3}\d+")
|
||||
icon=""
|
||||
text="$icon $enstatus"
|
||||
COLOR='#80ff80'
|
||||
}
|
||||
echo "$text"
|
||||
echo "$text"
|
||||
echo $COLOR
|
||||
20
i3/.config/i3blocks/workvpn
Executable file
20
i3/.config/i3blocks/workvpn
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
status=$(ip a show ppp1 2>/dev/null || "")
|
||||
[ -z "$status" ] && exit 0
|
||||
|
||||
icon=
|
||||
color="#808080"
|
||||
text=""
|
||||
ip=$(grep -Po 'inet \K(\d+\.){3}\d+' <<<$status)
|
||||
if [ -z "$ip" ]; then
|
||||
text="$icon wait..."
|
||||
color="#ffff00"
|
||||
else
|
||||
text="$icon $ip"
|
||||
color="#80ff80"
|
||||
fi
|
||||
|
||||
echo "$text"
|
||||
echo "$text"
|
||||
echo "$color"
|
||||
Reference in New Issue
Block a user