Skip to content

Commit

Permalink
fix(i3status-rs): tailscale on/off
Browse files Browse the repository at this point in the history
  • Loading branch information
workflow committed Oct 30, 2023
1 parent 7477b4f commit 590d555
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ in
# Syncthing tray
".config/syncthingtray.ini".source = ./dotfiles/syncthingtray.ini;

# Get tailscale IP if online
"bin/tailscale-ip" = { text = scripts.tailscale-ip; executable = true; };

# Variety
".config/variety/variety.conf".source = ./dotfiles/variety.conf;
};
Expand Down
6 changes: 3 additions & 3 deletions home/i3status-rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ in
++ [
{
block = "custom";
cycle = [ "echo -n '🦝 ' && sudo tailscale up --accept-routes --accept-dns=false && tailscale ip | head -n 1" "echo -n '🦝 ' && sudo tailscale down && echo down" ];
command = "echo -n '🦝 ' && /home/farlion/bin/tailscale-ip";
interval = 1;
click = [
{
button = "left";
action = "cycle";
cmd = "sudo tailscale up --accept-routes --accept-dns=false";
}
{
button = "right";
cmd = "alacritty -e fish -c 'tailscale status; exec fish'";
cmd = "sudo tailscale down";
}
];
}
Expand Down
11 changes: 11 additions & 0 deletions lib/scripts.nix
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ in
fi
'';

tailscale-ip = ''
${shebang}
# Get the current tailscale ip if tailscale is up
set -euo pipefail
isOnline=$(tailscale status --json | jq -r '.Self.Online')
if [[ "$isOnline" == "true" ]]; then
tailscaleIp=$(tailscale status --json | jq -r '.Self.TailscaleIPs[0]')
echo "$tailscaleIp"
fi
'';

nixos = ''
${shebang}
usage() {
Expand Down

0 comments on commit 590d555

Please sign in to comment.