1

I'm trying to set a wallpaper from the terminal. The script is:

pcmanfm-qt --set-wallpaper=$(ls /home/$USER/.local/share/wallpapers/*/* | shuf -n1)

This changes the wallpaper, but I want it to be run automatically everytime I log in.

Tried to put this script in some suitable files like /etc/X11/xinit/xinitrc If I source the file it runs as expected but nothing happens when logging in.

Any help on where to put that line to be run everytime I log in? (preferably under my user folder and not globally)

I'm using Lubuntu 19.10 with Simple Desktop Display Manager (SDDM).

5
  • Find out what display manager (DM) you are using. I think in Lubuntu the stanard ist LightDM, but I am not sure. Find out what user configuration file your DM executes on session start (e.g. ~/.xsession, but depends on the DM). Use this to load your wallpaper.
    – dirkt
    Mar 31, 2020 at 18:23
  • @dirkt alright. It's SSDM Mar 31, 2020 at 18:54
  • @dirkt no luck, no config file around. Even if I create it nothing happens. Mar 31, 2020 at 19:12
  • Is ~/.config/lxsession/LXDE/autostart no longer a thing? Mar 31, 2020 at 21:10
  • @steeldriver but lubuntu 19.10 does not come with LXDE as the project is discontinued, I believe. it's lxqt and there in there is no autostart file. There is also a ~/.config/autostart/lxqt/ . this could work but I've tried there and once again no luck (this is probably me doing wrong things, dont know). Mar 31, 2020 at 21:28

3 Answers 3

1

As it's SDDM:

Looking at the manpage of sddm.conf, there's

SessionCommand=

Path of script to execute when starting the user session. This script receives the value of the "Exec" setting in the ".desktop" file of the selected session and runs it. Default value is "/etc/sddm/Xsession".

So create that file, or modify sddm.conf and add your own file, then try doing something in this file.

For debugging purposes, writing output via redirecting to some file in /tmp/ as a logfile is a useful technique.

So as initial step, try something like

echo "Session file executed" >> /tmp/my.log

and see if this does something when you log in. Then try to add your wallpaper command.

0

sddm.conf specifies several sections, of which you want the 'SessionCommand' parameter of the [Wayland] section. The default script, which is in "/etc/sddm/wayland-session" checks for and sources the following script files in your user's home directory:

In order:

$HOME/.bash_profile, $HOME/.bash_login, $HOME/.profile.

You should be able to place your wallpaper setting command in any of these three files in your home directory to activate it on login.

Note: I technically use Ubuntu and not Lubuntu, so there might be system differences, but this should be pretty default stuff across both distros.

-1

Here is an article that I found: https://smallbusiness.chron.com/run-command-startup-linux-27796.html

  1. Put the command in your crontab file. The crontab file in Linux is a daemon that performs user-edited tasks at specific times and events. To edit the file, open a terminal and type "sudo crontab -e" to open your crontab file in the default text editor. At the first available line, type "@reboot xxxx", where "xxxx" is the command you wish to run. Save the file and exit.
  2. Put a script containing the command in your /etc directory. Create a script such as "startup.sh" using your favorite text editor. Save the file in your /etc/init.d/ directory. Change the permissions of the script (to make it executable) by typing "chmod +x /etc/init.d/mystartup.sh".

  3. Edit the /rc.local script using your text editor. In lubuntu, it is located in /etc/rc.local. Once you add the commands you wish to run -- making sure you do so as root -- save the file and exit. The commands will run after the next startup.

1
  • Note that commands that need X won't work from cron (because the X connection might not even be available at the time the cron command is run). You can cheat and pretend it is, but that will lead to interesting effects when it isn't... So the proper place to put this is someplace that's guaranteed to have an X connection. Like the startup script of the X session.
    – dirkt
    Apr 1, 2020 at 4:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.