sh: only activate X11 if it's installed

Fixes #23835.