Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

I need a system call to change the desktop background

Graphical Environments, Managers, Multimedia & Desktop questions.
Message
Author
Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

I need a system call to change the desktop background

#1 Post by Caitlin »

I'm writing a C program that will change the background of the desktop. (I'm using Marco under MATE.)

I need to program down to the bare metal on this; no apps, parameter settings, packages, or GUI menus.

Is there a system call that says, switch to this desktop background now?

(I've checked Google and searched the DUF for this. No success.)

Caitlin

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: I need a system call to change the desktop background

#2 Post by trinidad »

Is there a system call that says, switch to this desktop background now?
I don't understand the question. Marco is GTK3 and Mate controls the default desktop background image on the root file system. Log in as root and replace the default background with your own renaming the replaced one old_default (whatever its default name is) and renaming the new one as default. Otherwise there are ways to pass backgrounds from Grub2 directly overriding the default background display. You could also use update and journal recovery... but I guess, just a guess here, that one could write in C to control/modify gsettings to accomplish the task, but I'm still not sure what/why the task is here since such settings controls are already available.
I need to program down to the bare metal on this
Desktop background is on /fs so no bare metal available unless you want to write microcode, otherwise you would have to require buffer and payload first which is not bare metal. With C, as far as I know, with no other code injection, you could only get gray and/or black, or a monitor default, or nothing at all for a background.
I'm writing a C program that will change the background of the desktop. (I'm using Marco under MATE.)
There are probably people here better qualified to answer this, but the question itself, as you have qualified it, may make no sense to them either.

Just in case this involves AWS check the link below:
https://aws.amazon.com/blogs/desktop-an ... workspace/

TC
You can't believe your eyes if your imagination is out of focus.

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: I need a system call to change the desktop background

#3 Post by stevepusser »

I know that Variety (in the repos) has to handle KDE differently than most of the other desktops. Maybe you could take a look at its Python code to see how Peter Levi handled it.
MX Linux packager and developer

Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

Re: I need a system call to change the desktop background

#4 Post by Caitlin »

I don't understand these answers. But I will say I need to be able to change backgrounds, pointing Marco to an image of my own choosing, WITH A SYSTEM CALL so I don't have to do it myself each time I want to change backgrounds (which would be often). Perhaps "bare metal" was the wrong phrase for what I want to do.

I do know Variety does change the background (and that's ALL I know about it), but how? If I could figure that out, my question would be answered. I could not figure where the Variety source is (and I don't know Python anyway).

Any ideas?

Caitlin

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: I need a system call to change the desktop background

#5 Post by trinidad »

To permanently set a default wallpaper you would need to compile the Mate schema over again using a glibc wrapper. Files can then be saved in schema or skel. I'm still confused with what you are trying to do. Mate comes with a wallpaper changer.

https://guide.ubuntu-mate.org/#personalization

You could just alias a bashism to do what you want with a one word command. Perhaps that's what you mean by shouting "SYSTEM CALL" but that's not what a system call is.

https://en.wikipedia.org/wiki/System_call

TC
Last edited by trinidad on 2021-08-24 14:59, edited 1 time in total.
You can't believe your eyes if your imagination is out of focus.

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1400
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 175 times

Re: I need a system call to change the desktop background

#6 Post by steve_v »

Caitlin wrote: 2021-08-24 09:02I don't understand these answers.
Probably something to do with nobody understanding your question. Particularly this:
Caitlin wrote: 2021-08-24 09:02no apps, parameter settings, packages, or GUI menus
And this:
Caitlin wrote: 2021-08-24 09:02WITH A SYSTEM CALL
There is no "system call". The desktop background isn't handled by the "system", it's set by whatever is drawing to the root window of the X server (assuming you're running X). That whatever is almost certainly your window manager or DE.
The closest you will get to "bare metal" (again, confusing) is to do it directly with Xlib and co. You might have a look at the source for something like feh to see how they're doing it... But chances are extremely good that your WM/DE will simply stomp on your changes if you go this route.
Odds are it's not something anyone here has done or wanted to do either, because frankly it would be reinventing a perfectly good wheel for no rational gain.

If you want to get your WM or DE to change the wallpaper, you'll need to interact with it, not X, and not this supposed "system".
I don't run mate myself, but IIRC it uses gsettings, so that means something like 'gsettings set org.mate.background <filename>'.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: I need a system call to change the desktop background

#7 Post by CwF »

Flip your thinking! The desktop background is nowhere close to a low level function, it's a very very high level function. I don't believe there is only one 'system level' way it is done. It is more a 'DE' function, or an xorg XDG function, or something in wayland....all different.

I've used Feh, until I decided to just go black...

the steve*s got you covered..

Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

Re: I need a system call to change the desktop background

#8 Post by Caitlin »

(1) It seems I can write something like {system("gsettings ...");} in a program to do what I want.

(2) Yes, a system call is EXACTLY what I want.

(3) I don't want to change the background permanently. It would be one thing at some time and something else at other times.

(4) I specifically do not want to get into a terminal or anything else like that to make the change when I want it to change. Entering one word is entering one word too many.

I looked into gsettings and found a confusing jumble of something about schemas.

Any suggestions about what the command should be?

Caitlin

Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

Re: I need a system call to change the desktop background

#9 Post by Caitlin »

UPDATE: I tried entering "gsettings set org.mate.background picture-filename /ddisk/f/scans/UpTrain.png" in a root terminal but it just told me "(process:3014) dconf-WARNING ** : 22:14:35.613: failed to commit changes to dconf: The connection is closed". I think I'm on the right track though. (If you were wondering, Up stands for Union Pacific.) Do I have to open the connection somehow?

Caitlin

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1400
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 175 times

Re: I need a system call to change the desktop background

#10 Post by steve_v »

Caitlin wrote: 2021-08-31 20:09a system call is EXACTLY what I want.
Either you're still confused as to what handles drawing the desktop, or you've got your definitions mixed up. A system call is a call to the operating system kernel. You cannot effect the desktop background with a call to the Linux kernel, because aside from low-level driver functions it has nothing to do with drawing the desktop.
Caitlin wrote: 2021-08-31 20:18I looked into gsettings and found a confusing jumble of something about schemas.
The docs look quite readable to me, but again I don't run MATE/GNOME, so I have no convenient way to test it and I'm not going to dig too much deeper.
Caitlin wrote: 2021-08-31 20:18root terminal
I expect you will need to be the same user as the session you're trying to communicate with.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

User avatar
oswaldkelso
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1490
Joined: 2005-07-26 23:20
Location: UK
Has thanked: 1 time
Been thanked: 58 times

Re: I need a system call to change the desktop background

#11 Post by oswaldkelso »

When using icewm or TWM I use this to randomly swap one of the 3000 wallpapers I have. Needs feh . YMMV

Code: Select all

#!/bin/bash
# If used as a wallpaper/photo-frame switcher make sure the images are large enough!

while true; do
  find ~/images/backgrounds/ -type f \( -name '*.jpg' -o -name '*.png' \) -print0 |
    shuf -n1 -z | xargs -0 feh --bg-scale
    sleep 30s
done
Free Software Matters
Ash init durbatulûk, ash init gimbatul,
Ash init thrakatulûk agh burzum-ishi krimpatul.
My oldest used PC: 1999 imac 333Mhz 256MB PPC abandoned by Debian

shep
Posts: 423
Joined: 2011-03-15 15:22

Re: I need a system call to change the desktop background

#12 Post by shep »

This is usually configured by the login Display manager.
https://wiki.debian.org/DisplayManager
I'm not sure which DM is installed with Mate (gdm vs lightdm), but web searches for whatever you have should show how to configure slideshow type backgrounds or random backgrounds.

Caitlin
Posts: 329
Joined: 2012-05-24 07:32
Has thanked: 3 times
Been thanked: 2 times

Re: I need a system call to change the desktop background

#13 Post by Caitlin »

Grrr -- I DON'T NEED NO ******* SLIDESHOW! That's not even close to what I'm trying to accomplish.

To restate it -- I want to be able to have a program do something to change the desktop background. It will be IN RESPONSE to an event; not something mundane and trivial like it's been 3 hours since the last change.

A configuration type change is NOT going to do what I want it to -- unless it's a system call (AND YES, I DO MEAN SYSTEM CALL OR AT LEAST SOME SORT OF FUNCTION OR METHOD) that changes the configuration when it executes that line of code. "Random" has absolutely nothing to do with it.

Caitlin

trinidad
Posts: 290
Joined: 2016-08-04 14:58
Been thanked: 14 times

Re: I need a system call to change the desktop background

#14 Post by trinidad »

IN RESPONSE to an event
Define the event and then write the script for the onboard wallpaper changer that will cue the change. Something like YAD should work OK for this without a window. You'll need the dialogue and the else if script,
YES, I DO MEAN SYSTEM CALL
Doesn't matter if you do. Your computer sure doesn't. You're making my ears hurt. Switch to a sub-script for a while.

TC
You can't believe your eyes if your imagination is out of focus.

User avatar
oswaldkelso
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1490
Joined: 2005-07-26 23:20
Location: UK
Has thanked: 1 time
Been thanked: 58 times

Re: I need a system call to change the desktop background

#15 Post by oswaldkelso »

Grrr :mrgreen:

As only Caitlin knows what events are required I'd suggest using xprop or something similar to list the events.
Free Software Matters
Ash init durbatulûk, ash init gimbatul,
Ash init thrakatulûk agh burzum-ishi krimpatul.
My oldest used PC: 1999 imac 333Mhz 256MB PPC abandoned by Debian

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1400
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 175 times

Re: I need a system call to change the desktop background

#16 Post by steve_v »

Caitlin wrote: 2021-09-03 15:23 I DO MEAN SYSTEM CALL OR AT LEAST SOME SORT OF FUNCTION OR METHOD
Nobody is going to hand you a "change the wallpaper, works on every DE/WM" C "system call" on a silver platter. Especially if you shout at them. Why? Because there isn't one.

I'll spell it out one more time, and then I'm done:
There. Is. No. System. Call. The nearest you're going to get to "low level" is a bunch of mucking about with Xlib primitives from the '70s. See the SetBackgroundToBitmap function in the xsetroot source for example.
Note it only handles bitmaps, because Xlib only handles bitmaps.

To return to the OP, again:
Is there a system call that says, switch to this desktop background now?
No. No there is not.


I pointed you to the feh source code already. If you had actually studied any of it, and really intended to write a C program to do (some of) what it does, you wouldn't still be asking for this "system call" unicorn... You'd be asking what the best image conversion library to use is.


Also, in C we call a function a function. Methods are for java scrubs. :P Your terminology is still all over the place, and still confusing.
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

User avatar
golinux
Posts: 1579
Joined: 2010-12-09 00:56
Location: not a 'buntard!
Been thanked: 1 time

Re: I need a system call to change the desktop background

#17 Post by golinux »

Xfce has a desktop function (just right click on the desktop) to change the wallpaper every X minutes. Caveat . . . I'm still on jessie and not going to boot up an iso to see if it's still there in later releases because dinner is ready. Also I have never used it.
May the FORK be with you!

CwF
Global Moderator
Global Moderator
Posts: 2638
Joined: 2018-06-20 15:16
Location: Colorado
Has thanked: 41 times
Been thanked: 192 times

Re: I need a system call to change the desktop background

#18 Post by CwF »

golinux wrote: 2021-09-03 23:25 not going to boot up an iso to see if it's still there
It is. And a genmon could make quick work of this frivolous desire.

User avatar
golinux
Posts: 1579
Joined: 2010-12-09 00:56
Location: not a 'buntard!
Been thanked: 1 time

Re: I need a system call to change the desktop background

#19 Post by golinux »

Also on Xfce, you can right click on any image and set it as the desktop wallpaper. Can't be easier than that. I'm surprised that Mate doesn't have a function like that.
May the FORK be with you!

steve_v
df -h | grep > 20TiB
df -h | grep > 20TiB
Posts: 1400
Joined: 2012-10-06 05:31
Location: /dev/chair
Has thanked: 79 times
Been thanked: 175 times

Re: I need a system call to change the desktop background

#20 Post by steve_v »

golinux wrote: 2021-09-03 23:25Xfce has a desktop function (just right click on the desktop) to change the wallpaper every X minutes.
Pretty sure the OP wants to do this programmatically, with more flexible (or more nebulous, they don't say) conditions. There've been "x app/desktop can do timed/random changes" comments already, and that just started a bunch of shouting.
Personally I'd just do this kind of thing from bash, by calling some generic background-setter or the config tool relevant to the DE...

But then there's all the yammering about "system call"s and "low level", as well as the mention of "a C program".
IMO either the OP needs to go read (or steal) some source code for existing tools, or rethink their approach because they're trying to use a bazooka (custom C program) to kill mosquitoes (calling gconf or feh from a shell script).
Once is happenstance. Twice is coincidence. Three times is enemy action. Four times is Official GNOME Policy.

Post Reply