I am trying to run the below code as part of a larger Python project to display information on an OLED screen using a startup service on a Raspberry Pi Linux set-up.
However, the username will not appear unless I run the script as sudo
can you please suggest a work around to allow this code to run correctly without sudo.
Thank you in advance!
import psutil
def main():
user = psutil.users()[0].name
print(user)
main()
with sudo
*username*
without sudo
[]