Git Product home page Git Product logo

i3-keyboard-layout's Introduction

i3-keyboard-layout

Change keyboard layout with a keystroke + show it in the status bar.

Install

Download i3-keyboard-layout, make sure it's executable (chmod + x <file>), and store it somewhere in your home directory (or in your $PATH if you prefer)

Usage

Assign a keystroke in your i3 configuration to switch to different layouts:

# ~/.config/i3/config

bindsym $mod+z exec path/to/i3-keyboard-layout set us
bindsym $mod+x exec path/to/i3-keyboard-layout set es

Alternatively (or aditionally), you can use a single keystroke to cycle through a list of your most used layouts:

# ~/.config/i3/config

bindsym $mod+space exec path/to/i3-keyboard-layout cycle us es de

Each time you press that key, the next layout on the list will be selected.

If you want to use layouts with variants, you can use quotes, like this:

# ~/.config/i3/config

bindsym $mod+space exec path/to/i3-keyboard-layout cycle us "us euro"

Display current layout

NOTE: You can skip this part if you use some kind of tray indicator such as sbxkb, which is probably what you want if you prefer a flag instead of the name of the layout.

A subcommand is included to display the current layout on the i3status bar. On your bar configuration, you need to pipe i3status onto the i3status subcommand:

# ~/.config/i3/config

bar {
  # status_command i3status # this is the usual default configuration
  status_command i3status | i3-keyboard-layout i3status
}

i3status needs to be configured tou output the i3bar JSON format (which is usually the default):

# ~/.config/i3status/config

general {
  output_format = i3bar
}

At this point only prepending the layout at the left of everything else is supported.

i3 bar

i3-keyboard-layout's People

Contributors

porras avatar slaviber avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

i3-keyboard-layout's Issues

latam - layout codes with more than two characters

Hi, and thanks for this script.

I usually switch between es, us and latam layouts. The cycle won't work due to it does not recognize the "latam" code.

Solution is easy, in line 6 just change this:

setxkbmap -query | grep -oP 'layout:\s*\K(\w{2})'

to this:

setxkbmap -query | grep -oP 'layout:\s*\K(\w{2,5})'

It should be checked for other codes with more characters, maybe.

Error when using "us,br intl" keyboard

Hi

My keystroke is

bindsym $mod+space exec ~/.config/i3/i3-keyboard-layout cycle br "us,br intl"

This command works when I run it directly on CLI, but i3 raises error:

ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'sticky', 'split', 'floating', 'mark', 'unmark', 'resize', 'rename', 'nop', 'scratchpad', 'swap', 'title_format', 'mode', 'bar', 'gaps'
ERROR: Your command: exec ~/.config/i3/i3-keyboard-layout cycle br "us,br intl"
ERROR:                                                                 ^^^^^^^^
~

Relabel repo as a "not i3 specific repo"

I love this repo. I've been using this script for years now but I'm not an i3 user, even when I was I used to use i3blocks as my bar.
I was thinking why it should be "i3-keyboard-layout"?
It assumes that everybody uses i3status along with i3 which is sad.
It can simply be keyboard-layout and have keyboard-layout related scripts. (kblayout for better life even)

  • kblayout the star, script itself.
  • i3status-kblayout containing current i3status function of the i3-keyboard-layout.
  • blocks-kblayout containing update script for i3blocks (something like this)
    Which can be used in dwmblocks and i3blocks...

And maybe make the script read some $STATUSBAR variable before sending refresh singal to any bar so it can work with all bars (this is my implementation in my repo, default on dwmblocks):

    [ "$STATUSBAR" = "i3status" ] && pgrep i3status | xargs --no-run-if-empty kill -s USR1 || # tell i3status to update
        pkill -RTMIN+30 "${STATUSBAR:-dwmblocks}"

It makes the main script more aligned with its purpose: Managing layouts only.

i3bar update layout text

Hi there,

I can change the layout using the script, but the string displayed on the i3bar isn't updated when I cycle between layouts, not even after refreshing i3. The same string is always displayed.

I am using manjaro i3.

Something simpler, please

The idea to display keyboard layout in i3status bar is very good (and frankly should be implemented in i3status conf itself), but all you really need is setxkbmap, which probably comes in every Linux. Specifically, it would be great to somehow display the output of

setxkbmap -query | awk '/layout/{print $2}'

This output should somehow go in i3status bar. I have not found a way to include this in i3status. It is very puzzling to me that i3wm developers, otherwise extremely conscious of utf8 stuff and such, do not allow a simple output like this in i3status.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.