furas

ChatGPT - catch Super+V in Python with XRecord in Mate and Cinnamon

Aug 15th, 2025 (edited)
183
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. [pygtk - Super+V works only for the second time in Keybinder library python linux mint 22.1 cinnamon - Stack Overflow](https://stackoverflow.com/questions/79735661/superv-works-only-for-the-second-time-in-keybinder-library-python-linux-mint-22/79736488#79736488)
  2.  
  3. # Question:
  4.  
  5. I use code with `XRecord` to detect `Super+V`.
  6. Why `Mate` doesn't send `v` to other windows but `Cinnamon` send it.
  7.  
  8. # Answer:
  9.  
  10. Ah! Now I understand exactly what you’re asking.
  11.  
  12. Even when **just listening with XRecord**, you notice different behavior:
  13.  
  14. * **MATE:** Pressing `Super+V` in your script **doesn’t send `v` to other windows**.
  15. * **Cinnamon:** Pressing `Super+V` in your script **still sends `v` to the active window**.
  16.  
  17. This is **not about your XRecord code** — it’s about **how the DE handles modifier keys**:
  18.  
  19. ---
  20.  
  21. ### 1. Modifier behavior in X11
  22.  
  23. When you press a key like `Super+V`, X11 generates:
  24.  
  25. 1. **KeyPress for Super\_L**
  26. 2. **KeyPress for V** (with Super modifier in `state`)
  27. 3. **KeyRelease for V**
  28. 4. **KeyRelease for Super\_L**
  29.  
  30. What happens next depends on **how the window manager interprets the key combination**:
  31.  
  32. * **MATE**:
  33.  
  34. * Super is usually treated as a “modifier only” if no shortcut is bound.
  35. * When your XRecord callback sees the event, MATE **suppresses the V key from being sent to the active window** because it thinks Super is pressed alone and no shortcut is defined.
  36. * Essentially, MATE “eats” the V when combined with Super if it thinks it’s a shortcut trigger.
  37.  
  38. * **Cinnamon**:
  39.  
  40. * Cinnamon has many global shortcuts bound to Super+<key>.
  41. * Even if your XRecord callback runs, Cinnamon **still processes the V key and forwards it to the active window** because it is bound (or partially bound) to some accelerator.
  42. * XRecord cannot block the key — it’s passive listening.
  43. * So V always reaches the active window.
  44.  
  45. ---
  46.  
  47. ### 2. Key takeaway
  48.  
  49. * **XRecord never blocks keys** — it only listens.
  50. * Whether the key reaches other applications **depends on the DE**:
  51.  
  52. * MATE suppresses unbound Super+<key> combos.
  53. * Cinnamon passes Super+<key> to the window if it has a shortcut or doesn’t suppress it.
  54.  
  55. ---
  56.  
  57. ### 3. If you want consistent behavior
  58.  
  59. * Either **disable the conflicting shortcut in Cinnamon** so Super+V isn’t grabbed.
  60. * Or use a **real grab** (`root.grab_key()`) after disabling the shortcut.
  61. * Otherwise, listening with XRecord will **always behave differently depending on the DE**.
  62.  
  63. ---
  64.  
  65. If you want, I can make a **small test script** that shows exactly what MATE and Cinnamon do to the V key when Super is held, so you can see the difference in modifiers and event flow.
  66.  
  67. Do you want me to do that?
  68.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment