#!/bin/sh

if [ $(which pkexec) ]; then
	XHOST_LOCAL=false
	if [ $XDG_SESSION_TYPE == "wayland" ] && [ $(which xhost) ] && [ -z $(xhost | grep "LOCAL:") ]; then
		xhost +local:
		XHOST_LOCAL=true
	fi

	pkexec --disable-internal-agent "/usr/bin/cpu-x" "$@"

	if $XHOST_LOCAL; then
		xhost -local:
	fi
else
	/usr/bin/cpu-x "$@"
fi
