:: Re: [DNG] running script on eudev e…
Αρχική Σελίδα
Delete this message
Reply to this message
Συντάκτης: Alessandro Selli
Ημερομηνία:  
Προς: dng
Αντικείμενο: Re: [DNG] running script on eudev event
On 05/08/2018 at 16:29, Antonio Trkdz.tab wrote:
> Dear All,
>
> I am struggling to understand how to run a script automatically upon
> plugging a USB keyboard.
> I know this issue is not directly related to Devuan, but I will
> certainly appreciate a little help.
>
> I created the following rule as /etc/udev/rules.d/90-usb-keyboard.rules:
>  ATTRS{idVendor}=="XXXX", ATTRS{idProduct}=="XXXX", ACTION=="add",
> RUN+="/full/path_to/restore_space_as_modifier.sh"
> and reloaded eudev (I am on ASCII).
>
> The script essentially has to do this:
>
> #!/bin/bash
> /usr/bin/xmodmap -e "keycode 65=Super_L"
> /usr/bin/xmodmap -e "keycode any=space"
> /usr/bin/pkill xcape
> /usr/bin/xcape -e "Super_L=space"
>


  I think the problem lies in the x* from the commands: they are X11
commands, i.e. they interact with a running Xorg.  But, as they are run
by udevd, i.e. by a system daemon, they do not have the DISPLAY variable
initialized and do not have the appropriate session Xauthority cookies
set.  Thus they fail.
  Which leaves you with having to use the loadkeys command, which talks
directly to the kernel and sets it's keymap table, which is universal.
  But I wonder if Xorg does preserve what the kernel has in it's keymap
table or if it sets it's own key conversion table.  In the later case,
if you start Xorg after you plugged in the keyboard, then you'd still
see no effect from your script.


Alessandro