aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/scripts/SwitchKeyboardLayout.sh
diff options
context:
space:
mode:
authorJaKooLit <jimmielovejay@gmail.com>2023-12-07 14:29:10 +0900
committerJaKooLit <jimmielovejay@gmail.com>2023-12-07 14:29:10 +0900
commitabb68d82a2a839438a3de19b377084ae9796bf42 (patch)
tree3e3b79a8e0b6df9d0782d0f14c00d3dcec704893 /config/hypr/scripts/SwitchKeyboardLayout.sh
parent91515c96c89e22cc8411279a6263740f897ba6ca (diff)
updated initial boot and kb layout switch
Diffstat (limited to 'config/hypr/scripts/SwitchKeyboardLayout.sh')
-rwxr-xr-xconfig/hypr/scripts/SwitchKeyboardLayout.sh18
1 files changed, 13 insertions, 5 deletions
diff --git a/config/hypr/scripts/SwitchKeyboardLayout.sh b/config/hypr/scripts/SwitchKeyboardLayout.sh
index 40b212f0..e7c56b42 100755
--- a/config/hypr/scripts/SwitchKeyboardLayout.sh
+++ b/config/hypr/scripts/SwitchKeyboardLayout.sh
@@ -1,13 +1,21 @@
-#!/bin/bash
+#!/usr/bin/env bash
+
+layout_f="$HOME/.cache/kb_layout"
+settings_file="$HOME/.config/hypr/configs/Settings.conf"
+
+# Check if ~/.cache/kb_layout exists and create it with a default layout from Settings.conf if not found
+if [ ! -f "$layout_f" ]; then
+ default_layout=$(grep 'kb_layout=' "$settings_file" | cut -d '=' -f 2 | cut -d ',' -f 1 2>/dev/null)
+ if [ -z "$default_layout" ]; then
+ default_layout="us" # Default to 'us' layout if Settings.conf or 'kb_layout' is not found
+ fi
+ echo "$default_layout" > "$layout_f"
+fi
-layout_f="/tmp/kb_layout"
current_layout=$(cat "$layout_f")
# Read keyboard layout settings from Settings.conf
-settings_file="$HOME/.config/hypr/configs/Settings.conf"
-
if [ -f "$settings_file" ]; then
- # Extract the value of kb_layout from Settings.conf
kb_layout_line=$(grep 'kb_layout=' "$settings_file" | cut -d '=' -f 2)
IFS=',' read -ra layout_mapping <<< "$kb_layout_line"
fi
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage