@@ -893,6 +893,30 @@ def check_kernel_userspace_mismatch(self, attempt_fix=True, fix_with_x11=False):
893893 else :
894894 raise RuntimeError ("Unable to continue while mismatch is present." )
895895
896+ def run_raspi_config (self , args , suppress_message = False , return_output = False , run_as_user = None ):
897+ """
898+ Run a ``raspi-config nonint ...`` command, but only on Raspberry Pi OS.
899+
900+ ``raspi-config`` is only shipped (and only honored) on Raspberry Pi OS;
901+ on other distros (DietPi, Ubuntu, etc.) the binary is absent and the
902+ tweak would not apply anyway. On non-Pi-OS systems this method is a
903+ no-op that returns ``True`` (or ``""`` when ``return_output=True``)
904+ so existing call sites continue to work without producing misleading
905+ "command not found" output.
906+
907+ ``args`` is the part after ``raspi-config nonint`` (e.g. ``"do_spi 0"``).
908+ ``suppress_message``, ``return_output``, and ``run_as_user`` are
909+ forwarded to :meth:`run_command`.
910+ """
911+ if not self .is_raspberry_pi_os ():
912+ return "" if return_output else True
913+ return self .run_command (
914+ "raspi-config nonint " + args ,
915+ suppress_message = suppress_message ,
916+ return_output = return_output ,
917+ run_as_user = run_as_user ,
918+ )
919+
896920 def set_window_manager (self , manager ):
897921 """
898922 Call raspi-config to set a new window manager
@@ -907,9 +931,7 @@ def set_window_manager(self, manager):
907931 raise RuntimeError ("labwc is not installed" )
908932
909933 print (f"Using { manager } as the window manager" )
910- if not self .run_command (
911- "sudo raspi-config nonint do_wayland " + WINDOW_MANAGERS [manager .lower ()]
912- ):
934+ if not self .run_raspi_config ("do_wayland " + WINDOW_MANAGERS [manager .lower ()]):
913935 raise RuntimeError ("Unable to change window manager" )
914936
915937 def get_window_manager (self ):
0 commit comments