#!/usr/bin/env bash # Usage: ./switch_keyboards.sh [args] # # Args: # console Loads the console version # mac Loads the Mac keyboard version # pc Loads the standard keyboard version # fn Loads the version for a standard keyboard without an fn row # # Explanation ========= # Mac keyboards place their super key adjacent to the spacebar, while standard # keyboards put alt in that spot: # # Macbook: Shift | z # Fn | Ctrl | Alt | Super | Space # # Standard: Shift | z # Fn | Ctrl | Super | Alt | Space # # To preserve consistency when switching keyboards, two versions of the same # xremap config.yml are available. This script toggles between the two # # Xremap can also run in a non-graphical console. For this we don't need to # remap Super and Alt, though we still need other keys, like capslock. An # optional "console" argument can be passed to this script to load # config_console.yml print_help() { cat < ARGS: mac Remaps assuming super is adjacent to the spacebar pc Remaps assuming alt is adjacent to the spacebar fn Remaps assuming pc + no fn row console Only remaps capslock to ctrl help Print this message and exit HELP } if ! command -v xremap &>/dev/null; then printf "xRemap not found\nLayouts were not switched\n" exit 1 fi case "$(echo "$1" | awk '{print tolower($0)}')" in console) ln -sf ~/.config/xremap/config_console.yml ~/.config/xremap/config.yml echo "Switching to minimal console remapping" ;; mac) ln -sf ~/.config/xremap/config_mac.yml ~/.config/xremap/config.yml echo "Switching to mac layout :: ALT | SUPER | SPACE" ;; pc | standard) ln -sf ~/.config/xremap/config_standard.yml ~/.config/xremap/config.yml echo "Switching to standard layout :: SUPER | ALT | SPACE" ;; fn | small | mini) ln -sf ~/.config/xremap/config_no_fn.yml ~/.config/xremap/config.yml echo "Switching to no-fn row standard layout :: SUPER | ALT | SPACE" ;; *) if [[ -n "$1" ]]; then print_help exit 0 fi ;; esac sudo /usr/bin/systemctl restart xremap.service sleep 2