Archlinux basic installation configuration scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
1.9 KiB

  1. #!/usr/bin/env bash
  2. # Color files
  3. PFILE="$HOME/.config/polybar/docky/colors.ini"
  4. RFILE="$HOME/.config/polybar/docky/scripts/rofi/colors.rasi"
  5. # Change colors
  6. change_color() {
  7. # polybar
  8. sed -i -e "s/background = #.*/background = $BG/g" $PFILE
  9. sed -i -e "s/foreground = #.*/foreground = $FG/g" $PFILE
  10. sed -i -e "s/foreground-alt = #.*/foreground-alt = $FGA/g" $PFILE
  11. sed -i -e "s/module-fg = #.*/module-fg = $MF/g" $PFILE
  12. sed -i -e "s/primary = #.*/primary = $AC/g" $PFILE
  13. sed -i -e "s/secondary = #.*/secondary = $SC/g" $PFILE
  14. sed -i -e "s/alternate = #.*/alternate = $AL/g" $PFILE
  15. # rofi
  16. cat > $RFILE <<- EOF
  17. /* colors */
  18. * {
  19. al: #00000000;
  20. bg: ${BG}FF;
  21. bga: ${AC}33;
  22. bar: ${MF}FF;
  23. fg: ${FG}FF;
  24. ac: ${AC}FF;
  25. }
  26. EOF
  27. polybar-msg cmd restart
  28. }
  29. get_random_number() {
  30. RNUM=$(( ($RANDOM % $1) + 1 ))
  31. }
  32. get_random_color() {
  33. RCOLOR="#"
  34. for i in 1 2 3 4 5 6
  35. do
  36. get_random_number "16"
  37. case $RNUM in
  38. "1") NEXTDIGIT="1";;
  39. "2") NEXTDIGIT="2";;
  40. "3") NEXTDIGIT="3";;
  41. "4") NEXTDIGIT="4";;
  42. "5") NEXTDIGIT="5";;
  43. "6") NEXTDIGIT="6";;
  44. "7") NEXTDIGIT="7";;
  45. "8") NEXTDIGIT="8";;
  46. "9") NEXTDIGIT="9";;
  47. "10") NEXTDIGIT="A";;
  48. "11") NEXTDIGIT="B";;
  49. "12") NEXTDIGIT="C";;
  50. "13") NEXTDIGIT="D";;
  51. "14") NEXTDIGIT="E";;
  52. "15") NEXTDIGIT="F";;
  53. "16") NEXTDIGIT="0";;
  54. esac
  55. RCOLOR="$RCOLOR$NEXTDIGIT"
  56. done
  57. echo $RCOLOR
  58. }
  59. hex_to_rgb() {
  60. # Convert a hex value WITHOUT the hashtag (#)
  61. R=$(printf "%d" 0x${1:0:2})
  62. G=$(printf "%d" 0x${1:2:2})
  63. B=$(printf "%d" 0x${1:4:2})
  64. }
  65. get_fg_color(){
  66. INTENSITY=$(calc "$R*0.299 + $G*0.587 + $B*0.114")
  67. if [ $(echo "$INTENSITY>186" | bc) -eq 1 ]; then
  68. MF="#0a0a0a"
  69. else
  70. MF="#F5F5F5"
  71. fi
  72. }
  73. # Main
  74. BG='#1F1F1F' # change to light bg
  75. FG='#FFFFFF' # change to dark fg
  76. FGA=`get_random_color`
  77. AC=`get_random_color`
  78. SC=`get_random_color`
  79. AL=`get_random_color`
  80. HEX=${AC:1}
  81. hex_to_rgb $HEX
  82. get_fg_color
  83. change_color