Still broken, slightly less. Will import code from iode.
[iomenu.git] / io-tty-theme
blobcc19baec16a36f6e631e356fef93f40caf36e82d
1 # Apply a x-ressource theme to the tty                                2016-12-14
3 # .  _     |_ |_       |_ |_   _  __   _
4 # | (_) -- |  |  \/ -- |  | | (/_ ||| (/_
5 #                /
6 #_______________________________________________________________________________
8 # Set the directory where you usually set your themes:
9 THEMES="$HOME/.config/themes"
11 # Then run this script, with either one theme name as argument, or as is, to
12 # run it in an interactively filter.  You can set the filter to something like
13 # fzf, fzy, slmenu, pick, pick, selecta...
14 FILTER='iomenu'
16 # if no argument
17 if [ $# = 0 ]
18 then
19         # interactively prompt for a color theme
20         ls "$THEMES" | $FILTER
21 else
22         # otherwise use the one from the command line argument
23         printf %s $1
24 fi | xargs -i sed -rn '
26 # remove comment lines
27 /^[[:space:]]*!.*/ d
29 # remove empty lines
30 /^[[:space:]]*$/ d
32 # convert colors numbers from decimal to hexadecimal
33 s/color10/colorA/
34 s/color11/colorB/
35 s/color12/colorC/
36 s/color13/colorD/
37 s/color14/colorE/
38 s/color15/colorF/
40 # print escaped color names
41 s/.*\.color([0-9A-F])[[:space:]]*:[[:space:]]*#/\1/ p
43 ' "$THEMES/{}" | while read color
45         # TTY color escape codes
46         printf '\033]P%s' "$color"
47 done
49 clear