Files
blomarchy/bin/blob-hw-hybrid-gpu

25 lines
668 B
Bash
Executable File

#!/bin/bash
# blob:summary=Detect whether the system has an active hybrid GPU configuration
multiple_gpus() {
(($(lspci | grep -cE 'VGA|3D|Display') >= 2))
}
if blob-cmd-present supergfxctl; then
# A wedged supergfxd blocks its clients forever, and this gate runs while
# the menu renders. Bound the query, and treat a daemon that cannot answer
# like a machine without supergfxctl: count GPUs instead of hiding hardware
# that is really there.
modes=$(timeout --kill-after=1s 1s supergfxctl -s 2>/dev/null)
status=$?
if ((status == 124 || status == 137)); then
multiple_gpus
else
grep -qw Hybrid <<<"$modes"
fi
else
multiple_gpus
fi