Fix the swapcaps script.

This commit is contained in:
cyteen 2024-07-25 10:04:21 +01:00
parent 95768d9f89
commit eee4a9e597
5 changed files with 431 additions and 127 deletions

170
001_swap-caps.md Executable file
View File

@ -0,0 +1,170 @@
# various methods of setting key bindings
## We really should get 020_kmonad.sh working
```bash
# !/usr/bin/env zsh
# <https://thesynack.com/posts/persistent-capslock-behavior/>
DEST=${1:-/etc/skel}
# xmodmap
# cat <-'EOF' | tee ~/.Xmodmap
# # ! 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 tee loadkeys
# keycode 1 = Caps_Lock
# keycode 58 = Escape
# EOF
## current XKN settings
# setxkbmap -v 9
#
# Setting verbose level to 9
# locale is C
# Trying to load rules file ./rules/evdev
# Trying to load rules file /usr/share/X11/xkb/rules/evdev
# Success
# Applied rules from evdev
# rules: evdev
# model: pc104
# layout: gb
# options: caps:swapescape
# Trying to build keymap using the following components
# keycodes: evdev+aliases(qwerty)
# types: complete
# compat: complete
# symbols: pc+gb+inet(evdev)+capslock(swapescape)
# geometry: pc(pc104)
# setxkbmap -model pc104 -layout gb,us -variant ,dvorak -option caps:swapecape
# setxkbmap -v 9 -option "" -option "misc:extend,lv5:caps_switch_lock,compose:menu"
# mkdir -p ${DEST}/.xinitrc.d
#
# cat <<-EOF | tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
# #!/usr/bin/env bash
#
# setxkbmap -model pc104 -layout gb,us -option "caps:swapescape"
# 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
# "lv3:lwin_switch,caps:swapescape,compose:caps"
config_file="/etc/default/keyboard"
typeset -A rules
rules=(
"XKBMODEL" "pc104"
"XKBLAYOUT" "gb"
"XKBVARIANT" ""
"XKBOPTIONS" "caps:swapescape"
"BACKSPACE" "guess"
)
for rule in "${(@k)rules}"; do
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."
```
```
```

View File

@ -1,5 +1,22 @@
#!/bin/bash
# Create a keyboard file in /tmp to test the script
conf_print_keyboard_tmp() {
cat <<-EOF
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc104"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
EOF
}
#conf_print_keyboard_tmp | tee /tmp/keyboard
# Default destination directory if not provided
DEST=${1:-/etc/skel}
@ -18,20 +35,46 @@ chmod +x ${DEST}/.xinitrc.d/setxkbmap.sh
# Keyboard configuration adjustments
config_file="/etc/default/keyboard"
# config_file="/tmp/keyboard"
cp $config_file $config_file-bak
declare -A rules
rules=(
"XKBMODEL" "pc105"
"XKBLAYOUT" "gb"
"XKBVARIANT" ""
"XKBOPTIONS" "caps:swapescape"
"BACKSPACE" "guess"
"XKBMODEL" "pc104"
"XKBLAYOUT" "gb"
"XKBVARIANT" ""
"XKBOPTIONS" "caps:swapescape"
"BACKSPACE" "guess"
)
for rule in "${rules[@]}"; do
regex="s/^#\?\(${rule}\s*\).*$/\1=${rules[$rule]}/"
sudo sed -i "${regex}" ${config_file}
echo ""
declare -p rules
echo ""
# Iterate through the keys of the associative array
for key in "${!rules[@]}"; do
# Access the value associated with the current key
value="${rules[$key]}"
# Now you can use both $key and $value inside this loop
echo "$key = $value"
done
echo ""
for rule in "${!rules[@]}"; do
value="${rules[$rule]}"
regex="s|^#.\?\(${rule}\s*\).*$|\1=${value}|"
# sudo sed -i "${regex}" ${config_file}
if [[ -n "$value" ]]; then
echo "sudo sed -i "${regex}" ${config_file}"
sudo sed -i "${regex}" ${config_file}
fi
done
echo ""
cat ${config_file}
# Trigger udevadm to apply changes
sudo udevadm trigger --subsystem-match=input --action=change

153
001_swap-caps.zsh Executable file → Normal file
View File

@ -1,100 +1,81 @@
#!/usr/bin/env zsh
# https://thesynack.com/posts/persistent-capslock-behavior/
# Create a keyboard file in /tmp to test the script
conf_print_keyboard_tmp() {
cat <<-EOF
# KEYBOARD CONFIGURATION FILE
# Consult the keyboard(5) manual page.
XKBMODEL="pc104"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
EOF
}
#conf_print_keyboard_tmp | tee /tmp/keyboard
# Default destination directory if not provided
DEST=${1:-/etc/skel}
# xmodmap
# cat <-'EOF' | tee ~/.Xmodmap
# # ! 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
# Create the .xinitrc.d directory if it doesn't exist
mkdir -p ${DEST}/.xinitrc.d
# Console tty
# cat <<-EOF | sudo tee loadkeys
# keycode 1 = Caps_Lock
# keycode 58 = Escape
# EOF
# Write the setxkbmap configuration to a script file
cat <<EOF | sudo tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
#!/bin/zsh
## current XKN settings
# setxkbmap -v 9
#
# Setting verbose level to 9
# locale is C
# Trying to load rules file ./rules/evdev...
# Trying to load rules file /usr/share/X11/xkb/rules/evdev...
# Success.
# Applied rules from evdev:
# rules: evdev
# model: pc104
# layout: gb
# options: caps:swapescape
# Trying to build keymap using the following components:
# keycodes: evdev+aliases(qwerty)
# types: complete
# compat: complete
# symbols: pc+gb+inet(evdev)+capslock(swapescape)
# geometry: pc(pc104)
setxkbmap -model pc104 -layout gb,us -option caps:swapecape
EOF
# setxkbmap -model pc104 -layout gb,us -variant ,dvorak -option caps:swapecape
# setxkbmap -v 9 -option "" -option "misc:extend,lv5:caps_switch_lock,compose:menu".
# mkdir -p ${DEST}/.xinitrc.d
#
# cat <<-EOF | tee ${DEST}/.xinitrc.d/setxkbmap.sh >/dev/null
# #!/usr/bin/env bash
#
# setxkbmap -model pc104 -layout gb,us -option "caps:swapescape"
# 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.
# "lv3:lwin_switch,caps:swapescape,compose:caps"
# Make the script executable
chmod +x ${DEST}/.xinitrc.d/setxkbmap.sh
# Keyboard configuration adjustments
config_file="/etc/default/keyboard"
# config_file="/tmp/keyboard"
cp $config_file $config_file-bak
typeset -A rules
rules=(
"XKBMODEL" "pc104"
"XKBLAYOUT" "gb"
"XKBVARIANT" ""
"XKBOPTIONS" "caps:swapescape"
"BACKSPACE" "guess"
)
declare -A rules
rules=(
"XKBMODEL" "pc104"
"XKBLAYOUT" "gb"
"XKBVARIANT" ""
"XKBOPTIONS" "caps:swapescape"
"BACKSPACE" "guess"
)
for rule in "${(@k)rules}"; do
regex="s|^#\?\(${rule}\s*\).*$|\1\=\"${rules[${rule}]}\"|"
sudo sed -i "${regex}" ${config_file};
done
echo ""
declare -p rules
echo ""
# Iterate through the keys of the associative array
for key in "${(@k)rules}"; do
# Access the value associated with the current key
value="${rules[$key]}"
# Now you can use both $key and $value inside this loop
echo "$key = $value"
done
echo ""
for rule in "${(@k)rules}"; do
value="${rules[$rule]}"
regex="s|^#.\?\(${rule}\s*\).*$|\1=${value}|"
# sudo sed -i "${regex}" ${config_file}
if [[ -n "$value" ]]; then
echo "sudo sed -i '${regex}' ${config_file}"
sudo sed -i "${regex}" ${config_file}
fi
done
echo ""
cat ${config_file}
# Trigger udevadm to apply changes
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."

View File

@ -3,29 +3,137 @@
# Debian packages for hyprland have hit unstable and we attempt to build
# debs locally for devuan using gbp.
sudo apt-get install -y pipewire wireplumber waypipe qt6-wayland
DOTFILE_SRC="/space/code_repositories/hypr/dotfiles/Hyprland-config"
# status bar
# For sound and screensharing
# autostart with
sudo apt-get install -y \
pipewire \
wireplumber
# xdg-desktop-portal-hyprland
- gbm
apt-get install -y libgbm-dev libgbm1
apt-get install -y hyprland-protocols
apt-get install -y libhyprlang-dev libhyprlang2
apt-get install -y libdrm2 libdrm-dev
- libpipewire-0.3
apt-get intall -y libpipewire-0.3-dev
= libspa-0.2
aot-get install -y libspa-0.2-dev
= sdbus-cpp
apt-get install -y libsdbus-c++-dev
= wayland-client
apt-get install -y libwayland-client0
= wayland-protocols
apt-get install -y wayland-protocols
sudo apt-get install -y \
waypipe \
brightnessctl \
brightness-udev \
playerctl \
shutter \
wf-recorder \
wl-clipboard \
zathura \
ranger
# swaylock
git clone --recursive https://github.com/hyprwm/xdg-desktop-portal-hyprland
cd xdg-desktop-portal-hyprland/
cmake -DCMAKE_INSTALL_LIBEXECDIR=/usr/lib -DCMAKE_INSTALL_PREFIX=/usr -B build
cmake --build build
sudo cmake --install build
# team-hyprland packages (I made that up, there is a team-sway)
sudo apt-get install -y \
libudis86-0 \
udcli \
hyprwayland-scanner \
libhyprlang2 \
libhyprcursor0 \
libhyprutils0 \
hyprcursor-util \
hyprland-protocols \
hyprland \
hyprland-backgrounds \
hyprpaper
## ranger - Console File Manager
cp -a ${DOTFILE_SRC}/ranger ~/.config
## zathura document viewer
cp -a ${DOTFILE_SRC}/zathura ~/.config
## swaylock config
cp -a ${DOTFILE_SRC}/swaylock ~/.config
## hyprland config
mv ${HOME}/.config/hypr/hyprland.conf ${HOME}/.config/hypr/hyprland.conf.bak
cp -a ${DOTFILE_SRC}/hypr/* ${HOME}/.config/hypr/
## hyprpaper config
conf_print_hyprpaper() {
cat <<-EOF
preload = ${HOME}/Pictures/Wallpaper/default.png
# if more than one preload is desired then continue to preload other backgrounds
preload = ${HOME}/Pictures/Wallpaper/default.png
# .. more preloads
# set the default wallpaper(s) seen on initial workspace(s) --depending on the number of monitors used
wallpaper = monitor1,${HOME}/Pictures/Wallpaper/default.jpg
# if more than one monitor in use, can load a 2nd image
# wallpaper = monitor2,/path/to/next_image.png
# .. more monitors
# enable splash text rendering over the wallpaper
splash = true
# fully disable ipc
# ipc = off
EOF
}
conf_print_hyprpaper | tee ~/.config/hypr/hyprpaper.conf
# Add the wallpaper images
PAPER_DIR="${HOME}/Pictures/Wallpaper"
mkdir -p ${PAPER_DIR}
cp ${DOTFILE_SRC}/Wallpaper/* ${PAPER_DIR}/
ln -s ${PAPER_DIR}/samurai_strike.jpg ${PAPER_DIR}/default.jpg
ln -s ${PAPER_DIR}/street-tn.png ${PAPER_DIR}/default.png
## Status bar
# [eww](https://elkowar.github.io/eww/) rust based not packaged.
#
# waybar
# exec-once=waybar
sudo apt-get install -y \
waybar
## waybar config
# cp -a /etc/xdg/waybar into ~/.config/
# sed -i 's|sway\/workspaces|hyprland\/workspaces/g' ~/.config/waybar/config
# sed -i 's|sway\/workspaces|hyprland\/workspaces/g' ~/.config/waybar/config.jsonc
# or use a pre configured set of dotfiles as a starting point:
# https://github.com/knightfallxz/Hyprland-config
cp -a ${DOTFILE_SRC}/waybar ~/.config
# - default have pulseaudio needs to be changed to pipewire/wireplumber
# https://github.com/Alexays/Waybar/wiki/
# https://github.com/Alexays/Waybar/wiki/Module:-WirePlumber
# https://github.com/Alexays/Waybar/wiki/Module:-Hyprland
#
# application launcher for wlroots based wayland compositors
sudo apt-get install -y \
wofi
cp -a ${DOTFILE_SRC}/wofi ~/.config
# XDG Portal - Packaged on gitea
sudo apt-get install -y xdg-desktop-portal-hyprland
# Notification daemon - pick one
# mako is minimal
# swaync less so.
sudo apt-get install -y \
dunst
# sway-notification-center \
# mako-notifier
cp -a ${DOTFILE_SRC}/dunst ~/.config
# Terminal - Packaged or configured in automate scripts here for reference.
# More kitty binds in hyprland.conf examples than wezterm.
# sudo apt-get install -y \
# kitty \
# wezterm
# cp -a ${DOTFILE_SRC}/kitty ~/.config
# Authenitication Agent
# /etc/xdg/autostart/polkit-kde-authentication-agent-1.desktop
# autostart it with
# $ exec-once=/usr/lib/polkit-kde-authentication-agent-1
# exec-once=/usr/lib/x86_64-linux-gnu/libexec/polkit-kde-authentication-agent-1
sudo apt-get install -y \
polkit-kde-agent-1

View File

@ -1,8 +1,10 @@
#!/usr/bin/env bash
set -x
# https://www.zephyrproject.org/zephyr-rtos-on-esp32/
# https://zmk.dev/docs/development/setup/
# KMonad is an advanced tool that lets you infinitely customize and extend the functionalities
# of almost any keyboard. For a detailed list of features, see here
# Include the script create functions split into a separate file.
source ./020_kmonad-conf_print.sh
DEST=${1:-/etc/skel}
@ -98,14 +100,14 @@ git clone --depth 1 https://github.com/manna-harbour/miryoku_kmonad ${MIRYOKU_BU
pushd ${MIRYOKU_BUILD_HOME}/src
make
make \
MIRYOKU_ALPHAS=QWERTY \
MIRYOKU_EXTRA=COLEMAKDH \
MIRYOKU_TAP=QWERTY \
MIRYOKU_NAV=INVERTEDT \
MIRYOKU_CLIPBOARD=WIN \
MIRYOKU_LAYERS=FLIP \
MIRYOKU_MAPPING=LITE \
MIRYOKU_KMONAD_OS=LINUX
MIRYOKU_ALPHAS=QWERTY \
MIRYOKU_EXTRA=COLEMAKDH \
MIRYOKU_TAP=QWERTY \
MIRYOKU_NAV=INVERTEDT \
MIRYOKU_CLIPBOARD=WIN \
MIRYOKU_LAYERS=FLIP \
MIRYOKU_MAPPING=LITE \
MIRYOKU_KMONAD_OS=LINUX
popd
# Apply local defcfg and defsrc