I'm on Debian 9.11 with the MATE desktop (pinebook pro)
I've an Init script /etc/init.d/customMapping
that remaps some of my keys using both setxkbmap
and xmodmap
. Here it is
#! /bin/sh
BEGIN INIT INFO
Provides: customMapping
Required-Start: $local_fs x11-common xserver display
Required-Stop: $local_fs x11-common xserver display
Default-Start: 2 3 4 5
Default-Stop: 0 1 6
Short-Description: Custom keyboard mapping
Description: This is a simple Init script
Custom keyboard mapping
END INIT INFO
Some things that run always
echo "customMapping script"
Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script customMapping "
echo "start" >> /opt/test.txt
# Make Caps Lock a Control key
setxkbmap -option ctrl:nocaps > /opt/logs 2>&1
# Swap Left Control with Left Alt
setxkbmap -option ctrl:swap_lalt_lctl > /opt/logs 2>&1
# Make Pause/Break an End key
xmodmap -e "keycode 127 = End" > /opt/logs 2>&1
# Make Screen Lock a Home key
xmodmap -e "keycode 78 = Home" > /opt/logs 2>&1
;;
stop)
echo "Stopping custom Mapping"
;;
*)
echo "Usage: /etc/init.d/customMapping {start|stop}"
exit 1
;;
esac
exit 0
As you can see I've tried several kind of keywords in the Required-Start
section but this doesn't work and when I check in the /opt/logs
file I see the following error messages
Cannot open display "default display"
Cannot open display "default display"
xmodmap: unable to open display ''
xmodmap: unable to open display ''
What value should I set in Required-Start
in order for my script to access display
(X server)? Also is the Default-Start
values correct?
Thank you
xinitrc
andxsessionrc
I'm new to Linux and I didn't know about that. But @JdeBP's comment seems to be leading to a better way. Very useful information – Jérôme MEVEL Jan 27 '20 at 08:05