GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — How to get mods keysym names from keysym numbers · Issue #272 · python-xlib/python-xlib

How to get mods keysym names from keysym numbers #272

New issue
Copy link
New issue
Copy link
Open
Open
How to get mods keysym names from keysym numbers#272
Copy link

Description

@ldrahnik
ldrahnik
opened on Apr 17, 2024
Issue body actions

I needed to return for Shift dynamically Shift_L so I wrote this code and my question is whether part of the code marked as here could become part of this lib:

import Xlib.XK

mods_to_indexes_x11 = {
        "Shift": Xlib.X.ShiftMapIndex,
        "Lock": Xlib.X.LockMapIndex,
        "Control": Xlib.X.ControlMapIndex,
        "Mod1": Xlib.X.Mod1MapIndex,
        "Mod2": Xlib.X.Mod2MapIndex,
        "Mod3": Xlib.X.Mod3MapIndex,
        "Mod4": Xlib.X.Mod4MapIndex,
        "Mod5": Xlib.X.Mod5MapIndex
    }

if display and mod_name in mods_to_indexes_x11:

    mods = display.get_modifier_mapping()
    first_keycode = mods[mods_to_indexes_x11[mod_name]][0]
    if first_keycode:
        key = EV_KEY.codes[int(first_keycode) - 8]
        keysym = display.keycode_to_keysym(first_keycode, 0)

    	# here
        for key in Xlib.XK.__dict__:
            if key.startswith("XK") and Xlib.XK.__dict__[key] == keysym:
                return key[3:]
        # here

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.