#!/bin/sh

. /etc/control.d/functions

FILE=nvidia_gbm.sh
CONFIG=/etc/profile.d/$FILE

new_summary "Controls for Nvidia GBM backend"

is_trace_enabled='^export __NV_GBM_TRACE_ENABLED=1$'
enable_trace='s,^\(export\ __NV_GBM_TRACE_ENABLED\)=0$,\1=1,'

is_no_trace_enabled='^export __NV_GBM_TRACE_ENABLED=0$'
enable_no_trace='s,^\(export\ __NV_GBM_TRACE_ENABLED\)=1$,\1=0,'

new_subst trace "$is_trace_enabled" "$enable_trace"
new_subst no_trace "$is_no_trace_enabled" "$enable_no_trace"

new_help trace "Enable GBM tracing"
new_help no_trace "Disable GBM tracing"

is_builtin_mode "$*" ||
	[ "$*" != "`control_subst "$CONFIG" status`" ] || exit 0

control_subst "$CONFIG" "$*" || exit 1

is_builtin_mode "$*" ||
	echo "Don't forget to relogin or even restart your PC after applying this change!" || exit 0
