Layout Switcher is a utility designed for the GNOME environment, enabling users to deterministically switch between keyboard layouts using specific key combinations. Unlike the typical circular layout switching, where each key press toggles to the next layout in a sequence, Layout Switcher utilizes the left and right shift keys to provide predictable layout changes. By pressing the dedicated key (left shift for one layout and right shift for another), users can be confident in which layout they're switching to, ensuring a more efficient and user-friendly experience.
- How It Works
- Features
- Dependencies
- Building from Source
- Installation
- Usage
- Uninstallation
- Contributing
- License
Layout Switcher utilizes the left and right shift keys to deterministically switch between keyboard layouts:
Left Shift: Activates the first keyboard layout (Layout #1).
Right Shift: Activates the second keyboard layout (Layout #2).
It's crucial to understand that the utility relies on the order of the layouts as they're listed in GNOME's input source manager. The program doesn't specifically distinguish between "en", "ru", or any other language codes. Instead, it's based on the order in which the layouts are installed or listed:
inputSources[0]: This will be the layout that gets activated with the Left Shift key.
inputSources[1]: This will be the layout that gets activated with the Right Shift key.
If, for example, you have French (fr) as the first layout and German (de) as the second in your GNOME settings, then pressing the left shift will switch to French, and the right shift will switch to German.
- Switch between two predefined keyboard layouts using specific key combinations.
- Lightweight and efficient.
- Integrated with the GNOME desktop environment.
Before you start, ensure you have the following dependencies installed:
gcc
libX11-dev
libXi-dev
On Debian-based systems, you can install these using:
sudo apt-get install gcc libX11-dev libXi-dev
- Clone this repository:
git clone https://github.com/dreamscatchers/layout-switcher.git
- Navigate to the project directory:
cd layout-switcher
- Compile the program:
gcc -o switcher switcher.c -lX11 -lXi
- Move the compiled binary to
/usr/local/bin/
:
sudo mv switcher /usr/local/bin/
- Create a service file
layout-switcher.service
in~/.config/systemd/user/
with the provided content:
[Unit]
Description=Layout Switcher Daemon
Wants=gdm.service
After=local-fs.target gdm.service
[Service]
ExecStart=/usr/local/bin/switcher
Environment=DISPLAY=:0
Environment=XAUTHORITY=/run/user/1000/gdm/Xauthority
Environment=XDG_RUNTIME_DIR=/run/user/1000
Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
Environment=PATH=/usr/bin:/usr/local/bin:/usr/local/sbin
Restart=always
[Install]
WantedBy=graphical-session.target
- Enable and start the service:
systemctl --user enable layout-switcher.service
systemctl --user start layout-switcher.service
- To check service status run:
systemctl --user status layout-switcher.service
For a quick setup, you can run the provided setup script:
chmod +x setup.sh
./setup.sh
Once set up, simply use the defined key combinations (e.g., Left Shift, Right Shift) to switch between your two predefined layouts.
To remove the Layout Switcher and its traces, you can use the provided uninstallation script:
chmod +x uninstall.sh
./uninstall.sh
Contributions, issues, and feature requests are welcome! Feel free to check issues page.
After making changes and recompiling the switcher
binary, you can use the provided update script to replace the currently running version:
chmod +x update-switcher.sh
./update-switcher.sh
Distributed under the MIT License. See LICENSE
for more information.