How Do I Find Relative Files in Python with Ubuntu?

Basically, I am trying to set the background of ubuntu to a file, and I pretty much need to use relative paths.

I have looked at other people's and tried what they did but it didn't work, it just changes the background to a dark blue colour.

My code: os.system('gsettings set org.gnome.desktop.background picture-uri file:../Installer/Assets/BG.png')

Also, I am using Ubuntu 21.10 and yes, I have added the OS module.

2

1 Answer

Thanks, user535733 I changed the code so it uses PWD to find it.

os.system('gsettings set org.gnome.desktop.background picture-uri file:$PWD/Assets/BG.png')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.

Share this article
Twitter Facebook Pinterest