Skip to content

Can i get current keyboard layout? #2616

Answered by nativerv
nativerv asked this question in Q&A
Discussion options

You must be logged in to vote

ok, this is definitely an answer for both of them:

# switch-lang
hyprctl \
  --batch "$(
    hyprctl devices -j |
      jq -r '.keyboards[] | .name' |
      while IFS= read -r keyboard; do
        printf '%s %s %s;' 'switchxkblayout' "${keyboard}" 'next'
      done
  )"
# get-lang
# if we switch all of them, then getting any of them (the first) works.
hyprctl devices -j |
  jq -r '.keyboards[] | .active_keymap' |
  head -n1 |
  cut -c1-2 |
  tr 'a-z' 'A-Z'

thx. although the switch-lang is rather slow (0.070s-0.150s for me, which is noticeable) compared to xkblayout-state set +1 which only takes 0.006s. any suggestions on how to make it faster?

Replies: 4 comments 13 replies

Comment options

You must be logged in to vote
11 replies
@nativerv
Comment options

@MightyPlaza
Comment options

@MightyPlaza
Comment options

@nativerv
Comment options

Answer selected by nativerv
@MightyPlaza
Comment options

@nativerv
Comment options

@MightyPlaza
Comment options

@MahouShoujoMivutilde
Comment options

Comment options

You must be logged in to vote
1 reply
@izmyname
Comment options

Comment options

You must be logged in to vote
1 reply
@YawKar
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
8 participants