[download]

local/bin/theme

   1 #!/bin/bash
   2 
   3 declare -A ashes_base16=( # {{{
   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 blossom=( # {{{
  15     [background]='#2f3846' [foreground]='#ffffff' # [foreground]='#dfdff2'
  16         [color0]='#3e4755'     [color8]='#5d6473'
  17         [color1]='#e28479'     [color9]='#ec8e83'
  18         [color2]='#70b791'    [color10]='#7ac19b'
  19         [color3]='#c9c76b'    [color11]='#d3d175'
  20         [color4]='#839aec'    [color12]='#8da4f6'
  21         [color5]='#d18493'    [color13]='#db8e9d'
  22         [color6]='#78b3c5'    [color14]='#82bdcf'
  23         [color7]='#d2d2d4'    [color15]='#d1d1d3'
  24 ) # }}}
  25 declare -A ci_dark=( # {{{
  26     [background]='#24292e' [foreground]='#f6f8fa'
  27         [color0]='#24292e'     [color8]='#3a3f43'
  28         [color1]='#f97583'     [color9]='#f97583'
  29         [color2]='#85e89d'    [color10]='#85e89d'
  30         [color3]='#ffea7f'    [color11]='#ffea7f'
  31         [color4]='#79b8ff'    [color12]='#79b8ff'
  32         [color5]='#b392f0'    [color13]='#b392f0'
  33         [color6]='#73e3ff'    [color14]='#73e3ff'
  34         [color7]='#959da5'    [color15]='#f6f8fa'
  35 ) # }}}
  36 declare -A default=( # {{{
  37     [background]='#222228' [foreground]='#d8dade'
  38         [color0]='#222228'     [color8]='#4e4e56' # [color8]='#37373f'
  39         [color1]='#ff5f5f'     [color9]='#ff5f5f'
  40         [color2]='#87af5f'    [color10]='#87af5f'
  41         [color3]='#d7af87'    [color11]='#d7af87' # [color11]='#ffd75f'
  42         [color4]='#5f5fff'    [color12]='#afafd7'
  43         [color5]='#d75fff'    [color13]='#d75fff'
  44         [color6]='#87d7d7'    [color14]='#87d7d6'
  45         [color7]='#a8aaae'    [color15]='#d8dade'
  46 ) # }}}
  47 declare -A default_base16=( # {{{
  48     [background]='#181818' [foreground]='#d8d8d8'
  49         [color0]='#181818'     [color8]='#585858'
  50         [color1]='#ab4642'     [color9]='#ab4642'
  51         [color2]='#a1b56c'    [color10]='#a1b56c'
  52         [color3]='#f7ca88'    [color11]='#f7ca88'
  53         [color4]='#7cafc2'    [color12]='#7cafc2'
  54         [color5]='#ba8baf'    [color13]='#ba8baf'
  55         [color6]='#86c1b9'    [color14]='#86c1b9'
  56         [color7]='#d8d8d8'    [color15]='#f8f8f8'
  57 ) # }}}
  58 declare -A dkeg_bluetype=( # {{{
  59     [background]='#272a2a' [foreground]='#80807e'
  60     [color0]='#272a2a'         [color8]='#484c4e'
  61     [color1]='#b05f5f'         [color9]='#b05f5f'
  62     [color2]='#b05f5f'        [color10]='#b05f5f'
  63     [color3]='#88aa55'        [color11]='#88aa55'
  64     [color4]='#88aa55'        [color12]='#88aa55'
  65     [color5]='#ccb05f'        [color13]='#ccb05f'
  66     [color6]='#ccb05f'        [color14]='#ccb05f'
  67     [color7]='#f6f7f8'        [color15]='#f6f7f8' # [color7]='#556973'
  68 ) # }}}
  69 declare -A dkeg_prevail=( # {{{
  70     [background]='#263139' [foreground]='#ffffff' # [foreground]='#dac99d'
  71         [color0]='#263139'     [color8]='#455867'
  72         [color1]='#f36f62'     [color9]='#f36f62'
  73         [color2]='#c5e19c'    [color10]='#c5e19c'
  74         [color3]='#ccb478'    [color11]='#ccb478'
  75         [color4]='#4c7e89'    [color12]='#4c7e89'
  76         [color5]='#814d61'    [color13]='#814d61'
  77         [color6]='#79a69d'    [color14]='#79a69d'
  78         [color7]='#c4c4b5'    [color15]='#dbdbd1'
  79 ) # }}}
  80 declare -A dkeg_simplicity=( # {{{
  81     [background]='#28282c' [foreground]='#a18673'
  82         [color0]='#28282c'     [color8]='#404047'
  83         [color1]='#bf5c56'     [color9]='#bf5c56'
  84         [color2]='#bf5c56'    [color10]='#bf5c56'
  85         [color3]='#97b19c'    [color11]='#97b19c'
  86         [color4]='#97b19c'    [color12]='#97b19c'
  87         [color5]='#d7bd8a'    [color13]='#d7bd8a'
  88         [color6]='#d7bd8a'    [color14]='#d7bd8a'
  89         [color7]='#f4f4f2'    [color15]='#f4f4f2' # [color7]='#545f72'
  90 ) # }}}
  91 declare -A dracula=( # {{{
  92     [background]='#282a36' [foreground]='#f8f8f2'
  93         [color0]='#000000'     [color8]='#4d4d4d'
  94         [color1]='#ff5555'     [color9]='#ff6e67'
  95         [color2]='#50fa7b'    [color10]='#5af78e'
  96         [color3]='#f1fa8c'    [color11]='#f4f99d'
  97         [color4]='#bd93f9'    [color12]='#caa9fa'
  98         [color5]='#ff79c6'    [color13]='#ff92d0'
  99         [color6]='#8be9fd'    [color14]='#9aedfe'
 100         [color7]='#bfbfbf'    [color15]='#e6e6e6'
 101 ) # }}}
 102 declare -A dracula_base16=( # {{{
 103     [background]='#282936' [foreground]='#e9e9f4'
 104         [color0]='#282936'     [color8]='#4d4f68'
 105         [color1]='#ea51b2'     [color9]='#ea51b2'
 106         [color2]='#00f769'    [color10]='#00f769'
 107         [color3]='#ebff87'    [color11]='#ebff87'
 108         [color4]='#62d6e8'    [color12]='#62d6e8'
 109         [color5]='#b45bcf'    [color13]='#b45bcf'
 110         [color6]='#a1efe4'    [color14]='#a1efe4'
 111         [color7]='#e9e9f4'    [color15]='#f7f7fb'
 112 ) # }}}
 113 declare -A eighties_base16=( # {{{
 114     [background]='#2d2d2d' [foreground]='#d3d0c8'
 115         [color0]='#2d2d2d'     [color8]='#747369'
 116         [color1]='#f2777a'     [color9]='#f2777a'
 117         [color2]='#99cc99'    [color10]='#99cc99'
 118         [color3]='#ffcc66'    [color11]='#ffcc66'
 119         [color4]='#6699cc'    [color12]='#6699cc'
 120         [color5]='#cc99cc'    [color13]='#cc99cc'
 121         [color6]='#66cccc'    [color14]='#66cccc'
 122         [color7]='#d3d0c8'    [color15]='#f2f0ec'
 123 ) # }}}
 124 declare -A flat_base16=( # {{{
 125     [background]='#2c3e50' [foreground]='#e0e0e0'
 126         [color0]='#2c3e50'     [color8]='#95a5a6'
 127         [color1]='#e74c3c'     [color9]='#e74c3c'
 128         [color2]='#2ecc71'    [color10]='#2ecc71'
 129         [color3]='#f1c40f'    [color11]='#f1c40f'
 130         [color4]='#3498db'    [color12]='#3498db'
 131         [color5]='#9b59b6'    [color13]='#9b59b6'
 132         [color6]='#1abc9c'    [color14]='#1abc9c'
 133         [color7]='#e0e0e0'    [color15]='#ecf0f1'
 134 ) # }}}
 135 declare -A gruvbox_hard_base16=( # {{{
 136     [background]='#1d2021' [foreground]='#d5c4a1'
 137         [color0]='#1d2021'     [color8]='#665c54'
 138         [color1]='#fb4934'     [color9]='#fb4934'
 139         [color2]='#b8bb26'    [color10]='#b8bb26'
 140         [color3]='#fabd2f'    [color11]='#fabd2f'
 141         [color4]='#83a598'    [color12]='#83a598'
 142         [color5]='#d3869b'    [color13]='#d3869b'
 143         [color6]='#8ec07c'    [color14]='#8ec07c'
 144         [color7]='#d5c4a1'    [color15]='#fbf1c7'
 145 ) # }}}
 146 declare -A gruvbox_medium_base16=( # {{{
 147     [background]='#282828' [foreground]='#d5c4a1'
 148         [color0]='#282828'     [color8]='#665c54'
 149         [color1]='#fb4934'     [color9]='#fb4934'
 150         [color2]='#b8bb26'    [color10]='#b8bb26'
 151         [color3]='#fabd2f'    [color11]='#fabd2f'
 152         [color4]='#83a598'    [color12]='#83a598'
 153         [color5]='#d3869b'    [color13]='#d3869b'
 154         [color6]='#8ec07c'    [color14]='#8ec07c'
 155         [color7]='#d5c4a1'    [color15]='#fbf1c7'
 156 ) # }}}
 157 declare -A gruvbox_pale_base16=( # {{{
 158     [background]='#262626' [foreground]='#dab997'
 159         [color0]='#262626'     [color8]='#8a8a8a'
 160         [color1]='#d75f5f'     [color9]='#d75f5f'
 161         [color2]='#afaf00'    [color10]='#afaf00'
 162         [color3]='#ffaf00'    [color11]='#ffaf00'
 163         [color4]='#83adad'    [color12]='#83adad'
 164         [color5]='#d485ad'    [color13]='#d485ad'
 165         [color6]='#85ad85'    [color14]='#85ad85'
 166         [color7]='#dab997'    [color15]='#ebdbb2'
 167 ) # }}}
 168 declare -A gruvbox_soft_base16=( # {{{
 169     [background]='#32302f' [foreground]='#d5c4a1'
 170         [color0]='#32302f'     [color8]='#665c54'
 171         [color1]='#fb4934'     [color9]='#fb4934'
 172         [color2]='#b8bb26'    [color10]='#b8bb26'
 173         [color3]='#fabd2f'    [color11]='#fabd2f'
 174         [color4]='#83a598'    [color12]='#83a598'
 175         [color5]='#d3869b'    [color13]='#d3869b'
 176         [color6]='#8ec07c'    [color14]='#8ec07c'
 177         [color7]='#d5c4a1'    [color15]='#fbf1c7'
 178 ) # }}}
 179 declare -A hybrid=( # {{{
 180     [background]='#1d1f21' [foreground]='#eeeeee' # [foreground]='#c5c8c6'
 181         [color0]='#282a2e'     [color8]='#373b41'
 182         [color1]='#cc6666'     [color9]='#cc6666'
 183         [color2]='#b5bd68'    [color10]='#b5bd68'
 184         [color3]='#f0c674'    [color11]='#f0c674'
 185         [color4]='#81a2be'    [color12]='#81a2be'
 186         [color5]='#b294bb'    [color13]='#b294bb'
 187         [color6]='#8abeb7'    [color14]='#8abeb7'
 188         [color7]='#c5c8c6'    [color15]='#c5c8c6'
 189 ) # }}}
 190 declare -A hybrid_material=( # {{{
 191     [background]='#263238' [foreground]='#ffffff'
 192         [color0]='#263238'     [color8]='#707880'
 193         [color1]='#cc6666'     [color9]='#cc6666'
 194         [color2]='#f0c674'    [color10]='#f0c674'
 195         [color3]='#b5bd68'    [color11]='#b5bd68'
 196         [color4]='#8abeb7'    [color12]='#8abeb7'
 197         [color5]='#81a2be'    [color13]='#81a2be'
 198         [color6]='#b294bb'    [color14]='#b294bb'
 199         [color7]='#ffffff'    [color15]='#ffffff'
 200 ) # }}}
 201 declare -A materia_base16=( # {{{
 202     [background]='#263238' [foreground]='#cdd3de'
 203         [color0]='#263238'     [color8]='#707880'
 204         [color1]='#ec5f67'     [color9]='#ec5f67'
 205         [color2]='#8bd649'    [color10]='#8bd649'
 206         [color3]='#ffcc00'    [color11]='#ffcc00'
 207         [color4]='#89ddff'    [color12]='#89ddff'
 208         [color5]='#82aaff'    [color13]='#82aaff'
 209         [color6]='#80cbc4'    [color14]='#80cbc4'
 210         [color7]='#cdd3de'    [color15]='#ffffff'
 211 ) # }}}
 212 declare -A material_base16=( # {{{
 213     [background]='#263238' [foreground]='#eeffff'
 214         [color0]='#263238'     [color8]='#546e7a'
 215         [color1]='#f07178'     [color9]='#f07178'
 216         [color2]='#c3e88d'    [color10]='#c3e88d'
 217         [color3]='#ffcb6b'    [color11]='#ffcb6b'
 218         [color4]='#82aaff'    [color12]='#82aaff'
 219         [color5]='#c792ea'    [color13]='#c792ea'
 220         [color6]='#89ddff'    [color14]='#89ddff'
 221         [color7]='#eeffff'    [color15]='#ffffff'
 222 ) # }}}
 223 declare -A material_palenight_base16=( # {{{
 224     [background]='#292d3e' [foreground]='#959dcb'
 225         [color0]='#292d3e'     [color8]='#676e95'
 226         [color1]='#f07178'     [color9]='#f07178'
 227         [color2]='#c3e88d'    [color10]='#c3e88d'
 228         [color3]='#ffcb6b'    [color11]='#ffcb6b'
 229         [color4]='#82aaff'    [color12]='#82aaff'
 230         [color5]='#c792ea'    [color13]='#c792ea'
 231         [color6]='#89ddff'    [color14]='#89ddff'
 232         [color7]='#959dcb'    [color15]='#ffffff'
 233 ) # }}}
 234 declare -A materialer_base16=( # {{{
 235     [background]='#212121' [foreground]='#eeffff'
 236         [color0]='#212121'     [color8]='#4a4a4a'
 237         [color1]='#f07178'     [color9]='#f07178'
 238         [color2]='#c3e88d'    [color10]='#c3e88d'
 239         [color3]='#ffcb6b'    [color11]='#ffcb6b'
 240         [color4]='#82aaff'    [color12]='#82aaff'
 241         [color5]='#c792ea'    [color13]='#c792ea'
 242         [color6]='#89ddff'    [color14]='#89ddff'
 243         [color7]='#eeffff'    [color15]='#ffffff'
 244 ) # }}}
 245 declare -A mocha_base16=( # {{{
 246     [background]='#3b3228' [foreground]='#d0c8c6'
 247         [color0]='#3b3228'     [color8]='#7e705a'
 248         [color1]='#cb6077'     [color9]='#cb6077'
 249         [color2]='#beb55b'    [color10]='#beb55b'
 250         [color3]='#f4bc87'    [color11]='#f4bc87'
 251         [color4]='#8ab3b5'    [color12]='#8ab3b5'
 252         [color5]='#a89bb9'    [color13]='#a89bb9'
 253         [color6]='#7bbda4'    [color14]='#7bbda4'
 254         [color7]='#d0c8c6'    [color15]='#f5eeeb'
 255 ) # }}}
 256 declare -A monokai=( # {{{
 257     [background]='#272822' [foreground]='#f8f8f2'
 258         [color0]='#272822'     [color8]='#75715e'
 259         [color1]='#f92672'     [color9]='#f92672'
 260         [color2]='#a6e22e'    [color10]='#a6e22e'
 261         [color3]='#f4bf75'    [color11]='#f4bf75'
 262         [color4]='#66d9ef'    [color12]='#66d9ef'
 263         [color5]='#ae81ff'    [color13]='#ae81ff'
 264         [color6]='#a1efe4'    [color14]='#a1efe4'
 265         [color7]='#f8f8f2'    [color15]='#f8f8f2'
 266 ) # }}}
 267 declare -A muzieca_lowcontrast=( # {{{
 268     [background]='#3c3b37' [foreground]='#93a1a1'
 269         [color0]='#5f5f5f'     [color8]='#828282'
 270         [color1]='#d96468'     [color9]='#d98f93'
 271         [color2]='#b8d98f'    [color10]='#b8d98f'
 272         [color3]='#d9cf8f'    [color11]='#d9cf8f'
 273         [color4]='#8f99d9'    [color12]='#8f99d9'
 274         [color5]='#b08fd9'    [color13]='#b08fd9'
 275         [color6]='#8fd9d5'    [color14]='#8fd9d5'
 276         [color7]='#c5c5c5'    [color15]='#ffffff'
 277 ) # }}}
 278 declare -A nord=( # {{{
 279     [background]='#2e3440' [foreground]='#d8dee9'
 280         [color0]='#3b4252'     [color8]='#4c566a'
 281         [color1]='#bf616a'     [color9]='#bf616a'
 282         [color2]='#a3be8c'    [color10]='#a3be8c'
 283         [color3]='#ebcb8b'    [color11]='#ebcb8b'
 284         [color4]='#81a1c1'    [color12]='#81a1c1'
 285         [color5]='#b48ead'    [color13]='#b48ead'
 286         [color6]='#88c0d0'    [color14]='#8fbcbb'
 287         [color7]='#e5e9f0'    [color15]='#eceff4'
 288 ) # }}}
 289 declare -A nord_base16=( # {{{
 290     [background]='#2e3440' [foreground]='#e5e9f0'
 291         [color0]='#2e3440'     [color8]='#4c566a'
 292         [color1]='#88c0d0'     [color9]='#88c0d0'
 293         [color2]='#bf616a'    [color10]='#bf616a'
 294         [color3]='#5e81ac'    [color11]='#5e81ac'
 295         [color4]='#ebcb8b'    [color12]='#ebcb8b'
 296         [color5]='#a3be8c'    [color13]='#a3be8c'
 297         [color6]='#d08770'    [color14]='#d08770'
 298         [color7]='#e5e9f0'    [color15]='#8fbcbb'
 299 ) # }}}
 300 declare -A ocean_base16=( # {{{
 301     [background]='#2b303b' [foreground]='#c0c5ce'
 302         [color0]='#2b303b'     [color8]='#65737e'
 303         [color1]='#bf616a'     [color9]='#bf616a'
 304         [color2]='#a3be8c'    [color10]='#a3be8c'
 305         [color3]='#ebcb8b'    [color11]='#ebcb8b'
 306         [color4]='#8fa1b3'    [color12]='#8fa1b3'
 307         [color5]='#b48ead'    [color13]='#b48ead'
 308         [color6]='#96b5b4'    [color14]='#96b5b4'
 309         [color7]='#c0c5ce'    [color15]='#eff1f5'
 310 ) # }}}
 311 declare -A oceanicnext_base16=( # {{{
 312     [background]='#1b2b34' [foreground]='#c0c5ce'
 313         [color0]='#1b2b34'     [color8]='#65737e'
 314         [color1]='#ec5f67'     [color9]='#ec5f67'
 315         [color2]='#99c794'    [color10]='#99c794'
 316         [color3]='#fac863'    [color11]='#fac863'
 317         [color4]='#6699cc'    [color12]='#6699cc'
 318         [color5]='#c594c5'    [color13]='#c594c5'
 319         [color6]='#5fb3b3'    [color14]='#5fb3b3'
 320         [color7]='#c0c5ce'    [color15]='#d8dee9'
 321 ) # }}}
 322 declare -A porple_base16=( # {{{
 323     [background]='#292c36' [foreground]='#d8d8d8'
 324         [color0]='#292c36'     [color8]='#65568a'
 325         [color1]='#f84547'     [color9]='#f84547'
 326         [color2]='#95c76f'    [color10]='#95c76f'
 327         [color3]='#efa16b'    [color11]='#efa16b'
 328         [color4]='#8485ce'    [color12]='#8485ce'
 329         [color5]='#b74989'    [color13]='#b74989'
 330         [color6]='#64878f'    [color14]='#64878f'
 331         [color7]='#d8d8d8'    [color15]='#f8f8f8'
 332 ) # }}}
 333 declare -A rebecca_base16=( # {{{
 334     [background]='#292a44' [foreground]='#f1eff8'
 335         [color0]='#292a44'     [color8]='#666699'
 336         [color1]='#a0a0c5'     [color9]='#a0a0c5'
 337         [color2]='#6dfedf'    [color10]='#6dfedf'
 338         [color3]='#ae81ff'    [color11]='#ae81ff'
 339         [color4]='#2de0a7'    [color12]='#2de0a7'
 340         [color5]='#7aa5ff'    [color13]='#7aa5ff'
 341         [color6]='#8eaee0'    [color14]='#8eaee0'
 342         [color7]='#f1eff8'    [color15]='#53495d'
 343 ) # }}}
 344 declare -A solarized=( # {{{
 345     [background]='#073642' [foreground]='#fdf6e3'
 346         [color0]='#073642'     [color8]='#6c7c80'
 347         [color1]='#dc322f'     [color9]='#dc322f'
 348         [color2]='#859900'    [color10]='#859900'
 349         [color3]='#b58900'    [color11]='#b58900'
 350         [color4]='#268bd2'    [color12]='#268bd2'
 351         [color5]='#d33682'    [color13]='#d33682'
 352         [color6]='#2aa198'    [color14]='#2aa198'
 353         [color7]='#eee8d5'    [color15]='#eee8d5'
 354 ) # }}}
 355 declare -A tomorrow_night_base16=( # {{{
 356     [background]='#1d1f21' [foreground]='#c5c8c6'
 357         [color0]='#1d1f21'     [color8]='#969896'
 358         [color1]='#cc6666'     [color9]='#cc6666'
 359         [color2]='#b5bd68'    [color10]='#b5bd68'
 360         [color3]='#f0c674'    [color11]='#f0c674'
 361         [color4]='#81a2be'    [color12]='#81a2be'
 362         [color5]='#b294bb'    [color13]='#b294bb'
 363         [color6]='#8abeb7'    [color14]='#8abeb7'
 364         [color7]='#c5c8c6'    [color15]='#ffffff'
 365 ) # }}}
 366 declare -A zenburn3=( # {{{
 367     [background]='#3f3f3f' [foreground]='#ffffff'
 368         [color0]='#3f3f3f'     [color8]='#828282'
 369         [color1]='#dca5a5'     [color9]='#dca5a5'
 370         [color2]='#c0e380'    [color10]='#c0e380'
 371         [color3]='#e4e49a'    [color11]='#e4e49a'
 372         [color4]='#7d9ec0'    [color12]='#7d9ec0'
 373         [color5]='#ffc66d'    [color13]='#ffc66d'
 374         [color6]='#8acccf'    [color14]='#8acccf'
 375         [color7]='#ffffff'    [color15]='#ffffff'
 376 ) # }}}
 377 
 378 return 2>&-
 379 
 380 declare -n colors=default
 381 declare -a gtk=( # {{{
 382       black1 black2
 383         red1 red2
 384       green1 green2
 385      yellow1 yellow2
 386        blue1 blue2
 387     magenta1 magenta2
 388        cyan1 cyan2
 389       white1 white2
 390 ) # }}}
 391 declare -A map=( # {{{
 392       [black1]=color0   [black2]=color8
 393         [red1]=color1     [red2]=color9
 394       [green1]=color2   [green2]=color10
 395      [yellow1]=color3  [yellow2]=color11
 396        [blue1]=color4    [blue2]=color12
 397     [magenta1]=color5 [magenta2]=color13
 398        [cyan1]=color6    [cyan2]=color14
 399       [white1]=color7   [white2]=color15
 400 ) # }}}
 401 
 402 source ~/.theme/sh 2>&- &&
 403 for i in {back,fore}ground color{0..15}; do colors[$i]=${!i}; done
 404 
 405 ################################################################################
 406 
 407 adjust(){ # {{{
 408     local r=$(printf %d 0x${1:1:2} | awk -v m=$2 '{ print int($1 * m) }')
 409     local g=$(printf %d 0x${1:3:2} | awk -v m=$2 '{ print int($1 * m) }')
 410     local b=$(printf %d 0x${1:5:2} | awk -v m=$2 '{ print int($1 * m) }')
 411 
 412     printf '#%02x%02x%02x\n' $r $g $b
 413 } # }}}
 414 srgba(){ # {{{
 415     local r=$(printf %d 0x${1:1:2})
 416     local g=$(printf %d 0x${1:3:2})
 417     local b=$(printf %d 0x${1:5:2})
 418     local rgb="rgba($r, $g, $b"
 419 
 420     printf '%s/%-*s' "$rgb" ${#rgb} "alpha($(adjust $2 ${3:-1})"
 421 } # }}}
 422 
 423 case $1 in
 424     -r|--reload ) reload=1;;
 425     -R|--restart) reload=1 restart=1;;
 426 
 427     -b|--background)
 428         cp "$2" ~/.theme/background &&
 429         echo background "$(realpath "$2")" >> ~/.theme/history
 430         hsetroot -solid ${colors[background]} -fill ~/.theme/background
 431 
 432         exit
 433     ;;
 434 
 435     -c|--colors)
 436         reload=1
 437         source $0
 438         declare -n colors=${2:-null}
 439 
 440         c(){ source $0; local | sed 's/declare -A //' | grep -o '^\w*'; }
 441         [[ ! $2 || ! ${colors[@]} ]] && c && exit 1
 442 
 443         echo colors "$2" >> ~/.theme/history
 444     ;;
 445 
 446     -w|--wal)
 447         [[ ! $2 ]] && wal --theme && exit 1
 448 
 449         wal -c
 450 
 451         [[ -f $2 ]] && wal -qnstei "$2" && $0 -b "$2"
 452         [[ -f $2 ]] || wal -qnste --theme "${@:2}"
 453 
 454         echo wal "${@:2}" >> ~/.theme/history
 455         cp ~/.cache/wal/colors.sh ~/.theme/sh && $0 -r
 456 
 457         exit
 458     ;;
 459 
 460     -g|--gtk)
 461         [[ ! $2 || ! ${map[$2]} ]] && printf '%s\n' ${gtk[@]} && exit 1
 462         $0 -t $2; $0 -i $2; exit
 463     ;;
 464 
 465     -t|--theme)
 466         [[ ! $2 || ! ${map[$2]} ]] && printf '%s\n' ${gtk[@]} && exit 1
 467 
 468         echo theme "$2" >> ~/.theme/history
 469 
 470         git clone https://gitlab.com/lxg/adapta ~/.local/share/themes/Adapta-Color
 471         cd $_ && git checkout .
 472 
 473         color=${map[$2]}
 474         color=${colors[$color]}
 475 
 476         [[ $background != \#222228 ]] &&
 477         find * -type f ! -exec sed -i "
 478             s/#222d32/$background/Ig                # menubar
 479             s/#fdfdfe/$foreground/Ig                # submenu
 480             s/#28343a/$background/Ig                # submenu darkmode
 481 
 482             s/$(srgba \#cfd8dc $foreground 0.8)/Ig  # menuitem
 483             s/#cfd8dc/$(adjust $foreground 0.9)/Ig  # menuitem:hover
 484 
 485             s/#fafbfc/$(adjust $foreground 0.97)/Ig # top
 486             s/#f7f9f9/$(adjust $foreground 0.97)/Ig # left
 487             s/#ffffff/$foreground/Ig                # main
 488 
 489             s/$(srgba \#263238 $background)/Ig      # left text
 490             s/#263238/$background/Ig                # main text
 491 
 492             s/#1de9b6/$color/Ig                     # trash msg
 493             s/#ff1744/$color1/Ig                    # root  msg
 494 
 495             s/#e5e9ec/$(adjust $foreground 0.96)/Ig # line
 496             s/#80deea/$foreground/Ig                # selection
 497             s/$(srgba \#ffffff $foreground 0.9)/Ig  # scrollbar
 498 
 499             s/$(srgba \#459c95 $color)/Ig           # button
 500             s/#459c95/$color/Ig                     # button:hover
 501 
 502             s/$(srgba \#81c4bf $color)/Ig           # button
 503             s/#81c4bf/$color/Ig                     # button:hover
 504 
 505             s/$(srgba \#222d32 $background)/Ig      # tooltip
 506             s/#d4d7db/$foreground/Ig                # tooltip
 507 
 508             s/#00bcd4/$color/Ig                     # cyan500
 509             s/$(srgba \#00bcd4 $color)/Ig           # cyan500
 510 
 511             s/#4db6ac/$color/Ig                     # teal300
 512             s/$(srgba \#4db6ac $color)/Ig           # teal300
 513 
 514             s/#009688/$green1/Ig                    # teal500
 515             s/$(srgba \#009688 $green1)/Ig          # teal500
 516 
 517             s/#ff5252/$red1/Ig                      # reda200
 518             s/$(srgba \#ff5252 $red1)/Ig            # reda200
 519         " {} \+
 520 
 521         xfconf-query -c xsettings -p /Net/ThemeName | grep -q Adapta-Color &&
 522         xfconf-query -c xsettings -p /Net/ThemeName -s '' &&
 523         xfconf-query -c xsettings -p /Net/ThemeName -s Adapta-Color
 524 
 525         gsettings list-recursively | grep Adapta-Color | while read a b c; do
 526             gsettings set $a $b ''
 527             gsettings set $a $b Adapta-Color
 528         done
 529 
 530         exit
 531     ;;
 532 
 533     -i|--icons)
 534         [[ ! $2 || ! ${map[$2]} ]] && printf '%s\n' ${gtk[@]} && exit 1
 535 
 536         echo icons "$2" >> ~/.theme/history
 537 
 538         git clone --depth=1 \
 539         https://github.com/PapirusDevelopmentTeam/papirus-icon-theme \
 540         ~/.local/share/icons/Papirus.git
 541 
 542         cd $_ && git checkout .
 543         ln -sT ${PWD##*/}/Papirus ../Papirus-Color
 544         cd $_
 545 
 546         color=${map[$2]}
 547         color=${colors[$color]}
 548 
 549         if [[ $background != \#222228 ]]; then
 550             find -type f  \( -name '*-blue-*.svg' -o -name '*folder-*.svg' \) -exec sed -i "
 551                 s/#4877b1/$(adjust $color 0.6)/Ig
 552                 s/#e4e4e4/$(adjust $foreground 0.97)/Ig
 553                 s/#5294e2/$color/Ig
 554                 s/#1d344f/$(adjust $color 0.4)/Ig
 555             " {} \+ &
 556             find -type f -wholename '*/actions/*.svg' -exec sed -i "s/#444444/$black2/Ig"     {} \+ &
 557             find -type f -wholename '*/panel/*.svg'   -exec sed -i "s/#dfdfdf/$foreground/Ig" {} \+ &
 558             wait
 559         fi
 560 
 561         sed -i "s/Name=Papirus/Name=Papirus-Color/" index.theme
 562         for i in */emblems/emblem-symbolic-link.svg; do echo > $i; done
 563 
 564         xfconf-query -c xsettings -p /Net/IconThemeName | grep -q Papirus-Color &&
 565         xfconf-query -c xsettings -p /Net/IconThemeName -s '' &&
 566         xfconf-query -c xsettings -p /Net/IconThemeName -s Papirus-Color
 567 
 568         gsettings list-recursively | grep Papirus-Color | while read a b c; do
 569             gsettings set $a $b ''
 570             gsettings set $a $b Papirus-Color
 571         done
 572 
 573         exit
 574     ;;
 575 
 576     -C|--rand-colors    ) $0 -c $($0 -c | shuf -n 1); exit;;
 577     -G|--rand-gtk       ) $0 -g $($0 -g | shuf -n 1); exit;;
 578     -T|--rand-theme     ) $0 -t $($0 -t | shuf -n 1); exit;;
 579     -I|--rand-icons     ) $0 -i $($0 -i | shuf -n 1); exit;;
 580     -B|--rand-background) $0 -b $(find ~/Wallpapers/ -type f      | shuf -n 1); exit;;
 581     -W|--rand-wal       ) $0 -w $($0 -w | grep '^\s-' | cut -b 4- | shuf -n 1); exit;;
 582 
 583     -h|--history)
 584         tac ~/.theme/history    |
 585         sed "/^$2/!d; s/^.* //" | {
 586             [[ $3 == 0 ]] && uniq
 587             [[ $3 == 0 ]] || sed "${3:-1}q; d"
 588         } | tac
 589 
 590         exit
 591     ;;
 592 
 593     '') ;;
 594      *) exit;;
 595 esac
 596 
 597 mkdir -p ~/.theme && cd $_
 598 
 599 ################################################################################
 600 
 601 [[ ${colors[foreground]} < ${colors[color7]}  ]] && colors[foreground]=${colors[color7]}
 602 [[ ${colors[foreground]} < ${colors[color15]} ]] && colors[foreground]=${colors[color15]}
 603 
 604 opacity=$(printf '%x' $(( 256 * 97 / 100 )))
 605 colors[background_rgba]=${colors[background]}$opacity
 606 colors[background_argb]=${colors[background]/\#/\#$opacity}
 607 
 608 for i in ${!map[@]}; do
 609     color=${map[$i]}
 610     colors[$i]=${colors[$color]}
 611 done
 612 
 613 ################################################################################
 614 
 615 print(){ # {{{
 616     printf "${2:-%s}\n" "$(
 617         for i in ${!colors[@]}; do
 618             printf "$1\n" $i "${colors[$i]}"
 619         done | sort -V
 620     )"
 621 } # }}}
 622 
 623 > xres print '*%s: %s'
 624 > lua  print '%s = "%s";'
 625 > vim  print 'let %s = "%s"'
 626 > sh   print 'export %s="%s"'
 627 > h    print 'char %s[] = "%s";'
 628 > ini  print '%s = %s' '[colors]\n%s'
 629 
 630 unset colors[background_rgba]
 631 unset colors[background_argb]
 632 
 633 > gtk  print '@define-color %s %s;'
 634 > rasi print '  %s: %s;' '* {\n%s\n}'
 635 > css  print '  --%s: %s;' ':root {\n%s\n}'
 636 
 637 > xterm printf '\e]%s;%s\a' \
 638 10 ${colors[foreground]} 4\;256 ${colors[foreground]} \
 639 11 ${colors[background]} 4\;257 ${colors[background]} \
 640 12 ${colors[foreground]} \
 641 13 ${colors[foreground]} \
 642 17 ${colors[foreground]} \
 643 19 ${colors[background]} \
 644 $(for i in {0..15}; do echo "4;$i" ${colors[color$i]}; done)
 645 
 646 colors[color7]=${colors[foreground]}
 647 > linux printf '\e]P%x%s\a' \
 648 $(for i in {0..7}; do echo $i ${colors[color$i]:1}; done)
 649 
 650 ################################################################################
 651 
 652 source ./sh
 653 xrdb -merge xres
 654 
 655 trap 'wait; echo; colors -c' EXIT
 656 
 657 $0   -b background  &
 658 test -f background || filvice &
 659 
 660 find ~/.config ~/.local -name \*.theme |
 661 while read i; do envsubst < $i > ${i%.theme}; done
 662 
 663 ################################################################################
 664 
 665 [[ $reload ]] || exit
 666 
 667 $0 -t $($0 -h theme) > /dev/null &
 668 $0 -i $($0 -h icons) > /dev/null &
 669 
 670 cmp -s background ~/.cache/filvice.png &&
 671 filvice -r || filvice -n &
 672 
 673 for i in /dev/pts/[0-9]; do cat xterm > $i; done
 674 for i in /dev/tty[0-9];  do cat linux > $i; done 2>&-
 675 
 676 vim --serverlist | xargs -I % \
 677 vim --servername % --remote-send '<Esc>:so $MYGVIMRC<Cr>'
 678 
 679 pkill       -x dunst
 680 pkill -USR1 -x sxhkd
 681 
 682 pkill -HUP  -x awesome
 683 pkill -USR1 -x awesome-status
 684 
 685 pkill -HUP  -x xfwm4
 686 pkill -USR1 -x xfce4-panel
 687 pkill -USR1 -x xfwm4-status
 688 
 689 i3 reload
 690 pkill -USR1 -x openbox
 691 pidof dwm && xdotool key super+control+F5
 692 
 693 ################################################################################
 694 
 695 [[ $restart ]] || exit
 696 
 697 i3 restart
 698 
 699 pkill -HUP  -x dwm
 700 pkill -USR1 -x dwm-status