MagShift - Advanced Keyboard Layout Switcher with Instant Correction Engine for Linux (Wayland & X11). It fixes what you just typed without making you retype it.
Designed with NixOS Flakes in mind for reproducible and secure deployment.
Also supports other Linux distros via a simple installer script. For example:
- ⚡ Double Right Shift: Tap
Right Shifttwice to switch layout (e.g., English ↔ Ukrainian). - 🖋️ Auto-Correction: It automatically corrects the last typed phrase when you switch.
- 🔒 Secure: Runs with dynamic permissions (via Udev ACLs), no manual group configuration required.
- ❄️ Pure Nix: Zero global dependencies. Builds cleanly from the Nix Store.
Old unsecure version with clipboard dependency and extra features (like handling selected text) available in extra branch: SkySwitcher
Since this project exports a NixOS module, installation is clean, but requires an overlay to make the package available to the system.
Add the input, import the module, and apply the overlay in your system configuration:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
# Add MagShift input
magshift.url = "github:OleksandrCEO/MagShift";
# magshift.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, magshift, ... }: {
nixosConfigurations.myhostname = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
# 1. Import the module
magshift.nixosModules.default
# 2. Add Overlay (Required)
({ pkgs, ... }: {
nixpkgs.overlays = [
(final: prev: {
magshift = magshift.packages.${prev.stdenv.hostPlatform.system}.default;
})
];
})
];
};
};
}
{ config, pkgs, ... }:
{
# Enable MagShift
services.magshift.enable = true;
}
Note: With the new udev-based approach, users do not need to be added to
inputoruinputgroups. Permissions are granted dynamically to the active graphical session user.
If you've made local changes or want to pull the latest version:
cd /etc/nixos
sudo nix flake update magshift
sudo nixos-rebuild switch
If you track your NixOS config in git:
cd /etc/nixos
sudo git add .
sudo git commit -m "Update MagShift to latest version"
sudo nixos-rebuild switch
For non-NixOS systems, use the provided installer script:
# Download the latest release
wget https://github.com/OleksandrCEO/MagShift/archive/refs/heads/master.zip
unzip master.zip
cd MagShift-master
# Run installer (requires root)
sudo ./install.sh
The installer will:
- Install
python3-evdevvia your package manager (apt/dnf/pacman) - Copy
main.pyto/usr/local/bin/magshift - Create udev rules for dynamic device permissions
- Reload udev to apply changes
To update to the latest version, simply download and run the installer again:
wget https://github.com/OleksandrCEO/MagShift/archive/refs/heads/master.zip
unzip -o master.zip
cd MagShift-master
sudo ./install.sh
Since this tool relies on the graphical session (Wayland/X11), the most reliable way to start it is via KDE settings.
- Open System Settings (Системні параметри) -> Autostart (Автозапуск).
- Click + Add New (+ Додати нове) -> Application... (Програма...).
- Do not select "Login Script".
- Type
magshiftin the search bar and select it. - (Optional) If you want to use a different layout switching hotkey, click on the added entry, then click Properties and modify the command:
- For Alt+Shift:
magshift -k alt - For Ctrl+Shift:
magshift -k ctrl - For CapsLock:
magshift -k caps - Default is Meta+Space (
-k meta)
- For Alt+Shift:
- Click Apply (Гаразд).
That's it! MagShift will now start automatically with your user session.
To ensure MagShift runs automatically and remains stable on systems like Ubuntu, follow these steps to configure it as a systemd user service.
Create the service configuration file in your user directory:
mkdir -p ~/.config/systemd/user
nano ~/.config/systemd/user/magshift.service
Paste the following content into the file:
[Unit]
Description=MagShift Keyboard Layout Switcher
After=graphical-session.target
[Service]
# Ensure the path points to your installed executable
ExecStart=/usr/local/bin/magshift
Restart=always
RestartSec=5
[Install]
WantedBy=default.target
Apply the changes and activate the service:
# Reload the systemd user manager configuration
systemctl --user daemon-reload
# Enable the service to start automatically on login
systemctl --user enable magshift.service
# Start the service immediately
systemctl --user start magshift.service
To check if the service is running correctly, use:
systemctl --user status magshift.service
To view real-time logs for debugging purposes:
journalctl --user -u magshift -f
If you want to run it manually for debugging or development:
# Enter the development shell
nix develop
# Run with verbose logging to see key events
python3 main.py --verbose
# List available input devices (keyboards)
python3 main.py --list
# Use a different layout switching hotkey
python3 main.py -k alt # Alt+Shift (default in many Linux DEs)
python3 main.py -k meta # Meta+Space (default, KDE-style)
python3 main.py -k ctrl # Ctrl+Shift
python3 main.py -k caps # CapsLock
Available hotkey styles:
alt- Left Alt + Left Shift (common on GNOME/XFCE)meta- Left Meta (Windows key) + Space (default, KDE standard)ctrl- Left Ctrl + Left Shiftcaps- CapsLock only
MIT License. Feel free to use and modify.