mirror of
https://github.com/Ahwxorg/nixos-config.git
synced 2025-12-04 15:00:13 +01:00
feat: adds mullvad script
This commit is contained in:
parent
eecc50d44e
commit
c8c1276199
1 changed files with 21 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
{ pkgs, username, ... }:
|
||||
|
||||
let
|
||||
externalIPv4 = "";
|
||||
in
|
||||
{
|
||||
home.file = {
|
||||
"/home/${username}/.local/bin/waybar-yubikey" = {
|
||||
|
|
@ -213,6 +215,7 @@
|
|||
'';
|
||||
};
|
||||
"/home/${username}/.local/bin/waybar-vpn" = {
|
||||
# unused nowadays
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
|
|
@ -222,6 +225,23 @@
|
|||
|| echo '{"text":"Disconnected","class":"disconnected","percentage":0}'
|
||||
'';
|
||||
};
|
||||
"/home/${username}/.local/bin/waybar-mullvad" = {
|
||||
executable = true;
|
||||
text = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
STATUS="$(mullvad status | grep -Eio 'connected|connecting|disconnected' | tr '[:upper:]' '[:lower:]')"
|
||||
NODE="$(mullvad status | grep -Ei 'relay' | awk '{print $2}' | tr '[:upper:]' '[:lower:]')"
|
||||
LOCATION="$(mullvad status | grep -Ei 'location' | cut -d':' -f2 | cut -d'.' -f1 | sed 's/ //g')"
|
||||
IPV4="$(mullvad status | grep 'IPv4' | cut -d':' -f3 | sed 's/ //g')"
|
||||
echo "$IPV4" | grep -q "${externalIPv4}" && LOCATION="home"
|
||||
|
||||
echo "$STATUS" | grep -Eioq 'connected|connecting' && TEXT="{\"text\":\"$STATUS ($LOCATION)\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}" || ip address show tailscale0 | grep "global tailscale0" -q && TEXT="{\"text\":\"tailscale ($LOCATION)\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}"
|
||||
echo "$STATUS" | grep -Eioq 'disconnected' && TEXT="{\"text\":\"$STATUS\",\"location\":\"$LOCATION\",\"node\":\"$NODE\"}"
|
||||
|
||||
echo "$TEXT"
|
||||
'';
|
||||
};
|
||||
};
|
||||
home.packages = with pkgs; [
|
||||
wf-recorder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue