Przeglądaj źródła

Add colorscheme demo maker (depends on fastfoo)

Alois Mahdal 9 lat temu
rodzic
commit
5be1960dbe
1 zmienionych plików z 62 dodań i 0 usunięć
  1. 62
    0
      dotfiles.config/Xlib/colorscheme/mkdemo

+ 62
- 0
dotfiles.config/Xlib/colorscheme/mkdemo Wyświetl plik

@@ -0,0 +1,62 @@
1
+#!/bin/bash
2
+
3
+. <(ffoom init)
4
+
5
+ffoo import core
6
+
7
+CSDEMO_FNAME=$1
8
+CSDEMO_BG="$(mktemp)"
9
+CSDEMO_FG="$(mktemp)"
10
+
11
+
12
+xd2html() {
13
+    local name color
14
+    while read line;
15
+    do
16
+        name="${line%%:*}"
17
+        color="${line##*:}"
18
+        test -n "$name"  || continue
19
+        test -n "$color" || continue
20
+        debug -v name color
21
+        test "$name" == "URxvt.background" && echo "$color" > $CSDEMO_BG
22
+        test "$name" == "URxvt.foreground" && echo "$color" > $CSDEMO_FG
23
+        echos "        <p style='color: $color'>$name</p>"
24
+    done
25
+}
26
+
27
+htmlhead() {
28
+    echos "<!doctype html>"
29
+    echos "<html>"
30
+    echos "    <head>"
31
+    echos "        <title>$CSDEMO_FNAME</title>"
32
+    echos "        <link rel='stylesheet' href='$CSDEMO_FNAME.css'>"
33
+    echos "    </head>"
34
+    echos "    <body>"
35
+}
36
+
37
+htmltail() {
38
+    echos "    </body>"
39
+    echos "</html>"
40
+}
41
+
42
+css() {
43
+    echos "body {"
44
+    echos "    font-size: xx-large;"
45
+    echos "    font-family: monospace;"
46
+    echos "    color: $(cat $CSDEMO_FG);"
47
+    echos "    background-color: $(cat $CSDEMO_BG);"
48
+    echos "}"
49
+}
50
+
51
+test -n "$CSDEMO_FNAME" || usage_is "scheme.Xresources"
52
+
53
+htmlhead                    >  $CSDEMO_FNAME.html
54
+cat $CSDEMO_FNAME | xd2html >> $CSDEMO_FNAME.html
55
+htmltail                    >> $CSDEMO_FNAME.html
56
+debug -f $CSDEMO_FG $CSDEMO_BG
57
+test -s "$CSDEMO_FG" || die "failed to parse URxvt.foreground"
58
+test -s "$CSDEMO_BG" || die "failed to parse URxvt.background"
59
+css                         >  $CSDEMO_FNAME.css
60
+
61
+rm $CSDEMO_BG
62
+rm $CSDEMO_FG