diff --git a/home/programs/polybar/config.ini b/home/programs/polybar/config.ini index abe23ee..9dbd5a6 100644 --- a/home/programs/polybar/config.ini +++ b/home/programs/polybar/config.ini @@ -62,7 +62,7 @@ foreground = ${colors.foreground} ;font-5 = Unifont:size=64:antialias=false;1 ; modules-left = date battery cpu memory coretemp pulseaudio-control network bluetooth cmus -modules-left = date battery cpu memory coretemp pulseaudio-control network bluetooth cmus +modules-left = date battery cpu memory coretemp pulseaudio-control network bluetooth tailscale cmus modules-center = title ; modules-right = pomodoro xkeyboard bspwm modules-right = xkeyboard bspwm diff --git a/home/programs/polybar/default.nix b/home/programs/polybar/default.nix index d1bab5a..cda42b7 100644 --- a/home/programs/polybar/default.nix +++ b/home/programs/polybar/default.nix @@ -29,6 +29,16 @@ format-foreground = ${colors.theme} ''; + tailscaleScript = pkgs.callPackage ./scripts/tailscale.nix {}; + tctl = '' + [module/tailscale] + type = custom/script + interval = 15 + exec = ${tailscaleScript}/bin/bluetooth-ctl + label-foreground = ${colors.foreground} + format-foreground = ${colors.theme} + ''; + ip = "/run/current-system/sw/bin/ip"; grep = "/run/current-system/sw/bin/grep"; awk = "/run/current-system/sw/bin/awk"; @@ -99,7 +109,7 @@ in { enable = true; package = mypolybar; config = ./config.ini; - extraConfig = bctl + internets + mon; + extraConfig = bctl + internets + mon + tctl; # my savior: https://www.reddit.com/r/NixOS/comments/v8ikwq/polybar_doesnt_start_at_launch/ script = '' # echo "none" diff --git a/home/programs/polybar/scripts/bluetooth.nix b/home/programs/polybar/scripts/bluetooth.nix index b95a408..3067feb 100644 --- a/home/programs/polybar/scripts/bluetooth.nix +++ b/home/programs/polybar/scripts/bluetooth.nix @@ -19,7 +19,7 @@ in then echo "%{F#2193ff}" else - echo "%{F#2193ff} %{F#ffffff}[$device]" + echo "%{F#2193ff} %{F#ffffff}[$device]" fi fi '' diff --git a/home/programs/polybar/scripts/tailscale.nix b/home/programs/polybar/scripts/tailscale.nix new file mode 100644 index 0000000..604c0db --- /dev/null +++ b/home/programs/polybar/scripts/tailscale.nix @@ -0,0 +1,15 @@ +{pkgs, ...}: let + # bctl = "/run/current-system/sw/bin/bluetoothctl"; + # sctl = "/run/current-system/sw/bin/systemctl"; + # grep = "/run/current-system/sw/bin/grep"; + # wc = "/run/current-system/sw/bin/wc"; + tailscale = "/run/current-system/sw/bin/tailscale"; + rg = "/etc/profiles/per-user/synchronous/bin/rg"; + hostname = "/run/current-system/sw/bin/hostname"; + ip = "/run/current-system/sw/bin/ip"; + cut = "/run/current-system/sw/bin/cut"; + awk = "/run/current-system/sw/bin/awk"; +in + pkgs.writeShellScriptBin "tailscale-ctl" '' + tailscale status | rg "$(hostname)" &> /dev/null && echo "%{F#2193ff}🔗 [$(ip addr show tailscale0 | rg "inet " | awk '{print $2}' | cut -d'/' -f1 )]" || echo "" + ''