#!/bin/bash # speedwm-help # Documentation generator/list for speedwm. # Licensed under the GNU GPLv3 free software license. # No color if NOCOLOR is exported as true. if [ "$NOCOLOR" != "true" ]; then COL2="$(printf '\033[0;35m')" # Color 2 COL1="$(printf '\033[0m')" # Color 1 fi # Set documentation directory if [ "${DOCDIR}" = "" ]; then DOCDIR=/usr/share/speedwm fi # Set prefix if [ "$PREFIX" = "" ]; then PREFIX="" fi ARG1=$1 ARG2=$2 ARGINF=$@ if [ "$ARG2" = "" ]; then VIEWER=less else VIEWER="$ARG2" echo "Using $ARG2 as output." | sed "s|-o|stdout|g" fi case "$VIEWER" in "-o") VIEWER="cat" ;; esac if [ -e "${DOCDIR}/${PREFIX}example.Xresources" ]; then sed 's|\(!*\)!.*|\1|' ${DOCDIR}/${PREFIX}example.Xresources | grep -v "!" | grep speedwm > /tmp/example.Xresources fi cat ${DOCDIR}/${PREFIX}doc-01 \ ${DOCDIR}/${PREFIX}doc-02 \ ${DOCDIR}/${PREFIX}doc-03 \ ${DOCDIR}/${PREFIX}doc-04 \ ${DOCDIR}/${PREFIX}keybinds \ ${DOCDIR}/${PREFIX}dependencies \ ${DOCDIR}/${PREFIX}doc-05 \ ${DOCDIR}/${PREFIX}doc-06 \ /tmp/example.Xresources \ ${DOCDIR}/${PREFIX}doc-07 \ ${DOCDIR}/${PREFIX}example.signal \ ${DOCDIR}/${PREFIX}doc-08 \ ${DOCDIR}/${PREFIX}doc-09 | grep -v "!!" > /tmp/${PREFIX}doc case "$ARG1" in "-w") tail -n $(expr $(cat /tmp/${PREFIX}doc | wc -l) "-" 1) /tmp/${PREFIX}doc > ../readme ;; "-wmd") tail -n $(expr $(cat /tmp/${PREFIX}doc | wc -l) "-" 1) /tmp/${PREFIX}doc | \ sed "s|-- speedwm --|# speedwm|g" | \ sed "s|-- What is speedwm? --|## What is speedwm?|g" | \ sed "s|-- Installation --|## Installation|g" | \ sed "s|-- Layouts --|## Layouts|g" | \ sed "s|-- Patches --|## Patches|g" | \ sed "s|-- Keybinds --|## Keybinds|g" | \ sed "s|-- Applications --|### Applications|g" | \ sed "s|-- Navigation --|### Navigation|g" | \ sed "s|-- Chained keybinds --|### Chained keybinds|g" | \ sed "s|-- Mouse --|### Mouse|g" | \ sed "s|-- Extras --|### Extras|g" | \ sed "s|-- Dependencies --|## Dependencies|g" | \ sed "s|-- Features --|## Features|g" | \ sed "s|-- Software --|## Software|g" | \ sed "s|-- Important --|## Important|g" | \ sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \ sed "s|-- Signals --|## Signals|g" | \ sed "s|-- Additional note on autostart --|## Additional note on autostart|g" | \ sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" > ../README.md ;; "-whtml") tail -n $(expr $(cat /tmp/${PREFIX}doc | wc -l) "-" 1) /tmp/${PREFIX}doc | \ sed "s|-- speedwm --|# speedwm|g" | \ sed "s|-- What is speedwm? --|## What is speedwm?|g" | \ sed "s|-- Installation --|## Installation|g" | \ sed "s|-- Layouts --|## Layouts|g" | \ sed "s|-- Patches --|## Patches|g" | \ sed "s|-- Keybinds --|## Keybinds|g" | \ sed "s|-- Applications --|### Applications|g" | \ sed "s|-- Navigation --|### Navigation|g" | \ sed "s|-- Chained keybinds --|### Chained keybinds|g" | \ sed "s|-- Mouse --|### Mouse|g" | \ sed "s|-- Extras --|### Extras|g" | \ sed "s|-- Dependencies --|## Dependencies|g" | \ sed "s|-- Features --|## Features|g" | \ sed "s|-- Software --|## Software|g" | \ sed "s|-- Important --|## Important|g" | \ sed "s|-- .Xresources and Pywal --|## .Xresources and Pywal|g" | \ sed "s|-- Signals --|## Signals|g" | \ sed "s|-- Maintaining settings easily --|## Maintaining settings easily|g" | \ sed "s|-- Additional note on autostart --|## Additional note on autostart|g" > ../README.md markdown ../README.md > ../readme.html || printf "\nmarkdown-to-html not found, install using:\nnpm install markdown-to-html -g\n" && exit 1 ;; "-whtml-wtemplate") test ../readme.html && cat ../docs/speedwm.html.template.1 ../readme.html ../docs/speedwm.html.template.2 >> ../speedwm.html && exit 0 printf "\nYou need to $0 -whtml first." ; exit 1 ;; "") $0 -h && exit 0 ;; "-h") printf "speedwm help\n\nNo arguments to view this list of arguments.\n-h | View this list of arguments.\n-a | View everything.\n-1 | What is speedwm?\n-2 | List of all keybinds\n-3 | List of all dependencies\n-4 | .Xresources/Pywal information.\n-5 | Signals information\n-6 | Switching run launcher\n-7 | Installation\n-8 | Layouts\n-9| Important information.\n-w | Write documentation to ../readme\n-wmd | Write documentation (Markdown)\n-whtml | Write documentation (HTML) using markdown-to-html.\n-whtml-wtemplate | Combine template 1, output of -whtml and template 2 (from docs/) to create a full HTML document.\n\nIf second argument is -o, the requested output will be sent to stdout.\n-o can be replaced with a text editor or reader of your choice (such as less, vim, emacs, etc.)\n"; exit 0 ;; "-1") cat ${DOCDIR}/${PREFIX}doc-01 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-2") cat ${DOCDIR}/${PREFIX}doc-04 ${DOCDIR}/${PREFIX}keybinds > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-3") cat ${DOCDIR}/${PREFIX}dependencies > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-4") cat ${DOCDIR}/${PREFIX}doc-06 /tmp/example.Xresources > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-5") cat ${DOCDIR}/${PREFIX}doc-07 ${DOCDIR}/${PREFIX}example.signal > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-6") cat ${DOCDIR}/${PREFIX}doc-08 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-7") cat ${DOCDIR}/${PREFIX}doc-02 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-8") cat ${DOCDIR}/${PREFIX}doc-03 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-9") cat ${DOCDIR}/${PREFIX}doc-05 > /tmp/stdout ; $VIEWER /tmp/stdout ;; "-a") cat /tmp/${PREFIX}doc > /tmp/stdout ; $VIEWER /tmp/stdout ;; esac