Skip to content

Add user to hardware groups in Blinka installer #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 26, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions raspi-blinka.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"""

import os
import sys

try:
from adafruit_shell import Shell
Expand All @@ -16,7 +15,7 @@
shell = Shell()
shell.group="Blinka"
default_python = 3
blinka_minimum_python_version = 3.7
blinka_minimum_python_version = 3.8

def default_python_version(numeric=True):
version = shell.run_command("python -c 'import platform; print(platform.python_version())'", suppress_message=True, return_output=True)
Expand Down Expand Up @@ -107,6 +106,15 @@ def check_and_install_for_pi5(pi_model, user=False):
else:
print(f"Detected {pi_model}, no additional fixes needed.")

def check_user_groups():
# Check if the user has the groups i2c, spi, gpio, input, and video. If the user is not in a group, then they need to be added.
groups = shell.run_command("groups", suppress_message=True, return_output=True).split()
required_groups = ["i2c", "spi", "gpio", "input", "video"]
for group in required_groups:
if group not in groups:
print(f"Adding user to the group: {group}.")
shell.run_command(f"sudo usermod -aG {group} {os.environ['SUDO_USER']}")

def main():
global default_python
shell.clear()
Expand Down Expand Up @@ -143,6 +151,7 @@ def main():
update_python()
update_pip()
install_blinka(True)
check_user_groups()

# Check and install any Pi 5 fixes if detected
check_and_install_for_pi5(pi_model, True)
Expand Down