#!/bin/sh error() { echo $0: $* >&2 exit 2 } xconfig() { # uses nvidia-xconfig currently since it's actually driver-agnostic; # probably should switch to something else some day for i in $*; do [ -z "$i" ] || nvidia-xconfig -s --$i done } [ -z "$1" ] && echo "Usage: $0 enable => enable NVIDIA compositing $0 disable => disable NVIDIA compositing" && exit 1 # TODO: maybe drop -n? XDRIVER="`x11setupdrv -d -n | sed 's/^driver name:[[:blank:]]//'`" \ || error "x11setupdrv failed to get driver name" #[ "$XDRIVER" = "nvidia" ] || error "unsupported video driver, not nvidia" which nvidia-xconfig >&/dev/null || error "nvidia-xconfig not found" case $1 in enable|on) xconfig composite [ "$XDRIVER" = "nvidia" ] && xconfig allow-glx-with-composite add-argb-glx-visuals ;; disable|off) xconfig no-composite [ "$XDRIVER" = "nvidia" ] && xconfig no-allow-glx-with-composite no-add-argb-glx-visuals ;; *) error "unknown option: $1" ;; esac