0

I have created two systemd startup scripts as per https://www.howtogeek.com/687970/how-to-run-a-linux-program-at-startup-with-systemd/, containing the following:

#1

#!/bin/bash

synclient RightButtonAreaLeft=0
synclient RightButtonAreaTop=0

#2

#!/bin/bash

modprobe -r ec_sys
modprobe ec_sys write_support=1

echo -n -e "\x0a" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null

while true; do
read -rsn1 input
if [[ size=${#input}!=0 ]]; then

    echo -n -e "\x8a" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null
    
fi
    
echo -n -e "\x0a" | sudo dd of="/sys/kernel/debug/ec/ec0/io" bs=1 seek=12 count=1 conv=notrunc 2> /dev/null


done

When run manually, the scripts work as intended.

The top script disables the bottom-left RMB gesture on my touchpad, and the bottom one should turn an LED on and off when I type (https://www.reddit.com/r/thinkpad/comments/7n8eyu/thinkpad_led_control_under_gnulinux/), neither of these two have any effect when run automatically at startup, even when I have checked the service status to verify the have run/are running.

I have used the systemctl status servicename.service command which does not raise any obvious errors. While suggestions for fixes would be ideal, any alternative ways of running these scripts at startup are also welcome. I have already tried the init.d method, as well as the startup scripts setting in ubuntu, neither of which unfortunately worked.

5
  • Is this a system or user unit? Jun 19 at 2:48
  • If I understand correctly, this is a user unit as I own the computer and have root access.
    – Bart Weil
    Jun 19 at 9:52
  • When you run the scripts manually, are you prompted for a sudo password? Jun 19 at 15:36
  • 2
    Offhand, what is the environment when the scripts are executed? Many people (incorrectly) assume that running the command manually (from a terminal window or shell) is the same as when systemd (or cron, or ....) execute it. You may have to set your current working directory and PATH variables in the scripts to the expected values, and possibly the expected user/primary group names
    – C. M.
    Jun 19 at 17:57
  • @BartWeil: where are the systemd scripts? If systemd wasn't used, you should remove it from the title. Otherwise, provide the details. Also, if you're using init.d scripts you need root access to install the scripts, noting that sudo gives you root privileges. In short, you haven't privide any useful information regarding your presumed problem. Jun 20 at 1:58
0

Jobs run through cron, or as systemd startup scripts aren't run in the same runtime environment that you have on your desktop. systemd startup scripts are run as root. None of your PATH changes, or other environment variable settings are automatically propagated to your cron job. For example, there's no $DISPLAY, so GUI programs need special treatment (read man xhost).

Look at the results of echo "=== id ===";id;echo "=== set ===";set;echo "=== env ===";env | sort;echo "=== alias ===";alias in each of your environments.

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.