Ubuntu Pastebin

Paste from yeeve at Wed, 23 Aug 2017 15:54:02 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash

# http://www.pixelbeat.org/docs/xkb_remap/
# https://medium.com/@damko/a-simple-humble-but-comprehensive-guide-to-xkb-for-linux-6f1ad5e13450
 # sudo vim /usr/share/X11/xkb/symbols/keypad
 # xev
 # xinput list
 # xinput test ID
 # xmodmap -pke
 # xbindkeys -k
 # xbindkeys -s
 # xfconf-query -c xfce4-keyboard-shortcuts -l - v | grep XF86
 # sudo vim /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
 # sudo vim ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
 # killall xfconfd && /usr/lib/i386-linux-gnu/xfce4/xfconf/xfconfd &
 # killall xfsettingsd && xfsettingsd &


# http://wiki.linuxquestions.org/wiki/List_of_Keysyms_Recognised_by_Xmodmap


# Reset our keyboards back to GB to start with ...
setxkbmap -layout us && setxkbmap -layout gb

# The remote control device (USB keyboard)
# has keys that overlap with standard keyboards.
# Therefore we map the offending keys here.

kbd_id() {
  keyboard="$1"
  xinput list |
  sed -n "s/.*$keyboard.*id=\([0-9]*\).*keyboard.*/\1/p" |
  tail -n1
}

# In our case the USB:ID was shown in the `xinput list` output,
# but this is unusual and you may have to match
# on names or even correlate with /dev/input/by-id/*
remote_id=$(kbd_id 'HID 04d9:1203')
[ "$remote_id" ] || exit

# re-execute this script as "$xuser" if that's not root, in case the root user is not permitted to access the X session.
xuser=$(ps -C Xorg -C X -ouser=)
[ $(id -un) = root ] && [ "$xuser" != root ] && exec su -c $0 "$xuser"
export DISPLAY=":0"

# Write out the XKB config to remap just
# the keys we're interested in
mkdir -p /tmp/xkb/symbols
cat >/tmp/xkb/symbols/custom <<\EOF
xkb_symbols "remote" {
    key <NMLK> { [ XF86MonBrightnessDown] };
    key <KPDV> { [ XF86MonBrightnessUp] };
    key <KPMU> { [ XF86AudioMedia] };
    key <KPSU> { [ XF86KbdLightOnOff] };
    key <KPAD> { [ XF86KbdBrightnessDown] };
    key <KPEN> { [ XF86Reply] };
    key <KP7> { [ XF86Launch7] };
    key <KP8> { [ XF86Launch8] };
    key <KP9> { [ XF86Launch9] };
    key <KP4> { [ XF86Launch4] };
    key <KP5> { [ XF86Launch5] };
    key <KP6> { [ XF86Launch6] };
    key <KP1> { [ XF86Launch1] };
    key <KP2> { [ XF86Launch2] };
    key <KP3> { [ XF86Launch3] };
    key <KP0> { [ XF86WebCam ] };
};
EOF

# key <BackSpace> { [ XF86Battery] };
# key <KP_Delete> { [ XF86Bluetooth] };
# key <KPDL> { [ XF86Display] };
# key <KPPT> { [ XF86KbdBrightnessUp] };

# Amend the current keyboard map with
# the above key mappings, and apply to the particular device.
# Note xkbcomp >= 1.2.1 is needed to support this
setxkbmap -device $remote_id -print |
sed 's/\(xkb_symbols.*\)"/\1+custom(remote)"/' |
xkbcomp -I/tmp/xkb -i $remote_id -synch - $DISPLAY 2>/dev/null

# $remote_id is important, this will be a specific numeric ID for a specific keyboard.

killall xbindkeys;
/usr/bin/xbindkeys -n &
Download as text