Fedora 39 Xorg: run command when X session starts?

My Thinkpad T470p has a TouchPad that I can disable with the command xinput disable 11 . Doing this by hand works properly. I’m the only user of the laptop and I’m happy to make this system-wide if need be, but equally happy if it’s only done for my own account. (The BIOS has a setting to disable it too, which works in Windows 10, but for some reason has no effect on Fedora.)

This needs the X server to be running and DISPLAY to be set so I don’t think I can do it in systemd.

I dimly recall from decades ago that .xsession or .xinitrc would be proper to use, but sample commands in them don’t seem to have effect (“touch” commands in them with non-existent files don’t create the files).

Any suggestions?

Thank you Vladislav but this doesn’t help.

I am ONLY using Xorg. NO Wayland.

So, xinput works perfectly when run by hand.

I am simply looking for the right way to run it automatically.

I could even put it in the .cshrc but the clean way is to have it run ONE time when I start up Gnome.

cat /etc/sddm/Xsetup

#!/usr/bin/sh
# Xsetup - run as root before the login dialog appears

Mayby put
/usr/bin/xinput disable 11
there
?

2 Likes

Added gnome, touchpad and removed server

Added xorg

OK, I found a solution.

It works Fedora 39 (Gnome 45).

We just make a short file by hand.

I wanted to disable the touchpad on my ThinkPad T470p. After determining the command I needed to run (the xinput command shown below) I simply created the following file, logged out and logged in again, and it ran.

Along the way I discovered that some characters (such as >) are not accepted in this file so you may need to create a shell script even for a simple command, and run that shell script instead.

I also found that environment variable $DISPLAY is set correctly.

~myname/.config/autostart/disableTouchPad.desktop:

[Desktop Entry]
Name=DisableTouchPad
Exec=/usr/bin/xinput disable 'SynPS/2 Synaptics TouchPad'
Terminal=false
Type=Application

I’m not sure if the Terminal and Type keywords are necessary or if other keywords are also advisable, but the above works.

The file name extension must be .desktop.

(Note I’m the only user of this laptop, otherwise I’d have to study how to re-enable the touch pad when I log out.)

Finally, if you install gnome-tweaks (with the command sudo dnf install gnome-tweak-tool), run it, and go to Startup Applications, you’ll see the startup application named as Name= (in this case, DisableTouchPad). And if you use gnome-tweaks to remove that from the Startup Applications, it deletes the file you’ve made by hand.

1 Like

Maybe a service file that prompts systemd to run it at startup? with the run-once (one shot) option.

You then could tailor the service file to be run and even specify the stage where it would be run with the after & before options.

1 Like

Thanks for the idea, Jeff. Your suggestion might work and might be preferable to the working solution I posted here yesterday, but my working solution does seem to do exactly what I need to and doesn’t seem to be hacky. I’ve already spent hours on this and don’t think I can invest more time to try other things now that I’ve got one perfectly-working solution.

You can also create the .desktop file in /etc/xdg/autostart/ where all the other autostart files live. Alternatively, a --user systemd unit can be used instead. This means that the unit file should be in /etc/systemd/user or $HOME/.config/systemd/user. The former directory is for all users, and the latter for a single user.

1 Like