[raw] [dotfiles.tar.gz]
   1 #!/bin/bash
   2 
   3 if [[ -f $1 ]]; then
   4     cp "$1" ~/.config/wallpaper.jpg 2>&-
   5 
   6     hsetroot -fill $_
   7     gsettings set org.cinnamon.desktop.background picture-uri "file://$_"
   8     exit
   9 fi
  10 
  11 ################################################################################
  12 
  13 mkdir -p ~/.cache/wall; cd $_
  14 source ~/.config/wall/colors.sh
  15 declare -n colors=colors_default
  16 
  17 if [[ $1 == -c ]]; then
  18     [[   $2 ]] && declare -n colors=colors_$2
  19     [[ ! $2 || ! ${colors[@]} ]] &&
  20     set | grep -o "^colors_$2\w*" | cut -b 8- && exit
  21 elif [[ -f colors.sh ]]; then
  22     source colors.sh
  23 fi
  24 
  25 ################################################################################
  26 
  27 colors[cursor]=${colors[foreground]}
  28 keys=$(echo {back,fore}ground{,_rgba,_argb} cursor color{0..15}{,_rgba,_argb})
  29 
  30 for i in {back,fore}ground color{0..15}; do
  31     colors[${i}_rgba]="${colors[$i]}e0"
  32     colors[${i}_argb]="#e0${colors[$i]:1}"
  33 done
  34 
  35 sed=$(for i in $keys; do echo "s/{$i}/${colors[$i]}/g"; done)
  36 for f in ~/.config/wall/*; do [[ -f $f ]] && sed "$sed" $f > ${f##*/}; done
  37 
  38 for i in $keys; do echo "*$i: ${colors[$i]}"; done > colors.xres
  39 set | grep "^${!colors}=" | sed "s/^${!colors}/declare -A colors/" > colors.sh
  40 
  41 for i in {0..15}; do printf '\e]4;%d;%s\a' $i ${colors[color$i]}; done > colors
  42 for i in {0..15}; do printf '\e]P%x%s\a' $i ${colors[color$i]:1}; done > colors-tty
  43 
  44 printf '\e]10;%s\a\e]11;%s\a\e]12;%s\a' \
  45 ${colors[foreground]} ${colors[background]} ${colors[cursor]} >> colors
  46 printf '\e]4;256;%s\a' ${colors[foreground]} >> colors
  47 
  48 ################################################################################
  49 
  50 exec 2>&-
  51 
  52 cat *.xres | xrdb -merge
  53 $0 ~/.config/wallpaper.jpg
  54 
  55 for i in /dev/pts/[0-9]; do
  56     cat colors > $i
  57 done
  58 
  59 i3-msg restart
  60 pkill -HUP dwm
  61 pkill -HUP awesome
  62 
  63 sleep 0.1
  64 
  65 imwheel -k
  66 pkill -USR1 sxhkd
  67 
  68 pkill dunst
  69 pkill -USR1 polybar