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

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like