From b8f053d270edd90a87aeed48f3aabea874992018 Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Mon, 4 Nov 2024 15:46:00 -0500 Subject: [PATCH] finally got rofi-rbw working --- dot_local/bin/executable_dotool | 2 ++ .../bin/executable_get_plasma_keyboard_layout | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 dot_local/bin/executable_dotool create mode 100644 dot_local/bin/executable_get_plasma_keyboard_layout diff --git a/dot_local/bin/executable_dotool b/dot_local/bin/executable_dotool new file mode 100644 index 0000000..5a1f9c4 --- /dev/null +++ b/dot_local/bin/executable_dotool @@ -0,0 +1,2 @@ +#!/bin/sh +DOTOOL_XKB_LAYOUT=us DOTOOL_XKB_VARIANT=$(get_plasma_keyboard_layout) /usr/bin/dotool "$@" diff --git a/dot_local/bin/executable_get_plasma_keyboard_layout b/dot_local/bin/executable_get_plasma_keyboard_layout new file mode 100644 index 0000000..da402b8 --- /dev/null +++ b/dot_local/bin/executable_get_plasma_keyboard_layout @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import dbus + +def get_keyboard_info(): + bus = dbus.SessionBus() + keyboard = bus.get_object('org.kde.keyboard', '/Layouts') + keyboard_interface = dbus.Interface(keyboard, dbus_interface='org.kde.KeyboardLayouts') + + layouts_list = keyboard_interface.getLayoutsList() + current_layout_index = keyboard_interface.getLayout() + + return layouts_list, current_layout_index + +def set_keyboard_layout_env(layouts_list, current_layout_index): + current_layout = layouts_list[current_layout_index] + _, _, name = current_layout + + if "Dvorak" in name: + keyboard_layout = "dvorak" + elif "US" in name: + keyboard_layout = "basic" + else: + keyboard_layout = "unknown" + + return keyboard_layout + +if __name__ == "__main__": + layouts_list, current_layout_index = get_keyboard_info() + keyboard_layout = set_keyboard_layout_env(layouts_list, current_layout_index) + print(keyboard_layout)