Hyprland dotfiles
| 1 | #!/bin/bash |
| 2 | # /* ---- 💫 https://github.com/JaKooLit 💫 ---- */ ## |
| 3 | # This is for changing kb_layouts. Set kb_layouts in $settings_file |
| 4 | |
| 5 | layout_file="/.cache/kb_layout" |
| 6 | settings_file="/.config/hypr/UserConfigs/UserSettings.conf" |
| 7 | notif_icon="/.config/swaync/images/ja.png" |
| 8 | |
| 9 | # Refined ignore list with patterns or specific device names |
| 10 | ignore_patterns=( |
| 11 | "--(avrcp)" |
| 12 | "Bluetooth Speaker" |
| 13 | "Other Device |
| 14 | Name" |
| 15 | ) |
| 16 | |
| 17 | |
| 18 | # Create layout file with default layout if it does not exist |
| 19 | if [; then |
| 20 | |
| 21 | default_layout= |
| 22 | default_layout= # Default to 'us' layout |
| 23 | |
| 24 | |
| 25 | fi |
| 26 | |
| 27 | current_layout= |
| 28 | |
| 29 | |
| 30 | # Read available layouts from settings file |
| 31 | if [; then |
| 32 | kb_layout_line= |
| 33 | # Remove leading and trailing spaces around each layout |
| 34 | kb_layout_line= |
| 35 | IFS=',' |
| 36 | else |
| 37 | |
| 38 | |
| 39 | fi |
| 40 | |
| 41 | layout_count= |
| 42 | |
| 43 | |
| 44 | # Find current layout index and calculate next layout |
| 45 | for; do |
| 46 | if [; then |
| 47 | current_index= |
| 48 | break |
| 49 | fi |
| 50 | done |
| 51 | |
| 52 | next_index= |
| 53 | new_layout="" |
| 54 | |
| 55 | |
| 56 | # Function to get keyboard names |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | # Function to check if a device matches any ignore pattern |
| 62 | |
| 63 | |
| 64 | |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | # Function to change keyboard layout |
| 73 | |
| 74 | |
| 75 | |
| 76 | |
| 77 | |
| 78 | |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | # Execute layout change and notify |
| 95 | if ! ; then |
| 96 | |
| 97 | |
| 98 | |
| 99 | else |
| 100 | |
| 101 | |
| 102 | fi |
| 103 | |
| 104 |