*nohtml*

local/bin/wall

   1 #!/bin/bash
   2 
   3 declare -A base16_ashes=( # {{{
   4     [background]='#1c2023' [foreground]='#c7ccd1'
   5     [color0]='#1c2023' [color8]='#747c84'
   6     [color1]='#c7ae95' [color9]='#c7ae95'
   7     [color2]='#95c7ae' [color10]='#95c7ae'
   8     [color3]='#aec795' [color11]='#aec795'
   9     [color4]='#ae95c7' [color12]='#ae95c7'
  10     [color5]='#c795ae' [color13]='#c795ae'
  11     [color6]='#95aec7' [color14]='#95aec7'
  12     [color7]='#c7ccd1' [color15]='#f3f4f5'
  13 ) # }}}
  14 declare -A base16_dracula=( # {{{
  15     [background]='#282936' [foreground]='#e9e9f4'
  16     [color0]='#282936' [color8]='#4d4f68'
  17     [color1]='#ea51b2' [color9]='#ea51b2'
  18     [color2]='#00f769' [color10]='#00f769'
  19     [color3]='#ebff87' [color11]='#ebff87'
  20     [color4]='#62d6e8' [color12]='#62d6e8'
  21     [color5]='#b45bcf' [color13]='#b45bcf'
  22     [color6]='#a1efe4' [color14]='#a1efe4'
  23     [color7]='#e9e9f4' [color15]='#f7f7fb'
  24 ) # }}}
  25 declare -A base16_flat=( # {{{
  26     [background]='#2c3e50' [foreground]='#e0e0e0'
  27     [color0]='#2c3e50' [color8]='#95a5a6'
  28     [color1]='#e74c3c' [color9]='#e74c3c'
  29     [color2]='#2ecc71' [color10]='#2ecc71'
  30     [color3]='#f1c40f' [color11]='#f1c40f'
  31     [color4]='#3498db' [color12]='#3498db'
  32     [color5]='#9b59b6' [color13]='#9b59b6'
  33     [color6]='#1abc9c' [color14]='#1abc9c'
  34     [color7]='#e0e0e0' [color15]='#ecf0f1'
  35 ) # }}}
  36 declare -A base16_gruvbox_medium=( # {{{
  37     [background]='#282828' [foreground]='#d5c4a1'
  38     [color0]='#282828' [color8]='#665c54'
  39     [color1]='#fb4934' [color9]='#fb4934'
  40     [color2]='#b8bb26' [color10]='#b8bb26'
  41     [color3]='#fabd2f' [color11]='#fabd2f'
  42     [color4]='#83a598' [color12]='#83a598'
  43     [color5]='#d3869b' [color13]='#d3869b'
  44     [color6]='#8ec07c' [color14]='#8ec07c'
  45     [color7]='#d5c4a1' [color15]='#fbf1c7'
  46 ) # }}}
  47 declare -A base16_gruvbox_soft=( # {{{
  48     [background]='#32302f' [foreground]='#d5c4a1'
  49     [color0]='#32302f' [color8]='#665c54'
  50     [color1]='#fb4934' [color9]='#fb4934'
  51     [color2]='#b8bb26' [color10]='#b8bb26'
  52     [color3]='#fabd2f' [color11]='#fabd2f'
  53     [color4]='#83a598' [color12]='#83a598'
  54     [color5]='#d3869b' [color13]='#d3869b'
  55     [color6]='#8ec07c' [color14]='#8ec07c'
  56     [color7]='#d5c4a1' [color15]='#fbf1c7'
  57 ) # }}}
  58 declare -A base16_material=( # {{{
  59     [background]='#263238' [foreground]='#eeffff'
  60     [color0]='#263238' [color8]='#546e7a'
  61     [color1]='#f07178' [color9]='#f07178'
  62     [color2]='#c3e88d' [color10]='#c3e88d'
  63     [color3]='#ffcb6b' [color11]='#ffcb6b'
  64     [color4]='#82aaff' [color12]='#82aaff'
  65     [color5]='#c792ea' [color13]='#c792ea'
  66     [color6]='#89ddff' [color14]='#89ddff'
  67     [color7]='#eeffff' [color15]='#eeffff' # [color15]='#ffffff'
  68 ) # }}}
  69 declare -A base16_material_palenight=( # {{{
  70     [background]='#292d3e' [foreground]='#959dcb'
  71     [color0]='#292d3e' [color8]='#676e95'
  72     [color1]='#f07178' [color9]='#f07178'
  73     [color2]='#c3e88d' [color10]='#c3e88d'
  74     [color3]='#ffcb6b' [color11]='#ffcb6b'
  75     [color4]='#82aaff' [color12]='#82aaff'
  76     [color5]='#c792ea' [color13]='#c792ea'
  77     [color6]='#89ddff' [color14]='#89ddff'
  78     [color7]='#959dcb' [color15]='#ffffff'
  79 ) # }}}
  80 declare -A base16_nord=( # {{{
  81     [background]='#2e3440' [foreground]='#e5e9f0'
  82     [color0]='#2e3440' [color8]='#4c566a'
  83     [color1]='#88c0d0' [color9]='#88c0d0'
  84     [color2]='#bf616a' [color10]='#bf616a'
  85     [color3]='#5e81ac' [color11]='#5e81ac'
  86     [color4]='#ebcb8b' [color12]='#ebcb8b'
  87     [color5]='#a3be8c' [color13]='#a3be8c'
  88     [color6]='#d08770' [color14]='#d08770'
  89     [color7]='#e5e9f0' [color15]='#8fbcbb'
  90 ) # }}}
  91 declare -A base16_ocean=( # {{{
  92     [background]='#2b303b' [foreground]='#c0c5ce'
  93     [color0]='#2b303b' [color8]='#65737e'
  94     [color1]='#bf616a' [color9]='#bf616a'
  95     [color2]='#a3be8c' [color10]='#a3be8c'
  96     [color3]='#ebcb8b' [color11]='#ebcb8b'
  97     [color4]='#8fa1b3' [color12]='#8fa1b3'
  98     [color5]='#b48ead' [color13]='#b48ead'
  99     [color6]='#96b5b4' [color14]='#96b5b4'
 100     [color7]='#c0c5ce' [color15]='#eff1f5'
 101 ) # }}}
 102 declare -A base16_oceanicnext=( # {{{
 103     [background]='#1b2b34' [foreground]='#c0c5ce'
 104     [color0]='#1b2b34'  [color8]='#65737e'
 105     [color1]='#ec5f67'  [color9]='#ec5f67'
 106     [color2]='#99c794' [color10]='#99c794'
 107     [color3]='#fac863' [color11]='#fac863'
 108     [color4]='#6699cc' [color12]='#6699cc'
 109     [color5]='#c594c5' [color13]='#c594c5'
 110     [color6]='#5fb3b3' [color14]='#5fb3b3'
 111     [color7]='#c0c5ce' [color15]='#d8dee9'
 112 ) # }}}
 113 declare -A base16_porple=( # {{{
 114     [background]='#292c36' [foreground]='#d8d8d8'
 115     [color0]='#292c36' [color8]='#65568a'
 116     [color1]='#f84547' [color9]='#f84547'
 117     [color2]='#95c76f' [color10]='#95c76f'
 118     [color3]='#efa16b' [color11]='#efa16b'
 119     [color4]='#8485ce' [color12]='#8485ce'
 120     [color5]='#b74989' [color13]='#b74989'
 121     [color6]='#64878f' [color14]='#64878f'
 122     [color7]='#d8d8d8' [color15]='#f8f8f8'
 123 ) # }}}
 124 declare -A base16_tomorrow_night=( # {{{
 125     [background]='#1d1f21' [foreground]='#c5c8c6'
 126     [color0]='#1d1f21' [color8]='#969896'
 127     [color1]='#cc6666' [color9]='#cc6666'
 128     [color2]='#b5bd68' [color10]='#b5bd68'
 129     [color3]='#f0c674' [color11]='#f0c674'
 130     [color4]='#81a2be' [color12]='#81a2be'
 131     [color5]='#b294bb' [color13]='#b294bb'
 132     [color6]='#8abeb7' [color14]='#8abeb7'
 133     [color7]='#c5c8c6' [color15]='#ffffff'
 134 ) # }}}
 135 declare -A default=( # {{{
 136     [background]='#222228' [foreground]='#d8dade'
 137     [color0]='#222228'  [color8]='#4e4e56' # [color0]='#37373f'
 138     [color1]='#ff5f5f'  [color9]='#ff5f5f'
 139     [color2]='#87af5f' [color10]='#87af5f'
 140     [color3]='#d7af87' [color11]='#ffd75f'
 141     [color4]='#5f5fff' [color12]='#afafd7'
 142     [color5]='#d75fff' [color13]='#d75fff'
 143     [color6]='#87d7d7' [color14]='#87d7d6'
 144     [color7]='#a8aaae' [color15]='#d8dade'
 145 ) # }}}
 146 declare -A dkeg_prevail=( # {{{
 147     [background]='#263139' [foreground]='#dac99d'
 148     [color0]='#263139' [color8]='#455867'
 149     [color1]='#f36f62' [color9]='#f36f62'
 150     [color2]='#c5e19c' [color10]='#c5e19c'
 151     [color3]='#ccb478' [color11]='#ccb478'
 152     [color4]='#4c7e89' [color12]='#4c7e89'
 153     [color5]='#814d61' [color13]='#814d61'
 154     [color6]='#79a69d' [color14]='#79a69d'
 155     [color7]='#c4c4b5' [color15]='#dbdbd1'
 156 ) # }}}
 157 declare -A hybrid_material=( # {{{
 158     [background]='#263238' [foreground]='#ffffff'
 159     [color0]='#263238' [color8]='#707880'
 160     [color1]='#cc6666' [color9]='#cc6666'
 161     [color2]='#f0c674' [color10]='#f0c674'
 162     [color3]='#b5bd68' [color11]='#b5bd68'
 163     [color4]='#8abeb7' [color12]='#8abeb7'
 164     [color5]='#81a2be' [color13]='#81a2be'
 165     [color6]='#b294bb' [color14]='#b294bb'
 166     [color7]='#ffffff' [color15]='#ffffff'
 167 ) # }}}
 168 declare -A monokai=( # {{{
 169     [background]='#272822' [foreground]='#f8f8f2'
 170     [color0]='#272822' [color8]='#75715e'
 171     [color1]='#f92672' [color9]='#f92672'
 172     [color2]='#a6e22e' [color10]='#a6e22e'
 173     [color3]='#f4bf75' [color11]='#f4bf75'
 174     [color4]='#66d9ef' [color12]='#66d9ef'
 175     [color5]='#ae81ff' [color13]='#ae81ff'
 176     [color6]='#a1efe4' [color14]='#a1efe4'
 177     [color7]='#f8f8f2' [color15]='#f9f8f5'
 178 ) # }}}
 179 declare -A solarized=( # {{{
 180     [background]='#073642' [foreground]='#fdf6e3'
 181     [color0]='#073642' [color8]='#6c7c80'
 182     [color1]='#dc322f' [color9]='#dc322f'
 183     [color2]='#859900' [color10]='#859900'
 184     [color3]='#b58900' [color11]='#b58900'
 185     [color4]='#268bd2' [color12]='#268bd2'
 186     [color5]='#d33682' [color13]='#d33682'
 187     [color6]='#2aa198' [color14]='#2aa198'
 188     [color7]='#eee8d5' [color15]='#eee8d5'
 189 ) # }}}
 190 declare -A zenburn3=( # {{{
 191     [background]='#3f3f3f' [foreground]='#ffffff'
 192     [color0]='#3f3f3f' [color8]='#828282'
 193     [color1]='#dca5a5' [color9]='#dca5a5'
 194     [color2]='#c0e380' [color10]='#c0e380'
 195     [color3]='#e4e49a' [color11]='#e4e49a'
 196     [color4]='#7d9ec0' [color12]='#7d9ec0'
 197     [color5]='#ffc66d' [color13]='#ffc66d'
 198     [color6]='#8acccf' [color14]='#8acccf'
 199     [color7]='#ffffff' [color15]='#ffffff'
 200 ) # }}}
 201 
 202 [[ -f ~/.config/wall/colors.sh ]] &&
 203 source ~/.config/wall/colors.sh
 204 
 205 return 2>&-
 206 
 207 ################################################################################
 208 
 209 declare -n colors=default
 210 source ~/.config/colors/colors.sh 2>&- &&
 211 for i in {back,fore}ground color{0..15}; do colors[$i]=${!i}; done
 212 
 213 case $1 in
 214     -b|--background)
 215         cp "$2" ~/.config/wallpaper.jpg 2>&-
 216         hsetroot -solid ${colors[background]} -cover $_ > /dev/null 2>&1
 217 
 218         qdbus --system org.freedesktop.Accounts /org/freedesktop/Accounts/User$UID \
 219         org.freedesktop.DisplayManager.AccountsService.BackgroundFile $_ 2>&-
 220 
 221         exit
 222     ;;
 223 
 224     -c|--color)
 225         source $0; reload=1; declare -n colors=$2 2>&-
 226         list(){ source $0; local | grep -io "^\w*$1\w*"; }
 227         [[ ! $2 || ! ${colors[@]} ]] && { list "$2"; exit; }
 228     ;;
 229 
 230     -r|--reload) reload=1;;
 231 esac
 232 
 233 mkdir -p ~/.config/colors; cd $_
 234 
 235 ################################################################################
 236 
 237 print(){ # {{{
 238     printf "${2:-%s}\n" "$(for i in ${!colors[@]}; do printf "$1\n" $i "${colors[$i]}"; done)"
 239 } # }}}
 240 rgba(){ # {{{
 241     printf 'rgba(%d, %d, %d, 0.%d)' 0x${1:1:2} 0x${1:3:2} 0x${1:5:2} $(( 0x${1:7:2} * 1000 / 255 ))
 242 } # }}}
 243 
 244 [[ ${colors[foreground]} < ${colors[color7]}  ]] && colors[foreground]=${colors[color7]}
 245 [[ ${colors[foreground]} < ${colors[color15]} ]] && colors[foreground]=${colors[color15]}
 246 
 247 colors[background_rgba]=${colors[background]}e0
 248 colors[background_argb]=${colors[background]/\#/\#e0}
 249 
 250 > colors.xres print '*%s: %s'
 251 > colors.lua  print '%s = "%s";'
 252 > colors.sh   print 'export %s="%s"'
 253 > colors.h    print 'char %s[] = "%s";'
 254 > colors.ini  print '%s = %s' '[colors]\n%s'
 255 
 256 colors[background-rgba]=$(rgba ${colors[background_rgba]})
 257 unset colors[background_rgba] colors[background_argb]
 258 
 259 > colors.gtk  print '@define-color %s %s;'
 260 > colors.rasi print '  %s: %s;' '* {\n%s\n}'
 261 > colors.css  print '  --%s: %s;' ':root {\n%s\n}'
 262 
 263 > colors-xterm printf '\e]%s;%s\a' \
 264 10 ${colors[foreground]}      11 ${colors[background]} \
 265 12 ${colors[foreground]} '4;256' ${colors[foreground]} \
 266 $(for i in {0..15}; do echo "4;$i" ${colors[color$i]}; done)
 267 
 268 colors[color7]=${colors[foreground]}
 269 > colors-linux printf '\e]P%x%s\a' $(for i in {0..7}; do echo $i ${colors[color$i]:1}; done)
 270 
 271 ################################################################################
 272 
 273 printf '\e[1;30m'
 274 trap 'printf "\e[0m"; colors' EXIT
 275 
 276 xrdb -merge colors.xres
 277 $0 -b ../wallpaper.jpg &
 278 
 279 source colors.sh
 280 find ~/.config ~/.local -name \*.wall |
 281 while read f; do envsubst < $f > ${f%.wall}; done
 282 
 283 [[ $reload ]] || exit
 284 
 285 i3 restart
 286 killall dunst
 287 
 288 killall -HUP  dwm awesome xfwm4
 289 killall -USR1 openbox; sleep 0.2
 290 killall -USR1 sxhkd compton picom polybar xfce4-panel
 291 
 292 for i in /dev/pts/[0-9]; do cat colors-xterm > $i; done
 293 for i in /dev/tty[0-9];  do cat colors-linux > $i; done 2>&-
 294 
 295 $0 -b ../wallpaper.jpg &