// -*- mode: jsonc -*-
{
    "layer": "top",
    "position": "top",
    "height": 30,
    "spacing": 4,
    "modules-left": [
        "niri/workspaces"
    ],
    "modules-center": [
    ],
    "modules-right": [
        "custom/void-updates",

{% for iface in host.wireless + host.ethernet %}
        "network#{{ iface }}",
{% endfor %}

{% if not host.ethernet and host.auto_ethernet %}
        "network#auto_ethernet",
{% endif %}

        "wireplumber",
        "battery",
        "group/disks",
        "cpu",
        "memory",

{% if host.temperature_path %}
        "temperature",
{% endif %}

        "clock#utc",
        "clock#local",
        "custom/power",
    ],

    "niri/workspaces": {
        "format": "\uf111"
    },

    "custom/void-updates": {
        "exec": "waybar-void-update-checker",
        "hide-empty-text": true,
        "return-type": "json",
        // every 7 hours
        "interval": 25200,
        "on-click": "",
    },
    
{% for iface in host.wireless %}
    "network#{{ iface }}": {
        "interface": "{{ iface }}",
        "format": "\uf1eb",
        "tooltip-format": "{{ iface }} {ipaddr} {essid} {signalStrength}",
        "tooltip-format-disconnected": "{{ iface }} down"
    },
{% endfor %}

{% for iface in host.ethernet %}
    "network#{{ iface }}": {
        "interface": "{{ iface }}",
        "format": "\uf6ff",
        "tooltip-format": "{{ iface }} {ipaddr}",
        "tooltip-format-disconnected": "{{ iface }} down"
    },
{% endfor %}

{% if not host.ethernet and host.auto_ethernet %}
    "network#auto_ethernet": {
        "interface": "en*",
        "format": "\uf6ff",
        "tooltip-format": "{{ iface }} {ipaddr}",
        "tooltip-format-disconnected": "{{ iface }} down"
    },
{% endif %}

    "wireplumber": {
        "format": "{icon} {volume}%",
        "format-muted": "\uf6a9 {volume}%",
        "format-icons": ["\uf026", "\uf027", "\uf028"]
    },

{% if host.has_battery %}
    "battery": {
        "design-capacity": true,
        "format": "{icon} {capacity}% {time}",
        "format-time": "{H}:{m}",
        "format-icons": [
            "\uf244",
            "\uf243",
            "\uf242",
            "\uf241",
            "\uf240",
        ],
        "states": {
            "warning": 30,
            "critical": 10,
        },
        "format-charging": "\ue55b {capacity}% {time}",
        "format-full": "\ue55c {capacity}%",
    },
{% endif %}

    "group/disks": {
        // TODO: make drawer that expands orthogonally, outside of the bar
        "orientation": "inherit",
        "modules": [
{% for disk in host.disks %}
            "disk#{{ disk }}",
{% endfor %}
        ],
        "drawer": {}
    },

{% for disk in host.disks %}
    "disk#{{ disk }}": {
        "path": "{{ disk }}",
        "format": "{{ disk }} {free}",
        "tooltip-format": "{used} / {total} ({percentage_used}%)",
        "states": {
            "warning": 70,
            "critical": 90
        }
    },
{% endfor %}

    "cpu": {
        "format": "\uf2db {usage}%",
        "tooltip": false,
        "states": {
            "warning": 70,
            "critical": 90
        }
    },
    "memory": {
        "format": "\uf538 {percentage}%",
        "tooltip-format": "{used}GiB / {total}GiB",
        "states": {
            "warning": 70,
            "critical": 90
        }
    },

{% if host.temperature_path %}
    "temperature": {
        "format": "{temperatureC}°C",
        "hwmon-path": "{{ host.temperature_path }}"
    },
{% endif %}

    "clock#utc": {
        "interval": 5,
        "format": "{:%Y-%m-%d %H:%M:%S}",
        "timezone": "UTC",
        "tooltip": false
    },
    "clock#local": {
        "interval": 5,
        "format": "{:%H:%M}",
        "tooltip": false
    },
    "custom/power": {
        "format": "\uf011",
        "tooltip": false,
        "menu": "on-click",
        "menu-file": "$HOME/.config/waybar/power_menu.xml",
        "menu-actions": {
            "shutdown": "loginctl poweroff",
            "reboot": "loginctl reboot",
            "logout": "niri msg action quit"
        }
    }
}
