Hi, I have 2 somewhat similar problems. I want to run a command at startup and also when a device is plugged in (a graphics screen tablet), and also to run a command that mounts a harddrive when the computer turns on.
I am not familiar with this sort of thing at all, but I know the commands I want to run, because they work when I type them in manually. These are the 2 commands I want to run at startup:
This is to map the tablet screen’s pen input to itself (otherwise the pen input is mapped across all monitors). I also need this to run when this device is turned on, because if I turn if off and back on the setting resets. It’s a tablet screen that plugs in through HDMI.
This is to mount the hard drive to the directory I want (~/Kiophen):
#!/bin/sh
sudo mount /dev/nvme0n1p4 ~/Kiophen
I saved them as their own .sh files and made entries for them in the ‘Application Autostart’ tab in the ‘Session and Startup’ program, but they don’t do anything when I turn the computer on. I have googled around and don’t know what to do.
I have also ran sudo chmod -x [script name] on them with no errors but it did not do anything.
Why not simply create an entry in /etc/fstab to mount on system startup? How come you’re relying on a startup script? Using “sudo” in an autostart script cannot prompt you to enter your password.
As for the first script (xsetwacom), you’re saying it also doesn’t run upon startup?
Thank you all for the responses, I went and looked into those articles. I got the UUID from the drive using the command on the wiki, then added it to the fstab file using nano, and now it is mounting correctly at startup like I want it to. It is an ntfs system so I typed that in instead of ext4.
I got the xsetwacom command to work on startup, I realized that it is in fact working, but if I turn my tablet off then it does not keep that configuration (not a bug). I usually turn my tablet off when I turn on my computer, but I noticed now that it does work on startup.
I am looking into udev and it is difficult. I do not understand how to get the device name. The manjaro wiki does not have information for my issue. Manjaro detects my tablet, and xsetwacom is working. I will keep looking into udev.
I saw “udevadm” as a command on that wiki page, and I ran “udevadm --help” to see if I could decipher. “udevadm monitor” gave me some information that I tried with some other commands from the wiki page. I read over the wiki article and eventually got some understanding. I made a .rules file in /etc/udev/rules.d and added some information from the device, like the idVendor, idProduct, and other fields that are in the example in the wiki page for udev, along with a RUN+="~/script" at the end of the file to try and run the script when the device is plugged in. It didn’t do anything, so I just made the file:
KERNEL=="*", RUN+="~/script"
and saved that in the rules.d folder as tablet.rules. I made the script chmod -x. This does not do anything, the KERNEL=="*" part from my understanding should run the script whenever anything happens with udev, but I turned on/off my tablet and it did nothing. I put in a line in the file to write a line to a file if it’s ran, and the log is empty, so I know it is just not being run at all instead of something else happening.
I could not get udev to execute a script when the tablet was plugged in, after learning udev as well as a solution I saw about using “systemd” alongside udev, but nothing worked. I made a keyboard shortcut in xfce settings instead.