#!/bin/bash
# Prerequisites
sudo pacman --noconfirm -Syu cabextract;

contextRoot="$(mktemp -d)";
repo="https://github.com/manuth/xone.git";
pushd "$contextRoot" > /dev/null;

if lsmod | grep xone > /dev/null;
then
    git clone "$repo" "$contextRoot";
    sudo "$contextRoot/install.sh" --release;
    yes "" | sudo xone-get-firmware.sh;
fi;

popd;
rm -rf "$contextRoot" > /dev/null;