#!/bin/env fish
begin
    set -l dir (status dirname)
    source "$dir/../../Scripts/software.fish"

    function installSW
        set -l contextRoot (mktemp -d)
        set -l repo https://github.com/manuth/xone.git
        yayinst cabextract

        if not dkms status --all | grep xone > /dev/null
            git clone "$repo" "$contextRoot"
            sudo env -C "$contextRoot" ./install.sh --release
            sudo chmod -R a+rx /usr/src/xone*
            yes "" | sudo xone-get-firmware.sh
        end

        rm -rf "$contextRoot" > /dev/null
    end

    runInstaller $argv
end