Score:0

How do I find relative files in python with ubuntu?

gh flag

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.

ar flag
Please [edit your question](https://askubuntu.com/posts/1396172/edit) and add OS information.
user535733 avatar
cn flag
You must find a way to define the relative path. It's not hard. Just ask yourself: Are you using a user's /home dir? Or the PWD? Or something else? And construct your path that way.
Score:0
gh flag

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')

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.