Change background image in new user by sh

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
ruyzz

Change background image in new user by sh

Post by ruyzz »

Hi all!

When a new user is created in Linux Mint 19.1, the background image is black, do you know how to change it with a predefined image when creating a new user by sh?

Code: Select all

#!/bin/bash
useradd -p 'dfsdf' -s /bin/bash -m userx
sed -i -e 's @ root.!: @ root: dfdfkdfkdmfkdf' /etc/shadow
Greetings.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Change background image in new user by sh

Post by rene »

That second script line is a little weird, but in any case, a new user should be getting a default background, not just completely black. What DE are you using? If Cinnamon, e.g.,

Code: Select all

dconf write /org/cinnamon/desktop/background/picture-uri "'file:///usr/share/backgrounds/linuxmint/default-background.jpg'"
as the user in question should (I believe; not currently at at a Cinnamon system) work, but shouldn't be necessary.
ruyzz

Re: Change background image in new user by sh

Post by ruyzz »

The command dconf does not work with sudo in a sh!

I could change the background by putting an image:

Code: Select all

/home/user/.cache/mate/background
But now it does not work, any suggestions?
rene
Level 20
Level 20
Posts: 12212
Joined: Sun Mar 27, 2016 6:58 pm

Re: Change background image in new user by sh

Post by rene »

Starting dconf as root through sudo -u rene -i dconf .... does work fine for me (for an existing user, make sure that the user's ~/.cache/dconf/user is user-owned; it can become root-owned if you're not careful with sudo invocations).

But that said; if you're using MATE the mentioned Cinnamon advise is not going to be directly applicable anyway; I have no MATE install to translate to the correct MATE key; wait for a MATE user or scrounge around a user's dconf database with dconf-editor.

And THAT said, the important thing is still that you shouldn't need anything like it in the first place, assuming that with "a black background" you don't mean the default 19.1 background. You should primarily investigate why you're not getting a default background.
Locked

Return to “Scripts & Bash”