{"id":13572895,"url":"https://github.com/echuraev/keyboard_layout","last_synced_at":"2026-03-04T15:30:51.733Z","repository":{"id":23344312,"uuid":"98757853","full_name":"echuraev/keyboard_layout","owner":"echuraev","description":"Keyboard switcher for Awesome WM with additional layouts","archived":false,"fork":false,"pushed_at":"2022-09-26T05:50:32.000Z","size":1049,"stargazers_count":77,"open_issues_count":1,"forks_count":13,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T22:51:31.333Z","etag":null,"topics":["awesomewm","keyboard-layout","keyboard-switcher","keyboard-widget","lua","switcher-widget","widget"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/echuraev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-29T20:44:09.000Z","updated_at":"2025-03-01T14:33:16.000Z","dependencies_parsed_at":"2023-01-13T23:09:54.301Z","dependency_job_id":null,"html_url":"https://github.com/echuraev/keyboard_layout","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/echuraev/keyboard_layout","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echuraev%2Fkeyboard_layout","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echuraev%2Fkeyboard_layout/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echuraev%2Fkeyboard_layout/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echuraev%2Fkeyboard_layout/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/echuraev","download_url":"https://codeload.github.com/echuraev/keyboard_layout/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/echuraev%2Fkeyboard_layout/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30084953,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T13:22:36.021Z","status":"ssl_error","status_checked_at":"2026-03-04T13:20:45.750Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["awesomewm","keyboard-layout","keyboard-switcher","keyboard-widget","lua","switcher-widget","widget"],"created_at":"2024-08-01T15:00:23.562Z","updated_at":"2026-03-04T15:30:51.704Z","avatar_url":"https://github.com/echuraev.png","language":"Lua","funding_links":[],"categories":["features","Keyboard Related"],"sub_categories":["Optical Health"],"readme":"# Keyboard switcher for Awesome WM with additional layouts\n\n## Intro\nUsually I use two keyboard layouts on my computer there are English and Russian\nlayouts. But sometimes I need to write something on another language, for\nexample: German.  But adding new keyboard layout was very annoying me. Because I\nhave to press more than one time for changing my keyboard layout from Russian to\nEnglish.  But with this widget I can configure additional layouts. When I press\non buttons on keyboard only my primary layouts will be switching. But when I\nwant to use additional layout, I just click right mouse button on keyboard\nwidget and select one of additional layouts. You can see how it is work in the\nScreenshot section.\n\n## Table of Contents\n\n\u003c!-- vim-markdown-toc GFM --\u003e\n\n* [Features](#features)\n* [Installing](#installing)\n* [Usage](#usage)\n    * [Options](#options)\n    * [Functions](#functions)\n    * [How to use a different layout switch command](#how-to-use-a-different-layout-switch-command)\n    * [TUI wrap configuration](#tui-wrap-configuration)\n* [Screenshots](#screenshots)\n* [References](#references)\n    * [Author](#author)\n    * [Licence](#licence)\n    * [Flags icons](#flags-icons)\n\n\u003c!-- vim-markdown-toc --\u003e\n\n## Features\n* Conception of additional layouts\n* Flexible configuration of the widget\n* GUI/TUI modes of display current layout.\n* Possibility of remembering layout per window.\n\n## Installing\nClone this repository to your Awesome WM configuration directory:\n```bash\ncd ~/.config/awesome\ngit clone https://github.com/echuraev/keyboard_layout\n```\n\n## Usage\n1. Add call of `keyboard_layout` module to your `rc.init`:\n   ```lua\n   local keyboard_layout = require(\"keyboard_layout\")\n   ```\n\n2. Create instance of keyboard widget (full information about options that are\n   supported, you can find in section: [options](#options)). You can choose\n   between text and graphical layout label, see below. Primary and Additional\n   layouts can be set by `add_primary_layout` and `add_additional_layout`\n   respectively. And when you add all necessary options to `kbdcfg` then you\n   have to call `bind` functions. In this call all your settings will apply.\n\n   2.1. Create text label:\n   ```lua\n   local kbdcfg = keyboard_layout.kbdcfg({type = \"tui\"})\n\n   kbdcfg.add_primary_layout(\"English\", \"US\", \"us\")\n   kbdcfg.add_primary_layout(\"Русский\", \"RU\", \"ru\")\n\n   kbdcfg.add_additional_layout(\"Deutsch\",  \"DE\", \"de\")\n   kbdcfg.add_additional_layout(\"Français\", \"FR\", \"fr\")\n   kbdcfg.bind()\n   ```\n   2.2. Create graphical label:\n   ```lua\n   local kbdcfg = keyboard_layout.kbdcfg({type = \"gui\"})\n\n   kbdcfg.add_primary_layout(\"English\", beautiful.en_layout, \"us\")\n   kbdcfg.add_primary_layout(\"Русский\", beautiful.ru_layout, \"ru\")\n\n   kbdcfg.add_additional_layout(\"Deutsch\",  beautiful.de_layout, \"de\")\n   kbdcfg.add_additional_layout(\"Français\", beautiful.fr_layout, \"fr\")\n   kbdcfg.bind()\n   ```\n3. Bind your mouse keys:\n   ```lua\n   -- Mouse bindings\n   kbdcfg.widget:buttons(\n    awful.util.table.join(awful.button({ }, 1, function () kbdcfg.switch_next() end),\n                          awful.button({ }, 3, function () kbdcfg.menu:toggle() end))\n   )\n   ```\n4. Bind your keyboard shortcuts:\n   ```lua\n   globalkeys = awful.util.table.join(globalkeys,\n       -- Shift-Alt to change keyboard layout\n       awful.key({\"Shift\"}, \"Alt_L\", function () kbdcfg.switch_next() end),\n       -- Alt-Shift to change keyboard layout\n       awful.key({\"Mod1\"}, \"Shift_L\", function () kbdcfg.switch_next() end)\n   )\n   ```\n5. Add widget to your wibar:\n   ```lua\n   s.mywibox = awful.wibar({ position = \"top\", screen = s })\n\n   -- Add widgets to the wibox\n   s.mywibox:setup {\n       layout = wibox.layout.align.horizontal,\n       { -- Left widgets\n           -- ...\n       },\n       { -- Middle widgets\n           -- ...\n       },\n       { -- Right widgets\n           -- ...\n           kbdcfg.widget,\n           -- ...\n       },\n   }\n   ```\n\n### Options\nThe following options you can pass to create function:\n* `type` - set type of widget. It is two types of widget `gui` or `tui`.\n    Default: `tui`\n* `cmd` - command to change layout. For more information see section:\n    [How to use a different layout switch command](#how-to-use-a-different-layout-switch-command).\n    Default: `setxkbmap`\n* `default_layout_index` - set index of default layout. Default: `1`\n* `remember_layout` - to remember selected layout per window set it to `true`.\n    Default: `false`\n* `tui_wrap_left`, `tui_wrap_right` - allows you to customise the wrapping\n    around the `tui` version of the widget. Default: `\" \"`\n\n### Functions\n* `switch_next()` - this function switches one primary keyboard layout to the\n    next primary layout.\n* `bind()` - this function applies all settings to the widget.\n* `switch_by_name(name)` - this function is mostly used for setting additional\n    layouts. It gets a layout name (first parameter of `add_xxxx_layout()` of\n    layout that should be set.\n* `add_primary_layout(name, label, subcmd)` - this function adds a primary\n    layout to the widget.\n* `add_additional_layout(name, label, subcmd)` - this function adds additional\n    layout to the widget.\n\n### How to use a different layout switch command\n\nBy default the widget uses `setxkbmap` command to switch keyboard layouts. The\nfollowing parameters allow it to use a non-standard layout switcher, for example\nthe [Fcitx](https://github.com/fcitx/fcitx) for Chinese/Japanese/Korean input:\n\n```lua\nlocal kbdcfg = keyboard_layout.kbdcfg({cmd = \"fcitx-remote -s\", type = \"tui\"})\n\nkbdcfg.add_primary_layout(\"English\",  \"us\", \"fcitx-keyboard-us\")\nkbdcfg.add_primary_layout(\"Russian\",  \"ru\", \"fcitx-keyboard-ru-ruu\")\nkbdcfg.add_primary_layout(\"Japanese\", \"ja\", \"mozc\")\n```\n\nNote, that you should pass a valid input method name to `fcitx-remote`\ncommand. The last layout in the example uses the\n[Mozc](https://github.com/google/mozc) as an input method for Japanese input.\n\n### TUI wrap configuration\n\nBy default, the `tui` version adds a `\" \"` wrapping around the widget as a\nmargin. In certain cases however, this might not be what you want. To change\nthe wrapping around the widget, modify your config as such:\n\n```lua\nlocal kbdcfg = keyboard_layout.kbdcfg({\n    type = \"tui\",\n    tui_wrap_right = \"\",  -- wrapping on the right\n    tui_wrap_left = \" \"  -- wrapping on the left\n})\n```\n\nThe example given should result in something kinda like this:\n\n![Screenshot of the widget accompanied by a nerd font keyboard icon on the left](docs/tui_wrap_configuration.png)\n\n## Screenshots\nIn the beginning of both screen casts I changed layouts by keyboard shortcats\nand only primary layouts were switched. After that I showed how additional\nlayouts work.\n\nUsage of gui_layout:\n![Usage of gui_layout.gif](docs/gui_usage.gif)\n\nUsage of tui_layout\n![Usage of tui_layout.gif](docs/tui_usage.gif)\n\n## References\n### Author\nEgor Churaev egor.churaev@gmail.com\n\n### Licence\nMIT\n\n### Flags icons\nIcon with British flag I take from here: https://www.gosquared.com/resources/flag-icons/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechuraev%2Fkeyboard_layout","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fechuraev%2Fkeyboard_layout","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fechuraev%2Fkeyboard_layout/lists"}