Rename the working zsh script with the correct extension and provide a bash version.
This commit is contained in:
parent
012315ee5d
commit
fb7740bb04
|
|
@ -1,50 +1,22 @@
|
||||||
#!/usr/bin/env zsh
|
#!/bin/bash
|
||||||
|
|
||||||
# https://thesynack.com/posts/persistent-capslock-behavior/
|
# Default destination directory if not provided
|
||||||
DEST=${1:-/etc/skel}
|
DEST=${1:-/etc/skel}
|
||||||
# xmodmap
|
|
||||||
#cat > ~/.Xmodmap << 'EOF'
|
|
||||||
#! Swap caps lock and escape
|
|
||||||
#remove Lock = Caps_Lock
|
|
||||||
#keysym Escape = Caps_Lock
|
|
||||||
#keysym Caps_Lock = Escape
|
|
||||||
#add Lock = Caps_Lock
|
|
||||||
#EOF
|
|
||||||
#
|
|
||||||
#xmodmap ~/.Xmodmap
|
|
||||||
|
|
||||||
#cat <<EOF | sudo tee ${HOME}/.config/autostart/xmodmap.desktop >/dev/null
|
# Create the.xinitrc.d directory if it doesn't exist
|
||||||
#[Desktop Entry]
|
|
||||||
#Name=Xmodmap
|
|
||||||
#Exec=/usr/bin/xmodmap ${HOME}/.Xmodmap
|
|
||||||
#Terminal=false
|
|
||||||
#Type=Application
|
|
||||||
#X-GNOME-Autostart-enabled=true
|
|
||||||
#EOF
|
|
||||||
#
|
|
||||||
#chmod +x ~/.config/autostart/xmodmap.desktop
|
|
||||||
|
|
||||||
# Console tty
|
|
||||||
#cat <<EOF | sudo loadkeys
|
|
||||||
#keycode 1 = Caps_Lock
|
|
||||||
#keycode 58 = Escape
|
|
||||||
#EOF
|
|
||||||
|
|
||||||
#setxkbmap -model pc104 -layout gb,us -variant ,dvorak -option caps:swapecape
|
|
||||||
mkdir -p ${DEST}/.xinitrc.d
|
mkdir -p ${DEST}/.xinitrc.d
|
||||||
|
|
||||||
|
# Write the setxkbmap configuration to a script file
|
||||||
cat <<EOF | sudo tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
|
cat <<EOF | sudo tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
|
||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
|
|
||||||
setxkbmap -model pc104 -layout gb,us -option caps:swapecape
|
setxkbmap -model pc104 -layout gb,us -option caps:swapecape
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# Make the script executable
|
||||||
chmod +x ${DEST}/.xinitrc.d/setxkbmap.sh
|
chmod +x ${DEST}/.xinitrc.d/setxkbmap.sh
|
||||||
|
|
||||||
# default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
|
# Keyboard configuration adjustments
|
||||||
|
|
||||||
# FIXME:man keyboard says to use VARIABLE=VALUE not the space separated below.
|
|
||||||
|
|
||||||
|
|
||||||
config_file="/etc/default/keyboard"
|
config_file="/etc/default/keyboard"
|
||||||
|
|
||||||
typeset -A rules
|
typeset -A rules
|
||||||
|
|
@ -56,24 +28,10 @@ config_file="/etc/default/keyboard"
|
||||||
"BACKSPACE" "guess"
|
"BACKSPACE" "guess"
|
||||||
)
|
)
|
||||||
|
|
||||||
for rule in "${(@k)rules}"; do
|
for rule in "${rules[@]}"; do
|
||||||
regex="s/^#\?\(${rule}\s*\).*$/\1 ${rules[${rule}]}/"
|
regex="s/^#\?\(${rule}\s*\).*$/\1=${rules[$rule]}/"
|
||||||
# regex="s/^#\?\(${rule}\s*\).*$/\1=${rules[${rule}]}/"
|
sudo sed -i "${regex}" ${config_file}
|
||||||
sudo sed -i "${regex}" ${config_file};
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Trigger udevadm to apply changes
|
||||||
sudo udevadm trigger --subsystem-match=input --action=change
|
sudo udevadm trigger --subsystem-match=input --action=change
|
||||||
|
|
||||||
#cat <<EOF | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf > /dev/null
|
|
||||||
#Section "InputClass"
|
|
||||||
# Identifier "system-keyboard"
|
|
||||||
# MatchIsKeyboard "on"
|
|
||||||
# Option "XkbLayout" "gb,us"
|
|
||||||
# Option "XkbModel" "pc104"
|
|
||||||
# Option "XkbVariant" ""
|
|
||||||
# Option "XkbOptions" "caps:swapescape"
|
|
||||||
#EndSection
|
|
||||||
#EOF
|
|
||||||
|
|
||||||
|
|
||||||
#echo "enlightenment desktop settings-input-keyboard allowd swapping esc with caps."
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
# https://thesynack.com/posts/persistent-capslock-behavior/
|
||||||
|
DEST=${1:-/etc/skel}
|
||||||
|
# xmodmap
|
||||||
|
#cat > ~/.Xmodmap << 'EOF'
|
||||||
|
#! Swap caps lock and escape
|
||||||
|
#remove Lock = Caps_Lock
|
||||||
|
#keysym Escape = Caps_Lock
|
||||||
|
#keysym Caps_Lock = Escape
|
||||||
|
#add Lock = Caps_Lock
|
||||||
|
#EOF
|
||||||
|
#
|
||||||
|
#xmodmap ~/.Xmodmap
|
||||||
|
|
||||||
|
#cat <<EOF | sudo tee ${HOME}/.config/autostart/xmodmap.desktop >/dev/null
|
||||||
|
#[Desktop Entry]
|
||||||
|
#Name=Xmodmap
|
||||||
|
#Exec=/usr/bin/xmodmap ${HOME}/.Xmodmap
|
||||||
|
#Terminal=false
|
||||||
|
#Type=Application
|
||||||
|
#X-GNOME-Autostart-enabled=true
|
||||||
|
#EOF
|
||||||
|
#
|
||||||
|
#chmod +x ~/.config/autostart/xmodmap.desktop
|
||||||
|
|
||||||
|
# Console tty
|
||||||
|
#cat <<EOF | sudo loadkeys
|
||||||
|
#keycode 1 = Caps_Lock
|
||||||
|
#keycode 58 = Escape
|
||||||
|
#EOF
|
||||||
|
|
||||||
|
#setxkbmap -model pc104 -layout gb,us -variant ,dvorak -option caps:swapecape
|
||||||
|
mkdir -p ${DEST}/.xinitrc.d
|
||||||
|
cat <<EOF | sudo tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
setxkbmap -model pc104 -layout gb,us -option caps:swapecape
|
||||||
|
EOF
|
||||||
|
|
||||||
|
chmod +x ${DEST}/.xinitrc.d/setxkbmap.sh
|
||||||
|
|
||||||
|
# default keyboard layout is described in /etc/default/keyboard and it is shared between X and the console.
|
||||||
|
|
||||||
|
# FIXME:man keyboard says to use VARIABLE=VALUE not the space separated below.
|
||||||
|
|
||||||
|
|
||||||
|
config_file="/etc/default/keyboard"
|
||||||
|
|
||||||
|
typeset -A rules
|
||||||
|
rules=(
|
||||||
|
"XKBMODEL" "pc105"
|
||||||
|
"XKBLAYOUT" "extd"
|
||||||
|
"XKBVARIANT" ""
|
||||||
|
"XKBOPTIONS" "caps:swapescape"
|
||||||
|
"BACKSPACE" "guess"
|
||||||
|
)
|
||||||
|
|
||||||
|
for rule in "${(@k)rules}"; do
|
||||||
|
regex="s/^#\?\(${rule}\s*\).*$/\1 ${rules[${rule}]}/"
|
||||||
|
# regex="s/^#\?\(${rule}\s*\).*$/\1=${rules[${rule}]}/"
|
||||||
|
sudo sed -i "${regex}" ${config_file};
|
||||||
|
done
|
||||||
|
|
||||||
|
sudo udevadm trigger --subsystem-match=input --action=change
|
||||||
|
|
||||||
|
#cat <<EOF | sudo tee /etc/X11/xorg.conf.d/00-keyboard.conf > /dev/null
|
||||||
|
#Section "InputClass"
|
||||||
|
# Identifier "system-keyboard"
|
||||||
|
# MatchIsKeyboard "on"
|
||||||
|
# Option "XkbLayout" "gb,us"
|
||||||
|
# Option "XkbModel" "pc104"
|
||||||
|
# Option "XkbVariant" ""
|
||||||
|
# Option "XkbOptions" "caps:swapescape"
|
||||||
|
#EndSection
|
||||||
|
#EOF
|
||||||
|
|
||||||
|
|
||||||
|
#echo "enlightenment desktop settings-input-keyboard allowd swapping esc with caps."
|
||||||
Loading…
Reference in New Issue