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.

89 lines
1.6 KiB

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