User avatar
raymate
Posts: 143
Joined: Sat Sep 28, 2013 3:56 pm
Location: Canada / UK
Contact: Website

lxsession folder missing?

Thu Jun 03, 2021 8:39 pm

Im trying to auto run a python script in a terminal window at boot. I was able to do it a few years ago, but for the life of me I cant work out how I did it.

The issue I'm running into with a new project is I don't have the "lxsession" folder in the ".config" folder

Im trying to do this:

Code: Select all

nano /home/pi/.config/lxsession/LXDE-pi/autostart

but the "autostart " file does not seem to be present, is it still done this way.

Once I can get to that file (if thats still used) I will us the code below as "lxterminal" worked for me before

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@lxterminal -e python3 /home/pi/filename.py
______________________________________________________
Pi model B / Pi 2 / Pi 3 / Pi 4 / Pi 400 / Pi Zero W / Pico

gordon77
Posts: 5803
Joined: Sun Aug 05, 2012 3:12 pm

Re: lxsession folder missing?

Fri Jun 04, 2021 6:22 am

Try here...

/etc/xdg/lxsession/LXDE-pi/autostart

User avatar
raymate
Posts: 143
Joined: Sat Sep 28, 2013 3:56 pm
Location: Canada / UK
Contact: Website

Re: lxsession folder missing?

Fri Jun 04, 2021 1:12 pm

gordon77 wrote:
Fri Jun 04, 2021 6:22 am
Try here...

/etc/xdg/lxsession/LXDE-pi/autostart
Perfect, thank you... guess they changed its location :)
______________________________________________________
Pi model B / Pi 2 / Pi 3 / Pi 4 / Pi 400 / Pi Zero W / Pico

bls
Posts: 1598
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: lxsession folder missing?

Fri Jun 04, 2021 1:34 pm

raymate wrote:
Fri Jun 04, 2021 1:12 pm
gordon77 wrote:
Fri Jun 04, 2021 6:22 am
Try here...

/etc/xdg/lxsession/LXDE-pi/autostart
Perfect, thank you... guess they changed its location :)
Nope, nothing has changed. /etc/xdg/lxsession/LXDE-pi/autostart is the location that affects all users. If you want to do it for one user without affecting all users, you can do the following:

Code: Select all

bash$ whoami
pi
bash$ mkdir -p /home/pi/.config/lxsession/LXDE-pi
I'm not sure why the directory isn't created by default, but it is honored by lxde. I do this in my image prep tool to set the mouse to be left-handed for my user, and it works correctly.
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

User avatar
Paeryn
Posts: 3310
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: lxsession folder missing?

Fri Jun 04, 2021 1:49 pm

raymate wrote:
Thu Jun 03, 2021 8:39 pm
Once I can get to that file (if thats still used) I will us the code below as "lxterminal" worked for me before

Code: Select all

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@lxterminal -e python3 /home/pi/filename.py
If your RPiOS is up-to-date you can get rid of the line

Code: Select all

@point-rpi
as that program was removed ages ago. All it did was move the pointer so it hovered over the RPi menu button on startup but that unfunctionality has been added to the customised LXDE by means of a config entry.
She who travels light — forgot something.
Please note that my name doesn't start with the @ character so can people please stop writing it as if it does!

gordon77
Posts: 5803
Joined: Sun Aug 05, 2012 3:12 pm

Re: lxsession folder missing?

Fri Jun 04, 2021 1:55 pm

raymate wrote:
Fri Jun 04, 2021 1:12 pm
gordon77 wrote:
Fri Jun 04, 2021 6:22 am
Try here...

/etc/xdg/lxsession/LXDE-pi/autostart
Perfect, thank you... guess they changed its location :)
It changed in 2018..

viewtopic.php?t=227191

bls
Posts: 1598
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: lxsession folder missing?

Fri Jun 04, 2021 2:30 pm

That may be (the change from 2018), but having it in the user's directory definitely works. I just added left-handed mouse support to my image-building tool, and being left-handed, tested it well. Here's the code from the tool that sets left-handed mouse support. As you can see, I'm modifying settings in the user's config directory, not in /etc/xdg/... This code runs as root, hence the additional steps to carefully set the file/directory owner and protection. NOTE: This code will not run unmodified outside of my tool, but coudl be easily modified to do so if desired.

Code: Select all

    # System has LXDE, so set left-handed mouse if requested
    if [ $fmouse -eq 1 ]
    then
        userx=${myuser:-pi}     
        [ "$userx" == "pi" ] && gx=pi || gx=users
        logtoboth "> Enable left-handed mouse for user '$userx'"
        dirx="/home/$userx/.config/lxsession/LXDE-pi"
        mkdir -p $dirx
        cp /etc/xdg/lxsession/LXDE-pi/desktop.conf $dirx
        chown -R $userx:$gx /home/$userx/.config
        chmod -R 700 /home/$userx/.config
        chmod 644 $dirx/desktop.conf
        sed -i "s/LeftHanded=0/LeftHanded=1/" $dirx/desktop.conf
    fi
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

klricks
Posts: 7858
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: lxsession folder missing?

Fri Jun 04, 2021 3:26 pm

FYI - Here is a guide 'sticky' that explains how to use autostart: viewtopic.php?f=66&t=294014
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

bls
Posts: 1598
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA

Re: lxsession folder missing?

Fri Jun 04, 2021 6:46 pm

klricks wrote:
Fri Jun 04, 2021 3:26 pm
FYI - Here is a guide 'sticky' that explains how to use autostart: viewtopic.php?f=66&t=294014
Thanks, klricks, I had found that thread when I was wading through all this, but had forgotten about it. Very helpful post!
Pi tools:
Quickly and easily build customized-just-for-you SSDs/SD Cards: https://github.com/gitbls/sdm
Easily run and manage your network's DHCP/DNS servers on a Pi: https://github.com/gitbls/ndm
Easy and secure strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

Return to “Troubleshooting”