04-16-2025, 08:57 PM
I would suggest that you modify getUserID in common.php to retrieve whatever username is assigned uid:gid of 1000:1000 in /etc/passwd
Reasoning: According to the comment before the function definition, the assumption is that there will only be one user directory under /home and that will be the user id/name entered into the Raspberry Pi Imager. There is no guarantee that is always going to be the case and, if a second (or third or more) id created, that can break the local display xterm setup. Specifically, the wrong username can be entered in /lib/systemd/system/localdisplay.service, which will cause the local display to abend. What is true, however, is that the UID:GID for the account entered into the imager is ALWAYS going to be 1000:1000 and using that as the basis for fetching the username will ensure that the correct username is returned regardless of how many additional accounts the user creates.
Suggested replacement function:
function getUserID()
{
$userID = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f1') ;
if ( $userID != 'pi' )
{
$targetDir = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f6' ) ;
// The /home/pi is created by the moode-player package install during in-place update.
// If it exists, copy xinitrc script to the installation owners home directory and delete /home/pi
if (file_exists('/home/pi/.xinitrc'))
{
sysCmd('cp /home/pi/.xinitrc $targetDir');
sysCmd('rm -rf /home/pi/');
}
}
return $userId;
}
Reasoning: According to the comment before the function definition, the assumption is that there will only be one user directory under /home and that will be the user id/name entered into the Raspberry Pi Imager. There is no guarantee that is always going to be the case and, if a second (or third or more) id created, that can break the local display xterm setup. Specifically, the wrong username can be entered in /lib/systemd/system/localdisplay.service, which will cause the local display to abend. What is true, however, is that the UID:GID for the account entered into the imager is ALWAYS going to be 1000:1000 and using that as the basis for fetching the username will ensure that the correct username is returned regardless of how many additional accounts the user creates.
Suggested replacement function:
function getUserID()
{
$userID = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f1') ;
if ( $userID != 'pi' )
{
$targetDir = sysCmd('grep 1000:1000 /etc/passwd | cut -d: -f6' ) ;
// The /home/pi is created by the moode-player package install during in-place update.
// If it exists, copy xinitrc script to the installation owners home directory and delete /home/pi
if (file_exists('/home/pi/.xinitrc'))
{
sysCmd('cp /home/pi/.xinitrc $targetDir');
sysCmd('rm -rf /home/pi/');
}
}
return $userId;
}