Display network name and IP address
All checks were successful
/ check (push) Successful in 51s

This commit is contained in:
Oliver Davies 2025-08-19 23:51:52 +01:00
parent 5e1ef25879
commit 2d488eaa7a
2 changed files with 26 additions and 0 deletions

View file

@ -8,6 +8,8 @@
static const Block blocks[] = {
{"", "status-audio", 10, 0},
{"", "status-network", 10, 0},
{"", "status-battery", 60, 0},
{"", "free -h | awk '/^Mem/ { printf \"%s/%s RAM\\n\", $3, $2 }' | sed 's/i//g'", 30, 0},

View file

@ -0,0 +1,24 @@
{
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"
'';
})
];
};
}