feat: add ice stats waybar module

This commit is contained in:
etwas 2025-05-18 09:04:26 +02:00
parent 6d179a4fd8
commit 8ec9400b62
Signed by: etwas
SSH key fingerprint: SHA256:bHhIeAdn/2k9jmOs6+u6ox98VYmoHUN3HfnpV2w8Ws0
5 changed files with 60 additions and 0 deletions

View file

@ -24,6 +24,7 @@
];
modules-center = [ "hyprland/window" ];
modules-right = [
"custom/icestats"
"pulseaudio"
"backlight"
"network"
@ -38,6 +39,14 @@
max-length = 10;
};
"custom/icestats" = {
exec = ./src/ice_fetch.sh;
exec-if = ./src/ice_presence.sh;
interval = 1;
tooltip = false;
return-type = "json";
};
memory = {
interval = 30;
format = " {}%";

23
home/wm/waybar/src/ice_fetch.sh Executable file
View file

@ -0,0 +1,23 @@
# Fetch the JSON data from the API
data=$(curl -s https://iceportal.de/api1/rs/status)
# Extract the speed value
speed=$(echo "$data" | jq -r '.speed')
# Check if the speed value is empty
if [ -z "$speed" ]; then
echo "{\"text\": \"N/A\", \"alt\": \"Speed data not available\", \"tooltip\": \"\", \"class\": \"unavailable\", \"percentage\": 0}"
exit 1
fi
# Create the JSON object
text="${speed} km/h"
alt="Current speed"
tooltip="Current speed of the train"
class="icestats"
percentage=0
json_output="{\"text\": \"${text}\", \"alt\": \"${alt}\", \"tooltip\": \"${tooltip}\", \"class\": \"${class}\", \"percentage\": ${percentage}}"
# Print the JSON object
echo "$json_output"

View file

@ -0,0 +1,6 @@
SSID=$(iwconfig wlp1s0 | grep ESSID | sed -e 's/.*ESSID:"\(.*\)"/\1/' | xargs)
if [[ $SSID == "WIFIonICE" ]]; then
exit 0
else
exit 1
fi

View file

@ -65,6 +65,7 @@
#network,
#pulseaudio,
#temperature,
#icestats,
#tray {
padding-left: 10px;
padding-right: 10px;

21
modules/utils/gnome.nix Normal file
View file

@ -0,0 +1,21 @@
{ pkgs, ... }:
{
services.udev.packages = with pkgs; [ gnome.gnome-settings-daemon ];
# From https://discourse.nixos.org/t/enable-wayland-on-gnome-kde/39412
services.xserver = {
# Required for DE to launch.
enable = true;
displayManager = {
gdm = {
enable = true;
wayland = true;
};
};
# Enable Desktop Environment.
desktopManager.gnome.enable = true;
# Exclude default X11 packages I don't want.
excludePackages = with pkgs; [ xterm ];
};
}