From 3b518ee85d9f07b067b5b6cb15eadf930f232d1f Mon Sep 17 00:00:00 2001 From: tigro Date: Tue, 10 Sep 2024 15:42:31 +0300 Subject: [PATCH] Initial commit --- bin/sphere-keyboard-config.sh | 66 ++++++++++++++++++++++++++++++++++ sphere-keyboard-config.desktop | 11 ++++++ 2 files changed, 77 insertions(+) create mode 100755 bin/sphere-keyboard-config.sh create mode 100644 sphere-keyboard-config.desktop diff --git a/bin/sphere-keyboard-config.sh b/bin/sphere-keyboard-config.sh new file mode 100755 index 0000000..f551d36 --- /dev/null +++ b/bin/sphere-keyboard-config.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +if [ "$(echo $LANG)" = "ru_RU.UTF-8" ]; then + table=( + "'Shift_R'" "Control + Правый Shift" + "'Shift_L'" "Control + Левый Shift" + "'Shift'" "Control + Shift" + "'Shift_R'" "Alt + Правый Shift" + "'Shift_L'" "Alt + Левый Shift" + "'Shift'" "Alt + Shift" + "'Space'" "Ctrl + Пробел" + "'Space'" "Alt + Пробел" + ) + + TITLE="Переключение на другую расладку" + TEXT="Выберите комбинацию клавиш для переключения на другую раскладку" +else + table=( + "'Shift_R'" "Control + Right Shift" + "'Shift_L'" "Control + Left Shift" + "'Shift'" "Control + Shift" + "'Shift_R'" "Alt + Right Shift" + "'Shift_L'" "Alt + Left Shift" + "'Shift'" "Alt + Shift" + "'Space'" "Ctrl + Space" + "'Space'" "Alt + Space" + ) + + TITLE="Switch to another layout" + TEXT="Choose shortcut to switch keyboard layout" +fi + + +KEYS=$(zenity \ + --list \ + --title="$TITLE" \ + --text="$TEXT" \ + --print-column=1 \ + --hide-column=1 \ + --height=500 \ + --column="Layout:HD" \ + --column="Description" \ + --hide-header \ + "${table[@]}" +) + +if [ -z $KEYS ]; then + exit 1 +fi + +if [ $KEYS = "'Shift'" ]; then + switch_input_source="'Shift_L'" + switch_input_source_backward="'Shift_R'" +elif [ $KEYS = "'Shift'" ]; then + switch_input_source="'Shift_L'" + switch_input_source_backward="'Shift_R'" +fi + +if [ "${switch_input_source}" != "" -a "${switch_input_source_backward}" != "" ]; then +echo ME + gsettings set org.gnome.desktop.wm.keybindings switch-input-source "[${switch_input_source}]" + gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "[${switch_input_source_backward}]" +else + gsettings set org.gnome.desktop.wm.keybindings switch-input-source "['space', 'XF86Keyboard']" + gsettings set org.gnome.desktop.wm.keybindings switch-input-source-backward "[$KEYS]" +fi diff --git a/sphere-keyboard-config.desktop b/sphere-keyboard-config.desktop new file mode 100644 index 0000000..93a7b50 --- /dev/null +++ b/sphere-keyboard-config.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name[ru]=Настройка клавиатуры +Name=Keyboard Setup +Comment=Easy setup of shortcuts to switch keyboard layouts +Comment[ru]=Быстрая настройка клавиатурной комбинации для смены раскладок +Exec=sphere-keyboard-config +Icon=org.gnome.Characters +Terminal=false +Type=Application +Categories=System;Settings; +StartupNotify=true