0

My entire rc.local file

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
cd ~/xcape && ./xcape -e 'Control_L=Escape'
exit 0

This is supposed to make my caps lock key (which is set to Left control) become an escape key when pressed by itself, and be ctrl when pressed and held.

The command in the rc.local file works fine when I do it on the terminal, but when I boot up my computer, I have to run the command manually because the rc.local file didn't run the command... or it failed.

2 Answers2

3

Avoid the ~ in the script, use your full directory path. Not only is another script interpreter running (dash instead of bash) which doesn't understand the ~ convention, the script is running as root, so even if ~ was understood, it would be the wrong home directory.

ubfan1
  • 19,049
3

When rc.local runs during boot, it runs as root and the environment is restricted.

You should change ~/xcape with /home/yourUser/xcape.

In order to verify your /etc/rc.local script you should use this command:

 sudo service rc.local start
Lety
  • 6,089
  • 2
  • 32
  • 38