diff options
| author | dcc <dcc@logografos.com> | 2023-05-27 21:45:28 -0700 |
|---|---|---|
| committer | dcc <dcc@logografos.com> | 2023-05-27 21:45:28 -0700 |
| commit | bd4e72743ca24c0c380c221a6bc7376da1911f7e (patch) | |
| tree | 192b6af99d8ef0d28ffa8a64504ceab77776bb26 /bashs/shell scrips/keyboardlayoutswitcher.sh | |
| download | dcc-suckless-config-bd4e72743ca24c0c380c221a6bc7376da1911f7e.tar.gz dcc-suckless-config-bd4e72743ca24c0c380c221a6bc7376da1911f7e.tar.bz2 dcc-suckless-config-bd4e72743ca24c0c380c221a6bc7376da1911f7e.zip | |
first
Diffstat (limited to 'bashs/shell scrips/keyboardlayoutswitcher.sh')
| -rwxr-xr-x | bashs/shell scrips/keyboardlayoutswitcher.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/bashs/shell scrips/keyboardlayoutswitcher.sh b/bashs/shell scrips/keyboardlayoutswitcher.sh new file mode 100755 index 0000000..ff3101c --- /dev/null +++ b/bashs/shell scrips/keyboardlayoutswitcher.sh @@ -0,0 +1,23 @@ +#!/usr/local/bin/bash + +numberofparameter=$# # Gets the number of parameter passed +currentlayout=$(setxkbmap -query | grep layout | awk '{print $2}') # Gets the current layout +langLayout=($*) # Passes the parameters into an array + +i=0 + +while [[ "$i" -lt "$numberofparameter" ]]; do + if [[ "${langLayout[$i]}" == "${currentlayout}" ]]; then + break + fi + i=$(($i+1)) +done + +# checks if i has not reached to the last parameter (last language) +if [[ "$i" -lt "(($numberofparameter-1))" ]]; then + # Sets to next parameter (next language) + setxkbmap -layout ${langLayout[$(($i+1))]} && notify-send --icon /usr/share/icons/Dracula/apps/scalable/key_bindings.svg "Keyboard Layout" "Keyboard set to ${langLayout[$(($i+1))]}" || notify-send --icon /usr/share/icons/Dracula/apps/scalable/key_bindings.svg "Keyboard Layout" "Something went wrong :/" +else + # Has reached the end, so looping back to the first parameter (first language) + setxkbmap -layout $1 && notify-send --icon /usr/share/icons/Dracula/apps/scalable/key_bindings.svg "Keyboard Layout" "Keyboard set to $1" || notify-send --icon /usr/share/icons/Dracula/apps/scalable/key_bindings.svg "Keyboard Layout" "Something went wrong :/" +fi |
