123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/bin/bash
-
- . "$(sfpath)" || exit 3
-
- shellfu import pretty
-
-
- xd2html() {
- local name color
- while read -r line;
- do
- name="${line%%:*}"
- color="${line##*:}"
- test -n "$name" || continue
- test -n "$color" || continue
- debug -v name color
- test "$name" == "URxvt.background" && echo "$color" > "$Tmp/bg"
- test "$name" == "URxvt.foreground" && echo "$color" > "$Tmp/fg"
- echos " <p style='color: $color'>$name = $color</p>"
- done
- }
-
- htmlhead() {
- echos "<!doctype html>"
- echos "<html>"
- echos " <head>"
- echos " <title>$File</title>"
- echos " <link rel='stylesheet' href='$File.css'>"
- echos " </head>"
- echos " <body>"
- }
-
- htmltail() {
- echos " </body>"
- echos "</html>"
- }
-
- mkcss() {
- echos "body {"
- echos " font-size: xx-large;"
- echos " font-family: monospace;"
- echos " color: $(cat "$Tmp/fg");"
- echos " background-color: $(cat "$Tmp/bg");"
- echos "}"
- }
-
- mkhtml() {
- htmlhead
- <"$File" xd2html
- htmltail
- }
-
- main() {
- local File=$1
- local Tmp
- Tmp=$(mktemp -dt mkdemo.XXXXXXXX)
- test -n "$File" || mkusage "scheme.Xresources"
- mkhtml > "$File.html"
- debug -f "$Tmp/fg" "$Tmp/bg"
- test -s "$Tmp/fg" || die "failed to parse URxvt.foreground"
- test -s "$Tmp/bg" || die "failed to parse URxvt.background"
- mkcss > "$File.css"
- rm -r "$Tmp"
- }
-
- main "$@"
|