My dotfiles. Period.

mkdemo 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. . "$(sfpath)" || exit 3
  3. shellfu import pretty
  4. xd2html() {
  5. local name color
  6. while read -r line;
  7. do
  8. name="${line%%:*}"
  9. color="${line##*:}"
  10. test -n "$name" || continue
  11. test -n "$color" || continue
  12. debug -v name color
  13. test "$name" == "URxvt.background" && echo "$color" > "$Tmp/bg"
  14. test "$name" == "URxvt.foreground" && echo "$color" > "$Tmp/fg"
  15. echos " <p style='color: $color'>$name</p>"
  16. done
  17. }
  18. htmlhead() {
  19. echos "<!doctype html>"
  20. echos "<html>"
  21. echos " <head>"
  22. echos " <title>$File</title>"
  23. echos " <link rel='stylesheet' href='$File.css'>"
  24. echos " </head>"
  25. echos " <body>"
  26. }
  27. htmltail() {
  28. echos " </body>"
  29. echos "</html>"
  30. }
  31. mkcss() {
  32. echos "body {"
  33. echos " font-size: xx-large;"
  34. echos " font-family: monospace;"
  35. echos " color: $(cat "$Tmp/fg");"
  36. echos " background-color: $(cat "$Tmp/bg");"
  37. echos "}"
  38. }
  39. mkhtml() {
  40. htmlhead
  41. <"$File" xd2html
  42. htmltail
  43. }
  44. main() {
  45. local File=$1
  46. local Tmp
  47. Tmp=$(mktemp -dt mkdemo.XXXXXXXX)
  48. test -n "$File" || mkusage "scheme.Xresources"
  49. mkhtml > "$File.html"
  50. debug -f "$Tmp/fg" "$Tmp/bg"
  51. test -s "$Tmp/fg" || die "failed to parse URxvt.foreground"
  52. test -s "$Tmp/bg" || die "failed to parse URxvt.background"
  53. mkcss > "$File.css"
  54. rm -r "$Tmp"
  55. }
  56. main "$@"