Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

60%
+1 −0
Q&A How to use several keyboard layouts with Awesome WM?

Have you tried using awful's widget instead: awful.widget.keyboardlayout. It seems to be a switcher that automatically loads the available X11 settings(?). Here's a sample configuration (untested,...

posted 1mo ago by tantan‭

Answer
#1: Initial revision by user avatar tantan‭ · 2024-09-15T10:12:14Z (about 1 month ago)
Have you tried using [awful's widget instead](https://awesomewm.org/doc/api/classes/awful.widget.keyboardlayout.html): awful.widget.keyboardlayout. It seems to be a switcher that automatically loads the available X11 settings(?).

Here's a sample configuration (untested, pruned from mine).

**NB**: I only use one layout, so I haven't tried the switching functionality.

```lua
local awful = require("awful")
local wibox = require("wibox")
local mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
                                     menu = mymainmenu })
local mykeyboardlayout = awful.widget.keyboardlayout()

awful.screen.connect_for_each_screen(function(s)
    -- Create a promptbox for each screen
    s.mypromptbox = awful.widget.prompt()
    -- Create the wibox
    s.mywibox = awful.wibar({ position = "top", screen = s })

    -- Add widgets to the wibox
    s.mywibox:setup {
        layout = wibox.layout.align.horizontal,
        { -- Left widgets
            layout = wibox.layout.fixed.horizontal,
            mylauncher,
            s.mypromptbox,
        },
        s.mytasklist, -- Middle widget
        { -- Right widgets
            layout = wibox.layout.fixed.horizontal,
            mykeyboardlayout,
            wibox.widget.systray(),
        },
    }
end)
```