diff --git a/.config/.gitignore b/.config/.gitignore index 5fed2eb..f6e4d0b 100644 --- a/.config/.gitignore +++ b/.config/.gitignore @@ -60,6 +60,8 @@ !river/** !kak/ !kak/** +!fastfetch/ +!fastfetch/** !.gitignore polybar/default diff --git a/.config/fastfetch/config.jsonc b/.config/fastfetch/config.jsonc new file mode 100644 index 0000000..e5f1d4d --- /dev/null +++ b/.config/fastfetch/config.jsonc @@ -0,0 +1,38 @@ +{ + "$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json", + "modules": [ + "title", + "separator", + "os", + "host", + "kernel", + "uptime", + "packages", + "shell", + "display", + "de", + "wm", + "wmtheme", + "theme", + "icons", + "font", + "cursor", + "editor", + "terminal", + "cpu", + "gpu", + "memory", + "swap", + "disk", + { + "type": "command", + "shell": "/usr/bin/bash", + "text": "~/.config/fastfetch/nic.sh", + "key": "NIC" + }, + "battery", + "poweradapter", + "break", + "colors" + ] +} diff --git a/.config/fastfetch/nic.sh b/.config/fastfetch/nic.sh new file mode 100755 index 0000000..686db50 --- /dev/null +++ b/.config/fastfetch/nic.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +set -e + +# Get the default route +default_route=$(ip route | grep default) + +# Extract the NIC interface name +nic=$(echo $default_route | awk '{print $5}') + +# Get current link speed of interface +link_speed=$(ethtool $nic 2>/dev/null | grep "Speed:" | awk '{print $2}') + +# Get the PCI ID for the NIC interface +pci_id=$(ethtool -i $nic 2>/dev/null | grep bus-info | awk '{print $2}') + +# Extract speed and unit +speed_value=$(echo $link_speed | sed 's/[A-Za-z\/]*//g') +speed_unit=$(echo $link_speed | sed 's/[0-9]*//g') + +# Convert speed to a human-readable format +case $speed_unit in + "Mb/s") + if [ $speed_value -ge 1000 ]; then + speed_value=$(bc <<< "scale=1; $speed_value/1000") + speed_unit="Gb/s" + fi + ;; + "Gb/s") + # If you need to handle more units, you can extend here + ;; + *) + #echo "Unknown speed unit: $speed_unit" + speed_value="" + speed_unit="" + ;; +esac + +# Check if PCI ID is found +if [ -z "$pci_id" ]; then + #echo "PCI ID not found for interface: $nic" + exit 1 +else + # Get the human-readable name of the device + device_name=$(lspci -s $pci_id | cut -d ' ' -f 4-) +fi + +# Hee Hoo jank :) +if [[ ! -z $speed_value && ! -z $speed_unit ]]; then + speed_value="[${speed_value}" + speed_unit="${speed_unit}]" +else + speed_value="" + speed_unit="" +fi + +echo "$device_name" "${speed_value} ${speed_unit}"