configure 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/bash
  2. # Copyright (c) 2015-2016 Keefer Rourke <keefer.rourke@gmail.com>
  3. # Permission is hereby granted, free of charge, to any person obtaining
  4. # a copy of this software and associated documentation files (the "Software"),
  5. # to deal in the Software without restriction, including without limitation the
  6. # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  7. # sell copies of the Software, and to permit persons to whom the Software is
  8. # furnished to do so, subject to the following conditions:
  9. # The above copyright notice and this permission notice shall be included in
  10. # all copies or substantial portions of the Software.
  11. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  17. # SOFTWARE.
  18. # this script will update various icon symlinks based on your machine's
  19. # reported distribution and desktop environment
  20. # formats text to lower and removes whitespace and non-alpha chars
  21. format() {
  22. name=$(awk '{print tolower($0)}' <<< $1)
  23. name=$(sed 's/\s+//g;s/[^a-z]//g'<<< $name)
  24. echo $name
  25. }
  26. # define variables
  27. DISTRO=$(format "$(lsb_release -si 2>/dev/null)")
  28. DE=$(format "$XDG_CURRENT_DESKTOP")
  29. distro_error=0
  30. de_error=0
  31. wd=$PWD
  32. # set distributor logo based on distro detected through lsb_release
  33. cd "$wd/places/scalable"
  34. distromatch() {
  35. case $DISTRO in
  36. arch) ln -sf distributor-logo-archlinux.svg distributor-logo.svg ;;
  37. debian|raspbian) ln -sf distributor-logo-debian.svg distributor-logo.svg ;;
  38. elementaryos) ln -sf distributor-logo-elementaryos.svg distributor-logo.svg ;;
  39. fedora) ln -sf distributor-logo-fedora.svg distributor-logo.svg ;;
  40. gentoo) ln -sf distributor-logo-gentoo.svg distributor-logo.svg ;;
  41. korora) ln -sf distributor-logo-korora.svg distributor-logo.svg ;;
  42. linuxmint) ln -sf distributor-logo-linuxmint.svg distributor-logo.svg ;;
  43. mageia) ln -sf distributor-logo-mageia.svg distributor-logo.svg ;;
  44. manjaro) ln -sf distributor-logo-manjaro.svg distributor-logo.svg ;;
  45. nixos) ln -sf distributor-logo-nixos.svg distributor-logo.svg ;;
  46. opensuse) ln -sf distributor-logo-opensuse.svg distributor-logo.svg ;;
  47. solus) ln -sf distributor-logo-solus.svg distributor-logo.svg ;;
  48. ubuntu) ln -sf distributor-logo-ubuntu.svg distributor-logo.svg ;;
  49. *) return 1 ;;
  50. esac
  51. }
  52. # in case lsb_release detection fails, try /etc/os-release
  53. alt_distromatch() {
  54. local pattern="ID=arch:ID=opensuse:ID=raspbian:ID=ubuntu:ID=nixos:ID=solus"
  55. local IFS=:
  56. distro_error=1
  57. for i in $pattern; do
  58. if $(grep -wsq "$i" /etc/os-release); then
  59. DISTRO=${i##*=}
  60. distromatch
  61. distro_error=0
  62. break
  63. fi
  64. done
  65. if [ $distro_error -eq 1 ]; then
  66. echo "Could not determine distribution logo."
  67. ln -sf distributor-logo-gnome.svg distributor-logo.svg
  68. fi
  69. }
  70. # attempt to detect distribution
  71. ! distromatch && alt_distromatch
  72. # prompt for desktop environment integration instead of distro
  73. read -p "Use distributor logo from desktop environment? [y/N] " yn
  74. case $yn in
  75. [Yy]* )
  76. case $DE in
  77. budgie|budgiegnome) ln -sf distributor-logo-budgie.svg distributor-logo.svg ;;
  78. gnome) ln -sf distributor-logo-gnome.svg distributor-logo.svg ;;
  79. unity) ln -sf distributor-logo-unity.svg distributor-logo.svg ;;
  80. xfce) ln -sf distributor-logo-xfce.svg distributor-logo.svg ;;
  81. lxde) ln -sf distributor-logo-lxde.svg distributor-logo.svg ;;
  82. kde) ln -sf distributor-logo-kde.svg distributor-logo.svg ;;
  83. *)
  84. echo "Could not determine desktop environment... Using distribution logo."
  85. de_error=1
  86. ;;
  87. esac
  88. ;;
  89. * ) if [ $distro_error -eq 0 ]; then
  90. echo "Using distribution logo."
  91. elif [ $distro_error -eq 1 ] || [ $de_error -eq 1 ]; then
  92. echo "Could not determine distributor logo, you may need to set this manually in places/scalable/"
  93. fi
  94. ;;
  95. esac
  96. ln -sf distributor-logo.svg start-here.svg # fixes potentially broken link
  97. cd "$wd"
  98. ln -sfr "$wd"/places/scalable/distributor-logo.svg "$wd"/apps/scalable/cs-desktop.svg
  99. ln -sfr "$wd"/places/scalable/distributor-logo.svg "$wd"/apps/scalable/applications-system.svg
  100. echo "Updated distributor logo."
  101. # update mimetypes based on distro and de
  102. cd "$wd"/mimetypes/scalable
  103. case $DISTRO in
  104. opensuse) ln -sf application-x-rpm-opensuse.svg application-x-rpm.svg ;;
  105. fedora) ln -sf application-x-rpm-fedora.svg application-x-rpm.svg ;;
  106. debian|raspbian) ln -sf application-x-deb-debian.svg application-x-deb.svg ;;
  107. ubuntu) ln -sf application-x-deb-ubuntu.svg application-x-deb.svg ;;
  108. linuxmint)
  109. ln -sf application-x-deb-linuxmint.svg application-x-deb.svg
  110. ln -sf application-x-desktop-linuxmint.svg application-x-desktop.svg
  111. ;;
  112. * )
  113. ln -sf application-x-deb-debian.svg application-x-deb.svg
  114. ln -sf application-x-rpm-redhat.svg application-x-rpm.svg
  115. ;;
  116. esac
  117. echo "Updated package archive icons."
  118. case $DE in
  119. budgie|budgiegnome) ln -sf application-x-desktop-budgie.svg application-x-desktop.svg ;;
  120. gnome) ln -sf application-x-desktop-gnome.svg application-x-desktop.svg ;;
  121. unity) ln -sf application-x-desktop-unity.svg application-x-desktop.svg ;;
  122. lxde) ln -sf application-x-desktop-lxde.svg application-x-desktop.svg ;;
  123. xfce) ln -sf application-x-desktop-xfce.svg application-x-desktop.svg ;;
  124. kde) ln -sf application-x-desktop-kde.svg application-x-desktop.svg ;;
  125. esac
  126. echo "Updated desktop mimetype icons."