How to add programs to X session autostart from command line?

I need to automatically run an xrandr and xinput command at the start X session (lightDM+Mate) of a user.

I have been trying putting the commands into ~/.xprofile and ~/.xsession, but they don’t run. How can I get access to the “System -> Preferences -> Startup Applications” while being logged in through SSH, without access to GUI?

I need to automatically run an xrandr and xinput command at the start X session (lightDM+Mate) of a user.

For a single user setup there is:

~/.config/autostart

Could also create your own xprofile in your home directory.

https://wiki.archlinux.org/index.php/Xprofile

while being logged in through SSH, without access to GUI

This is something I do not do, but I wonder if update-rc is of any use to you. In terminal:

man update-rc.d

I haven’t researched it, but sounds like systemctl is also a possibility.

Good luck :slight_smile:

Hi @lockheed I have a few suggestions.

Rather than play around with individual startup entries (which end up being desktop files in ~/.config/autostart as @anon42388993 mentioned) I add exactly 1 startup.sh file then edit that script as needed. Your xinput and xrandr commands can go here and adjusted with nano.

Another thought is the ssh -X option. You can run X on individual apps like mate-settings. I do this all the time for synaptic and gparted to a server with no desktop environment at all. Of course, you need X running on both ends. When I install synaptic on the server it installs enough X to work fine.

Last, after years of xinput commands in startup, mostly to tame a wild mouse, I moved it all to /usr/share/X11/xorg.conf.d/60-mymouse.conf. More like the old days.

Just my 2 cents