changeicon.sh 1.4 KB

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. # Changes the icon theme of the system
  3. # To run: ./changeicon.sh SomeIconThemeName
  4. # To see a list of installed icon themes: ./changeicon.sh
  5. if [ -z "${1}" ]; then echo "Please pass an icon theme name:"$'\n'" ${0} SomeThemeName"$'\n'"You can use these:";ls -l /usr/share/icons/ | grep ^d | awk '{print $9}';ls -l ~/.icons/ | grep ^d | awk '{print $9}'; exit 1; fi
  6. if [ ! -d "/usr/share/icons/${1}" ] && [ ! -d "~/.icons/${1}" ]; then echo "The icon theme does not exist"; exit 2; fi
  7. ICON_THEME="${1}"
  8. if [ -f ~/.config/gtk-3.0/settings.ini ]; then
  9. if [ -n "$(grep 'gtk-icon-theme-name' ~/.config/gtk-3.0/settings.ini)" ]; then
  10. sed -i "s/gtk-icon-theme-name=\(.*\)/gtk-icon-theme-name=${ICON_THEME}/1" ~/.config/gtk-3.0/settings.ini
  11. else
  12. echo "gtk-icon-theme-name=${ICON_THEME}" >> ~/.config/gtk-3.0/settings.ini
  13. fi
  14. else
  15. echo "[Settings]"$'\n'"gtk-icon-theme-name=${ICON_THEME}" > ~/.config/gtk-3.0/settings.ini
  16. fi
  17. if [ -f ~/.gtkrc-2.0 ]; then
  18. if [ -n "$(grep 'gtk-icon-theme-name' ~/.gtkrc-2.0)" ]; then
  19. sed -i "s/gtk-icon-theme-name=\(.*\)/gtk-icon-theme-name=\"${ICON_THEME}\"/1" ~/.gtkrc-2.0
  20. else
  21. echo "gtk-icon-theme-name=\"${ICON_THEME}\"" >> ~/.gtkrc-2.0
  22. fi
  23. else
  24. echo "gtk-icon-theme-name=\"${ICON_THEME}\"" > ~/.gtkrc-2.0
  25. fi
  26. gsettings set org.gnome.desktop.interface icon-theme "${ICON_THEME}"
  27. echo "Change is applied. You may have to restart apps to take changes effect."