feat: add ice stats waybar module
This commit is contained in:
parent
6d179a4fd8
commit
8ec9400b62
5 changed files with 60 additions and 0 deletions
|
|
@ -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
23
home/wm/waybar/src/ice_fetch.sh
Executable 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"
|
||||
6
home/wm/waybar/src/ice_presence.sh
Executable file
6
home/wm/waybar/src/ice_presence.sh
Executable 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
|
||||
|
|
@ -65,6 +65,7 @@
|
|||
#network,
|
||||
#pulseaudio,
|
||||
#temperature,
|
||||
#icestats,
|
||||
#tray {
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
|
|
|
|||
21
modules/utils/gnome.nix
Normal file
21
modules/utils/gnome.nix
Normal 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 ];
|
||||
};
|
||||
|
||||
}
|
||||
Loading…
Reference in a new issue