#!/usr/bin/bash

set -eu

if [[ $EUID -ne 0 ]]; then
	exec pkexec --disable-internal-agent "$0" "$@"
fi

turbo_takeover() {
	value=${1}
	echo "${value}" >/sys/devices/platform/oxp-platform/tt_toggle
}

if [[ $1 == "turbo_takeover" ]]; then
	if [[ ! -f /sys/devices/platform/oxp-platform/tt_toggle ]]; then
		echo "Turbo toggle does not exist."
		exit 1
	fi
	turbo_takeover "$2"
fi

if [[ $1 == "startInputPlumber" ]]; then
	systemctl enable --now inputplumber
fi

if [[ $1 == "startPowerStation" ]]; then
	systemctl enable --now powerstation
fi
