Change background image in new user by sh

Forum rules
Before you post please read how to get help
Post Reply
ruyzz
Level 1
Level 1
Posts: 25
Joined: Sat Feb 24, 2018 11:01 pm

Change background image in new user by sh

Post by ruyzz » Wed Jan 02, 2019 8:05 pm

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.

rene
Level 9
Level 9
Posts: 2581
Joined: Sun Mar 27, 2016 6:58 pm

Re: Change background image in new user by sh

Post by rene » Sun Jan 06, 2019 1:19 pm

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
Level 1
Level 1
Posts: 25
Joined: Sat Feb 24, 2018 11:01 pm

Re: Change background image in new user by sh

Post by ruyzz » Tue Jan 08, 2019 12:54 pm

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 9
Level 9
Posts: 2581
Joined: Sun Mar 27, 2016 6:58 pm

Re: Change background image in new user by sh

Post by rene » Tue Jan 08, 2019 3:18 pm

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.

Post Reply

Return to “Scripts & Bash”