#!/bin/bash

Main() {
    echo "Session type: $XDG_SESSION_TYPE"
    local country=$(show-location-info --tolower country)
    echo "Detected country: $country"

    case "$XDG_SESSION_TYPE" in
        x11)
            case "$country" in
                us | gb | fr | it | es | de | fi | jp | cn | se)
                    echo "Setting keymap: $country"
                    ;;
                *)
                    local c="$country"
                    country=us
                    echo "Country '$c' not handled, falling back to '$country'"
                    ;;
            esac
            setxkbmap "$country"
            ;;
        wayland)
            echo "Wayland not supported"
            ;;
    esac
}

Main "$@"
