Add grave modifier support for hotkeys
Implements support for using the grave key (`) as a hotkey modifier in Barrier, enabling hotkey combinations like Grave+1, Grave+2, etc. Key changes: - Add XK_grave case to getModifierBitForKeySym() for XKB support - Add fallback mapping for grave modifier to Mod4 in XKB path - Include KeyModifierGrave in allowed modifiers for hotkey registration - Add setup documentation for required X11 modifier mapping Requires running: xmodmap -e "add mod4 = grave" 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
f7ad724570
commit
314f1070e5
|
@ -0,0 +1,48 @@
|
|||
# Grave Modifier Setup for Barrier
|
||||
|
||||
## Overview
|
||||
This implementation adds support for using the grave key (`) as a hotkey modifier in Barrier, similar to Control, Alt, and Shift.
|
||||
|
||||
## Required Setup
|
||||
|
||||
### 1. Code Changes
|
||||
The following code changes have been implemented:
|
||||
|
||||
- **XWindowsUtil.cpp**: Added `case XK_grave: return kKeyModifierBitGrave;` to `getModifierBitForKeySym()`
|
||||
- **XWindowsKeyState.cpp**: Added fallback mapping for grave modifier to Mod4 in `updateKeysymMapXKB()`
|
||||
- **key_types.cpp**: Already included grave modifier in `kModifierNameMap`
|
||||
|
||||
### 2. X11 Modifier Mapping (REQUIRED)
|
||||
The grave key must be mapped to an X11 modifier for hotkeys to work. Run this command:
|
||||
|
||||
```bash
|
||||
xmodmap -e "add mod4 = grave"
|
||||
```
|
||||
|
||||
### 3. Make it Permanent
|
||||
To make the X11 mapping persistent across reboots, add this line to `~/.xsessionrc`:
|
||||
|
||||
```bash
|
||||
echo 'xmodmap -e "add mod4 = grave"' >> ~/.xsessionrc
|
||||
```
|
||||
|
||||
## Usage
|
||||
Once setup is complete, you can use grave modifier hotkeys in your Barrier configuration:
|
||||
|
||||
```
|
||||
keystroke(Grave+1) = switchToScreen(screen1,960,540)
|
||||
keystroke(Grave+2) = switchToScreen(screen2,960,540)
|
||||
```
|
||||
|
||||
## Verification
|
||||
To verify the setup:
|
||||
|
||||
1. Check modifier mapping: `xmodmap -pm`
|
||||
- Should show `grave (0x31)` in the mod4 line
|
||||
2. Test hotkeys: Press and hold grave, then press a number key
|
||||
3. Check Barrier logs for successful hotkey registration
|
||||
|
||||
## Troubleshooting
|
||||
- If hotkeys don't work, verify grave is mapped to mod4: `xmodmap -pm`
|
||||
- If mapping is lost after reboot, ensure `~/.xsessionrc` contains the xmodmap command
|
||||
- Restart Barrier server after making X11 mapping changes
|
|
@ -317,6 +317,7 @@ XWindowsKeyState::updateKeysymMap(barrier::KeyMap& keyMap)
|
|||
m_modifierToX[KeyModifierShift] = ShiftMask;
|
||||
m_modifierToX[KeyModifierCapsLock] = LockMask;
|
||||
m_modifierToX[KeyModifierControl] = ControlMask;
|
||||
m_modifierToX[KeyModifierGrave] = Mod4Mask;
|
||||
|
||||
// prepare map from KeyID to KeyCode
|
||||
m_keyCodeFromKey.clear();
|
||||
|
@ -779,6 +780,16 @@ XWindowsKeyState::updateKeysymMapXKB(barrier::KeyMap& keyMap)
|
|||
}
|
||||
}
|
||||
|
||||
// Add fallback for grave modifier if not found during XKB discovery
|
||||
if (m_modifierToX.find(KeyModifierGrave) == m_modifierToX.end()) {
|
||||
LOG((CLOG_DEBUG1 "XKB: Adding fallback mapping for grave modifier to Mod4"));
|
||||
m_modifierToX[KeyModifierGrave] = Mod4Mask;
|
||||
// Also update the reverse mapping for consistency
|
||||
if (m_modifierFromX.size() > 3) { // Mod4 is bit 3
|
||||
m_modifierFromX[3] |= KeyModifierGrave;
|
||||
}
|
||||
}
|
||||
|
||||
// change all modifier masks to barrier masks from X masks
|
||||
keyMap.foreachKey(&XWindowsKeyState::remapKeyModifiers, this);
|
||||
|
||||
|
|
|
@ -528,7 +528,7 @@ XWindowsScreen::registerHotKey(KeyID key, KeyModifierMask mask)
|
|||
{
|
||||
// only allow certain modifiers
|
||||
if ((mask & ~(KeyModifierShift | KeyModifierControl |
|
||||
KeyModifierAlt | KeyModifierSuper)) != 0) {
|
||||
KeyModifierAlt | KeyModifierSuper | KeyModifierGrave)) != 0) {
|
||||
LOG((CLOG_DEBUG "could not map hotkey id=%04x mask=%04x", key, mask));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1646,6 +1646,9 @@ XWindowsUtil::getModifierBitForKeySym(KeySym keysym)
|
|||
case XK_Scroll_Lock:
|
||||
return kKeyModifierBitScrollLock;
|
||||
|
||||
case XK_grave:
|
||||
return kKeyModifierBitGrave;
|
||||
|
||||
default:
|
||||
return kKeyModifierBitNone;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue