3 numberofparameter=$# # Gets the number of parameter passed
4 currentlayout=$(setxkbmap -query | grep layout | awk '{print $2}') # Gets the current layout
5 langLayout=($*) # Passes the parameters into an array
9 while [[ "$i" -lt "$numberofparameter" ]]; do
10 if [[ "${langLayout[$i]}" == "${currentlayout}" ]]; then
16 # checks if i has not reached to the last parameter (last language)
17 if [[ "$i" -lt "(($numberofparameter-1))" ]]; then
18 # Sets to next parameter (next language)
19 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 :/"
21 # Has reached the end, so looping back to the first parameter (first language)
22 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 :/"