Skip to content

Instantly share code, notes, and snippets.

@ice-blaze
Last active October 4, 2018 07:40
Show Gist options
  • Save ice-blaze/d2b13a9f5355e458136500db043bbb5c to your computer and use it in GitHub Desktop.
Save ice-blaze/d2b13a9f5355e458136500db043bbb5c to your computer and use it in GitHub Desktop.
US international keyboard with AltGr as dead key (for french accents)
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "Sorry, you are not root."
exit 1
fi
# content of /usr/share/X11/xkb/symbols/ice-blaze_keyboard
/bin/cat <<EOM >"/usr/share/X11/xkb/symbols/ice-blaze_keyboard"
default partial alphanumeric_keys
xkb_symbols "basic" {
name[Group1]= "Ice-Blaze English (international AltGr dead keys)";
include "us(altgr-intl)"
key <AD01> {[ q, Q, adiaeresis, Adiaeresis ]};
key <AD02> {[ w, W, ecircumflex, Ecircumflex ]};
key <AD03> {[ e, E, eacute, Eacute ]};
key <AD04> {[ r, R, egrave, Egrave ]};
key <AD07> {[ u, U, ugrave, Ugrave ]};
key <AD06> {[ y, Y, ucircumflex, Ucircumflex ]};
key <AC07> {[ j, J, udiaeresis, udiaeresis ]};
key <AD08> {[ i, I, icircumflex, Icircumflex ]};
key <AC08> {[ k, K, idiaeresis, Idiaeresis ]};
key <AD09> {[ o, O, ocircumflex, Ocircumflex ]};
key <AC09> {[ l, L, odiaeresis, Odiaeresis ]};
key <AC01> {[ a, A, agrave, Agrave ]};
key <AC02> {[ s, S, acircumflex, Acircumflex ]};
key <AC03> {[ d, D, ediaeresis, ediaeresis ]};
key <AB03> {[ c, C, ccedilla, Ccedilla ]};
include "level3(ralt_switch)"
};
EOM
echo "Create the file /usr/share/X11/xkb/symbols/ice-blaze_keyboard"
VARIABLE="<layout>
<configItem>
<name>ice-blaze_keyboard</name>
<shortDescription>en</shortDescription>
<description>English (US) Ice-Blaze AltGr</description>
<languageList>
<iso639Id>eng</iso639Id>
</languageList>
</configItem>
<variantList>
</variantList>
</layout>"
# append in the /usr/share/X11/xkb/rules/evdev.xml
xmlFile="/usr/share/X11/xkb/rules/evdev.xml"
tmpFile="mktemp"
lineNumber=$(grep -n "<layoutList>" $xmlFile | cut -d: -f 1)
head -n$lineNumber $xmlFile > $tmpFile
echo "$VARIABLE" >> $tmpFile
tmpLineNumber=$((lineNumber + 1))
tail -n +$tmpLineNumber $xmlFile >> $tmpFile
mv $tmpFile $xmlFile
echo "Append in $xmlFile the new config"
# ctrl esc swap
apt-get install xcape -y
# set in autostart
# /bin/bash -c "sleep 1s && setxkbmap -option ctrl:nocaps && xcape -e 'Control_L=Escape'"
mkdir $HOME/.config/autostart/ -p
/bin/cat <<EOM >"$HOME/.config/autostart/setxkbmap.desktop"
[Desktop Entry]
Type=Application
Exec=/bin/bash -c "sleep 1s && xcape -e 'Control_L=Escape'"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=xcape
Name=xcape
Comment[en_US]=
Comment=
EOM
/bin/cat <<EOM >"/etc/default/keyboard"
XKBLAYOUT=ice-blaze_keyboard
BACKSPACE=guess
XKBOPTIONS="ctrl:nocaps"
EOM
# set keybindings for windows on gnome
# source: https://stackoverflow.com/questions/39785698/keyboard-shortcuts-file-gnome
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-down "['<Primary><Shift><Alt>j']"
gsettings set org.gnome.desktop.wm.keybindings move-to-workspace-up "['<Primary><Shift><Alt>k']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-down "['<Primary><Alt>j']"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-up "['<Primary><Alt>k']"
gsettings set org.gnome.desktop.wm.keybindings switch-applications "@as []"
gsettings set org.gnome.desktop.wm.keybindings cycle-windows-backward "['<Shift><Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings cycle-windows "['<Alt>Tab']"
gsettings set org.gnome.desktop.wm.keybindings unmaximize "['<Primary><Super>j']"
gsettings set org.gnome.desktop.wm.keybindings maximize "['<Primary><Super>k']"
gsettings set org.gnome.mutter.keybindings toggle-tiled-left "['<Primary><Super>h']"
gsettings set org.gnome.mutter.keybindings toggle-tiled-right "['<Primary><Super>l']"
apt install git vim vlc terminator emacs -y
#how to select the keyboard https://askubuntu.com/questions/875688/how-to-install-usa-international-keyboard-option-on-ubuntu-gnome-16-10/875707#875707
git clone https://github.com/syl20bnr/spacemacs $HOME/.emacs.d
mkdir $HOME/git_repos -p
#terminator configuration
mkdir $HOME/.config/terminator -p
/bin/cat <<EOM >"$HOME/.config/terminator/config"
[global_config]
[keybindings]
go_down = <Alt>j
go_left = <Alt>h
go_right = <Alt>l
go_up = <Alt>k
layout_launcher = None
[layouts]
[[default]]
[[[child1]]]
parent = window0
type = Terminal
[[[window0]]]
parent = ""
type = Window
[plugins]
[profiles]
[[default]]
cursor_color = "#aaaaaa"
EOM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment