.language.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. restart_session=0 #If change locale the system need restart session to see the changes
  3. #Comprobe if language was selected
  4. code=$(cat ~/.codecheck | grep LANG= | tail --bytes 2)
  5. if [ "$code" = "0" ]; then
  6. lang=$(zenity --list --title="Select your locale (optional)" \
  7. --column="Locale" --column="Language" \
  8. "en_US.UTF-8" "English" \
  9. "gl_ES.UTF-8" "Galego" \
  10. "es_ES.UTF-8" "Spanish" \
  11. "pt_BR.UTF-8" "Brazilian Portuguese")
  12. [ "$lang" ] || lang="en_US.UTF-8"
  13. #Copy locale in locale.conf
  14. sudo echo "LANG=$lang" > /etc/locale.conf
  15. #Put a new line confirm that language was selected
  16. sed -i '/LANG=./d' ~/.codecheck
  17. echo "LANG=1" >> ~/.codecheck
  18. #Copy install scripts in that language
  19. sudo cp -a /root/.scriptsInstallation/language/${lang/_*/}/* /root/.scriptsInstallation/
  20. restart_session=1
  21. fi
  22. #Comprobe if X11 keymap was selected
  23. code=$(cat .codecheck | grep XKBMAP= | cut -d '=' -f 2)
  24. if [ "$code" = "0" ]; then
  25. keymap=$(zenity --list --title="Select your keymap (optional)" \
  26. --column="Keymap" $(localectl list-x11-keymap-layouts))
  27. [ "$keymap" ] || keymap="us"
  28. setxkbmap $keymap
  29. #Sae XKBMAP in .codecheck to use in other time. For example if you install X11 with scripts
  30. sed -i '/XKBMAP=./d' ~/.codecheck
  31. echo "XKBMAP=$keymap" >> ~/.codecheck
  32. fi
  33. if [ $restart_session -eq 1 ]; then
  34. #Restart session
  35. pkill -KILL -u $(whoami)
  36. fi