nix-config/modules/hosts/t480/dwm/dwmblocks/network.nix
Oliver Davies 2d488eaa7a
All checks were successful
/ check (push) Successful in 51s
Display network name and IP address
2025-08-19 23:51:53 +01:00

24 lines
638 B
Nix

{
flake.modules.homeManager.gui =
{ pkgs, ... }:
{
home.packages = [
(pkgs.writeShellApplication {
name = "status-network";
runtimeInputs = with pkgs; [ networkmanager ];
text = ''
connected_to="$(nmcli | grep "connected to")"
network_name="$(echo "$connected_to" | awk '{print $NF}')"
connected_device="$(echo "$connected_to" | cut -d ':' -f 1)"
ip_address="$(ip a | grep "$connected_device" | grep inet | awk '{print $2}'| cut -d '/' -f 1)"
echo "$network_name $ip_address"
'';
})
];
};
}