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.

81 lines
1.7 KiB

  1. #!/usr/bin/env bash
  2. # Color files
  3. PFILE="$HOME/.config/polybar/material/colors.ini"
  4. RFILE="$HOME/.config/polybar/material/scripts/rofi/colors.rasi"
  5. # Get colors
  6. pywal_get() {
  7. wal -i "$1" -q -t
  8. }
  9. # Change colors
  10. change_color() {
  11. # polybar
  12. sed -i -e "s/background = #.*/background = $BG/g" $PFILE
  13. sed -i -e "s/foreground = #.*/foreground = $FG/g" $PFILE
  14. sed -i -e "s/foreground-alt = #.*/foreground-alt = $FGA/g" $PFILE
  15. sed -i -e "s/module-fg = #.*/module-fg = $MF/g" $PFILE
  16. sed -i -e "s/primary = #.*/primary = $AC/g" $PFILE
  17. sed -i -e "s/secondary = #.*/secondary = $SC/g" $PFILE
  18. sed -i -e "s/alternate = #.*/alternate = $AL/g" $PFILE
  19. # rofi
  20. cat > $RFILE <<- EOF
  21. /* colors */
  22. * {
  23. al: #00000000;
  24. bg: ${BG}FF;
  25. bga: ${AC}33;
  26. bar: ${MF}FF;
  27. fg: ${FG}FF;
  28. ac: ${AC}FF;
  29. }
  30. EOF
  31. }
  32. hex_to_rgb() {
  33. # Convert a hex value WITHOUT the hashtag (#)
  34. R=$(printf "%d" 0x${1:0:2})
  35. G=$(printf "%d" 0x${1:2:2})
  36. B=$(printf "%d" 0x${1:4:2})
  37. }
  38. get_fg_color(){
  39. INTENSITY=$(calc "$R*0.299 + $G*0.587 + $B*0.114")
  40. if [ $(echo "$INTENSITY>186" | bc) -eq 1 ]; then
  41. MF="#202020"
  42. else
  43. MF="#F5F5F5"
  44. fi
  45. }
  46. # Main
  47. if [[ -f "/usr/bin/wal" ]]; then
  48. if [[ "$1" ]]; then
  49. pywal_get "$1"
  50. # Source the pywal color file
  51. . "$HOME/.cache/wal/colors.sh"
  52. BG=`printf "%s\n" "$background"`
  53. FG=`printf "%s\n" "$foreground"`
  54. FGA=`printf "%s\n" "$color8"`
  55. AC=`printf "%s\n" "$color1"`
  56. SC=`printf "%s\n" "$color2"`
  57. AL=`printf "%s\n" "$color3"`
  58. HEX=${AC:1}
  59. hex_to_rgb $HEX
  60. get_fg_color
  61. change_color
  62. else
  63. echo -e "[!] Please enter the path to wallpaper. \n"
  64. echo "Usage : ./pywal.sh path/to/image"
  65. fi
  66. else
  67. echo "[!] 'pywal' is not installed."
  68. fi