How to change background image programatically?
-
Hello everyone,
I am a noob, trying to become more familiar with making apps and i created a test project for myself in which i am trying to make an app that changes the background to a random image in a specific folder each hour of the day.
This seemed like it should not be too difficult but I am running into some issues. I am currently messing around in an adb shell with gsettings and also trying dbus-send and gdbus with org.freedesktop.Accounts.User BackgroundFile but when i try to Set the value, it does not update since i don't have write ability. I am assuming this is due to sandboxing. Is there a recommended way of interacting with the system to change the background programatically?
I tried looking through the documentation but I can't find anything that really describes any of this.
-
@AdFundum did you find a command that works from the terminal/adb shell? If so, does that command work if you make your app unconfined?
Its possible that UT does not have an app armor policy that fits your use case, and that's the cause of your problem. From the list of policy groups I cannot see anything that would allow a confined app to change the background image.
https://docs.ubports.com/no/latest/appdev/platform/apparmor.html
-
@AdFundum i dont know about confined use but i know how to do it, its not a single command and has a couple of steps. look at lss background module its basically the how to for it.
-
Hi, sorry for the late response, I don't have a lot of spare time so progress on this goes very slowly.
Not yet, I now going to try running in the app directly because maybe the adb shell is sandboxed differently from an unconfined app.
That is an interesting suggestion, I had not thought of it. When I try to interact via the command line with lomiri-system-settings I am getting errors, but I found the background plugin folder in the source code.
https://gitlab.com/AdamSchrey/lomiri-system-settings/-/tree/main/plugins/background?ref_type=heads
I am going to see if I can bruteforce it by copying the logic from the source code for my own app and running it unconfined.
Probably won't work but I might learn something interesting in the attempt. -
@AdFundum thats essentially what i did, ill upload my implemention once i get home to my laptop in roughly 3h.
-
That would be awesome, thanks!
-
@AdFundum here is the code, it doesn't work yet for what i want it to do but the change background part works:
https://pastebin.com/EHuAkQvbEDIT:
ignore the comment// for some reason lss goes stale and we don't see the new background.its an lss bug, the background will be set but if you have lss open on the background page while you set it it will not update you'll need to refresh the page (by going out and in again)
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login