import re _ = $(swaymsg input "type:keyboard" xkb_switch_layout next) print("Layout: " + re.search(r'"xkb_active_layout_name": "(.+?)"', $(swaymsg -t get_inputs)).group(1))