install.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/bash
  2. URL="https://git.sr.ht/~heckyel/i3-config"
  3. while true
  4. do
  5. function _copy_i3_config() {
  6. # check root
  7. if [[ "$UID" == 0 ]]; then
  8. root_key=''
  9. elif [[ $(command -v sudo) ]]; then
  10. root_key=sudo
  11. elif [[ $(command -v doas) ]]; then
  12. root_key=doas
  13. fi
  14. ## Install dependencies
  15. if [[ $(command -v pacman) ]]; then
  16. $root_key pacman -Syy --noconfirm
  17. # i3 base
  18. $root_key pacman -S --noconfirm i3-wm i3status dmenu sysstat
  19. # i3 blocks and dependecies
  20. $root_key pacman -S --noconfirm i3blocks rofi \
  21. conky acpi scrot st sakura feh ranger bubblewrap \
  22. ttf-hack xenocara-xbacklight xdg-user-dirs
  23. fi
  24. # Install i3config
  25. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Cloning i3-config...' '\e[m'
  26. git clone "$URL" "/tmp/i3config/" --depth=1
  27. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying images...' '\e[m'
  28. install -d -m755 "$HOME/.config/i3/images"
  29. for i in background.png; do
  30. install -m644 -v "/tmp/i3config/images/$i" "$HOME/.config/i3/images/$i"
  31. done
  32. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying scripts...' '\e[m'
  33. cp -rv /tmp/i3config/scripts "$HOME/.config/i3/"
  34. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying i3-config...' '\e[m'
  35. for i in config i3blocks.conf; do
  36. install -m644 -v "/tmp/i3config/$i" "$HOME/.config/i3/$i"
  37. done
  38. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying conky...' '\e[m'
  39. install -d -m755 "$HOME/.config/conky/"
  40. install -m644 -v /tmp/i3config/extra/conky.conf "$HOME/.config/conky/"
  41. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying bubblewrap scripts...' '\e[m'
  42. install -d -m755 "$HOME/.config/bwrap/"
  43. for i in /tmp/i3config/bwrap/*.bash; do
  44. install -m644 -v "$i" "$HOME/.config/bwrap/"
  45. done
  46. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Copying FontAwesome...' '\e[m'
  47. install -d -m755 "$HOME/.local/share/fonts/"
  48. for i in /tmp/i3config/fonts/*.ttf; do
  49. install -m644 -v "$i" "$HOME/.local/share/fonts/"
  50. done
  51. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Make log directory...' '\e[m'
  52. install -d -m755 "$HOME/.config/i3/logs/"
  53. # clean up temp files
  54. rm -rf /tmp/i3config/
  55. # update xdg-user-dirs
  56. printf '%b%s%b%s%b\n' '\e[1;32m' '==> ' '\e[0m\033[1m' 'Run xdg-user-dirs-update...' '\e[m'
  57. $(command -v xdg-user-dirs-update) && xdg-user-dirs-update
  58. }
  59. case ${LANG/_*/} in
  60. es)
  61. read -r -p "¿Estás seguro de instalar i3config? [S/n]: " input
  62. case $input in
  63. [sS]|"") _copy_i3_config "$@"; break ;;
  64. [nN]) break ;;
  65. *) echo "Por favor responde sí o no" ;;
  66. esac
  67. ;;
  68. *)
  69. read -r -p "Are you sure to install i3config? [Y/n]: " input
  70. case $input in
  71. [yY]|"") _copy_i3_config "$@"; break ;;
  72. [nN]) break ;;
  73. *) echo "Please answer yes or no.";;
  74. esac
  75. ;;
  76. esac
  77. done
  78. unset URL