diff --git a/.Books/atmo.sh b/.Books/atmo.sh new file mode 100755 index 0000000..82180ca --- /dev/null +++ b/.Books/atmo.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BG_DIR="${SCRIPT_DIR/\/.Books/}/backgrounds" + +while [[ $chosen != 'chosen' ]]; do + clear + echo -e "============================================\033[1;38;5;94m" + ls $BG_DIR + echo -e "\033[38;5;95m============================================" + cd $BG_DIR + read -e -p " Choose a background:$(echo -e "\033[1;38;5;94m") " bg + + + if [[ -e "$bg" && "$bg" =~ \.(jpg|jpeg)$ ]]; then + echo + $SCRIPT_DIR/viu "$bg" -w64 + echo + read -sn1 -p "This one? [Y|n]" yn + if [[ ! ${yn^^} == 'N' ]]; then + rm -f $SCRIPT_DIR/backgrounds/atmo.jpg + ln -s "$(realpath "$bg")" $SCRIPT_DIR/backgrounds/atmo.jpg + chosen='chosen' + fi + echo + else + echo Not a .jpg + fi +done diff --git a/.Books/backgrounds/Henley-on-Thames.jpg b/.Books/backgrounds/Henley-on-Thames.jpg new file mode 100644 index 0000000..66f3c8a Binary files /dev/null and b/.Books/backgrounds/Henley-on-Thames.jpg differ diff --git a/.Books/backgrounds/atmo.jpg b/.Books/backgrounds/atmo.jpg new file mode 120000 index 0000000..15bfee9 --- /dev/null +++ b/.Books/backgrounds/atmo.jpg @@ -0,0 +1 @@ +/home/ggstuart/Nextcloud/Documents/writing/Books/.Books/backgrounds/kowloon3.jpg \ No newline at end of file diff --git a/.Books/backgrounds/bookshelf.jpg b/.Books/backgrounds/bookshelf.jpg new file mode 100644 index 0000000..4e77b2a Binary files /dev/null and b/.Books/backgrounds/bookshelf.jpg differ diff --git a/.Books/backgrounds/bookshelf2.jpg b/.Books/backgrounds/bookshelf2.jpg new file mode 100644 index 0000000..18bdb36 Binary files /dev/null and b/.Books/backgrounds/bookshelf2.jpg differ diff --git a/.Books/backgrounds/bracknell-station.jpg b/.Books/backgrounds/bracknell-station.jpg new file mode 100644 index 0000000..e6cf602 Binary files /dev/null and b/.Books/backgrounds/bracknell-station.jpg differ diff --git a/.Books/backgrounds/dark-forest.jpg b/.Books/backgrounds/dark-forest.jpg new file mode 100644 index 0000000..c0478c8 Binary files /dev/null and b/.Books/backgrounds/dark-forest.jpg differ diff --git a/.Books/backgrounds/forest.jpeg b/.Books/backgrounds/forest.jpeg new file mode 100644 index 0000000..925e286 Binary files /dev/null and b/.Books/backgrounds/forest.jpeg differ diff --git a/.Books/backgrounds/graveyard.jpg b/.Books/backgrounds/graveyard.jpg new file mode 100644 index 0000000..2842596 Binary files /dev/null and b/.Books/backgrounds/graveyard.jpg differ diff --git a/.Books/backgrounds/green-tree-forest.jpg b/.Books/backgrounds/green-tree-forest.jpg new file mode 100644 index 0000000..85cf522 Binary files /dev/null and b/.Books/backgrounds/green-tree-forest.jpg differ diff --git a/.Books/backgrounds/kowloon.jpg b/.Books/backgrounds/kowloon.jpg new file mode 100644 index 0000000..620edb8 Binary files /dev/null and b/.Books/backgrounds/kowloon.jpg differ diff --git a/.Books/backgrounds/kowloon2.jpg b/.Books/backgrounds/kowloon2.jpg new file mode 100644 index 0000000..7ff177c Binary files /dev/null and b/.Books/backgrounds/kowloon2.jpg differ diff --git a/.Books/backgrounds/kowloon3.jpg b/.Books/backgrounds/kowloon3.jpg new file mode 100644 index 0000000..8537629 Binary files /dev/null and b/.Books/backgrounds/kowloon3.jpg differ diff --git a/.Books/backgrounds/messy room.jpg b/.Books/backgrounds/messy room.jpg new file mode 100644 index 0000000..10f51c6 Binary files /dev/null and b/.Books/backgrounds/messy room.jpg differ diff --git a/.Books/backgrounds/night-trains.jpg b/.Books/backgrounds/night-trains.jpg new file mode 100644 index 0000000..c54545e Binary files /dev/null and b/.Books/backgrounds/night-trains.jpg differ diff --git a/.Books/backgrounds/oldlondon.jpg b/.Books/backgrounds/oldlondon.jpg new file mode 100644 index 0000000..351e5dc Binary files /dev/null and b/.Books/backgrounds/oldlondon.jpg differ diff --git a/.Books/backgrounds/police-station.jpg b/.Books/backgrounds/police-station.jpg new file mode 100644 index 0000000..df696ba Binary files /dev/null and b/.Books/backgrounds/police-station.jpg differ diff --git a/.Books/backgrounds/post-apocalypse london.jpg b/.Books/backgrounds/post-apocalypse london.jpg new file mode 100644 index 0000000..829784d Binary files /dev/null and b/.Books/backgrounds/post-apocalypse london.jpg differ diff --git a/.Books/backgrounds/prison-cell.jpg b/.Books/backgrounds/prison-cell.jpg new file mode 100644 index 0000000..617518b Binary files /dev/null and b/.Books/backgrounds/prison-cell.jpg differ diff --git a/.Books/backgrounds/prison.jpg b/.Books/backgrounds/prison.jpg new file mode 100644 index 0000000..fa9b536 Binary files /dev/null and b/.Books/backgrounds/prison.jpg differ diff --git a/.Books/backgrounds/slumpunk.jpg b/.Books/backgrounds/slumpunk.jpg new file mode 100644 index 0000000..f103945 Binary files /dev/null and b/.Books/backgrounds/slumpunk.jpg differ diff --git a/.Books/backgrounds/spacedreams.jpg b/.Books/backgrounds/spacedreams.jpg new file mode 100644 index 0000000..26cd14f Binary files /dev/null and b/.Books/backgrounds/spacedreams.jpg differ diff --git a/.Books/backgrounds/station.jpg b/.Books/backgrounds/station.jpg new file mode 100644 index 0000000..f344ca8 Binary files /dev/null and b/.Books/backgrounds/station.jpg differ diff --git a/.Books/backgrounds/wei long 2.jpg b/.Books/backgrounds/wei long 2.jpg new file mode 100644 index 0000000..53ee229 Binary files /dev/null and b/.Books/backgrounds/wei long 2.jpg differ diff --git a/.Books/backgrounds/wei long.jpg b/.Books/backgrounds/wei long.jpg new file mode 100644 index 0000000..6b82d53 Binary files /dev/null and b/.Books/backgrounds/wei long.jpg differ diff --git a/.Books/backgrounds/writingdesk.jpg b/.Books/backgrounds/writingdesk.jpg new file mode 100644 index 0000000..836ade7 Binary files /dev/null and b/.Books/backgrounds/writingdesk.jpg differ diff --git a/.Books/booksenv.sh b/.Books/booksenv.sh new file mode 100755 index 0000000..acd0567 --- /dev/null +++ b/.Books/booksenv.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash + +# This script should be sourced + +BOOK_DIR=$1 +lightbrown="\[\033[1;38;5;94m\]" +darkbrown="\[\033[38;5;95m\]" + +# export PERIOD=30 +export MANUSKRIPT_BIN="$HOME/.Books/manuskript/bin/manuskript" +# export MANUSKRIPT_BIN="manuskript" + +alias upload="$HOME/.Books/upload.sh" +alias download="$HOME/.Books/download.sh" +alias write="$HOME/.Books/write.sh" +alias wryte="$HOME/.Books/write.sh" +alias manuskript="$HOME/.Books/write.sh" +alias atmo="$HOME/.Books/atmo.sh" +alias compile="$HOME/.Books/compile.sh" +# alias rollback="$HOME/.Books/rollback.sh" + +# mkdir -p /tmp/manuskriptbackups +# find /tmp/manuskriptbackups/ -ctime +1 | xargs -I% rm % # remove backups older than a day + +bookmoji=$(echo -e "\U1F4D6") +PS1=$(echo -e "$bookmoji $lightbrown-Books-\[\033[0m\] $darkbrown") +which guake &>/dev/null && guake -r $bookmoji +history -c +history -r "$HOME/.Books/history" +cd $BOOK_DIR +#$HOME/.Books/download.sh +clear diff --git a/.Books/branchy.sh b/.Books/branchy.sh new file mode 100755 index 0000000..0c4710f --- /dev/null +++ b/.Books/branchy.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +# PERIOD=10 + +while [[ ! `pgrep -f "manuskript $1"` ]]; do + sleep 0.5 +done +notify-send "Making backups of $1 every $PERIOD seconds." +tick=1 +while [[ `pgrep -f "manuskript $1"` ]]; do + sleep 1 + if [[ $tick -ge $PERIOD ]]; then + committy "$1" + tick=0 + fi + tick=$(( $tick + 1 )) +done +notify-send "No longer making backups of $1." +rm -f $BOOK_DIR/nohup.out diff --git a/.Books/compile.sh b/.Books/compile.sh new file mode 100755 index 0000000..aee8d4b --- /dev/null +++ b/.Books/compile.sh @@ -0,0 +1,101 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +####### defaults ######### +YAML=$SCRIPT_DIR/frontmatter.yml +OUTPUT_FORMAT=docx +TEMPLATE=md2long.sh +SCENE_BREAK="\n\n### #\n\n" +LINE_BREAK="\n" + +####### options ######### +while getopts "hy:edsf:" opt; do + case $opt in + y) YAML=$OPTARG ;; + e) OUTPUT_FORMAT=epub ;; + d) OUTPUT_FORMAT=docx ;; + s) TEMPLATE=md2short.sh ;; + f) OUTPUT_FORMAT=$OPTARG ;; + h) echo "USAGE: compile [-y frontmatter.yml ] [ -e | -d | -f format ] FILE.msk" ;; + esac +done +shift $((OPTIND-1)) +msk=$1 + +echo -e "*********** compiling *******************\033[19D$msk " + +chapter() { + dir=$1 + if [[ $(egrep -c "^compile: *0$" $dir/folder.txt) -eq 0 ]]; then + chaptitle=$(cat $dir/folder.txt | egrep "^title:" | sed 's/^title: *//g') + chapsubtitle=$(cat $dir/folder.txt | egrep "^summarySentence:" | sed 's/^summarySentence: *//g') + echo "# $chaptitle - $chapsubtitle" + for md in $dir/*.md; do + if [[ $(egrep -c "^compile: *0$" $md) -eq 0 ]]; then + start=$(( $(egrep -n -m1 '^$' $md | cut -d: -f1) + 2 )) + echo >> $md + tail -n +$start $md | while read line; do echo "$line"; echo -ne $LINE_BREAK; done + echo -ne $SCENE_BREAK + fi + done + fi +} + +dir2md() { + shortbooktitle=$(cat $1/infos.txt | egrep "^Title:" | sed 's/^Title: *//g') + booktitle=$(cat $1/infos.txt | egrep "^Subtitle:" | sed 's/^Subtitle: *//g') + compiled_md=$(mktemp /tmp/XXXXXXXX.md) + cat $YAML | sed "s/^title:\ .*$/title: \"$shortbooktitle\"/g; s/^short_title:\ .*$/short_title: \"$shortbooktitle\"/g" > $compiled_md + for dir in $1/outline/*; do + if [[ -d $dir ]]; then + chapter $dir >> $compiled_md + fi + done + echo "*********** markdown compiled ***********" +} + +compile() { + if [[ -f $msk ]]; then + if [[ $(cat $msk | wc -c) -eq 1 ]]; then + dir2md ${msk%\.*} + else + #unzip the msk + unzipped_dir=$(mktemp -d /tmp/XXXXXXXX) + unzip -qou "$msk" -d $unzipped_dir + dir2md $unzipped_dir + rm -rf $unzipped_dir + fi + elif [[ -d $msk && -f $msk/infos.txt ]]; then + dir2md $msk + else + echo No book specified + exit + fi +} + +###### main ########### +case $OUTPUT_FORMAT in + docx) + compile + echo -en "\033[1;38;5;94m" + $SCRIPT_DIR/pandoc-templates/bin/$TEMPLATE --output "$booktitle.$OUTPUT_FORMAT" --overwrite $compiled_md #&> /dev/null + ;; + epub) + compile + echo -en "\033[1;38;5;94m" + pandoc --from=markdown --to=epub --css=$SCRIPT_DIR/epub.css --output="$booktitle.$OUTPUT_FORMAT" --toc $compiled_md #&> /dev/null + ;; + *) + echo -e "What on Earth is a \033[1m$OUTPUT_FORMAT\033[0m?" + echo "******* exiting because of reasons ******" + exit 1 + ;; +esac + echo -en "\033[1;38;5;95m" +echo "*********** pandoc finished *************" +rm $compiled_md +# echo $compiled_md +# echo $unzipped_dir +echo -e "\n\033[1m$booktitle.$OUTPUT_FORMAT\033[0m\n" diff --git a/.Books/dictionaries/PyEnchant/en_GB.txt b/.Books/dictionaries/PyEnchant/en_GB.txt new file mode 100644 index 0000000..e69de29 diff --git a/.Books/download.sh b/.Books/download.sh new file mode 100755 index 0000000..974c2b8 --- /dev/null +++ b/.Books/download.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +[[ ! -e $SCRIPT_DIR/initted ]] && $BOOK_DIR/init.sh +[[ ! -e $BOOK_DIR/backgrounds ]] && ln -s "$SCRIPT_DIR/backgrounds" "$BOOK_DIR/backgrounds" + +cd $BOOK_DIR && git pull diff --git a/.Books/epub.css b/.Books/epub.css new file mode 100644 index 0000000..c24802a --- /dev/null +++ b/.Books/epub.css @@ -0,0 +1,54 @@ +/* kindle friendly css with indents*/ + +body { + line-height: 1.75; +} + +body * { + line-height: inherit; +} + + +p { + margin: 0rem 0% 0rem 0rem; + text-indent: 1rem; +} + +h1+p, h2+p { + text-indent: 0em; +} + +h1, h2, .author { + text-align: center; +} + +h4, h5 { + font-size: 100%; +} + +blockquote { + font-size: 90%; + color: #666666; + margin: 0; + padding: 1em 0 1em 3em; + border-left: 0.25em #EEE solid; +} + +blockquote>p { + text-indent: 0em; +} + +hr { + height: 0; + margin-top: 1em; + margin-bottom: 1em; + border: 0; + border-top: 1px solid #eee; +} + +/*suppress numbering in TOC to match the default pandoc styling*/ +ol.toc li { + list-style-type: none; + margin: 0; + padding: 0; +} diff --git a/.Books/frontmatter.yml b/.Books/frontmatter.yml new file mode 100644 index 0000000..e6ec392 --- /dev/null +++ b/.Books/frontmatter.yml @@ -0,0 +1,11 @@ +--- +title: "MANAGED BY SCRIPT - 'Subtitle' field in Manuskript" +short_title: "MANAGED BY SCRIPT - 'Title' field in Manuskript" +author: "by Gordon Grant-Stuart" +author_lastname: "Grant-Stuart" +contact_name: "Gordon Grant-Stuart" +contact_address: "42 Parkway" +contact_city_state_zip: "Camberley, GU15 2PE, UK" +contact_phone: "(+44) 07462 129908" +contact_email: "gordon@grant-stuart.com" +--- diff --git a/.Books/history b/.Books/history new file mode 100644 index 0000000..c908aa1 --- /dev/null +++ b/.Books/history @@ -0,0 +1,5 @@ +download +upload +compile +atmo +wryte diff --git a/.Books/load.sh b/.Books/load.sh new file mode 100755 index 0000000..06ef99d --- /dev/null +++ b/.Books/load.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) + +[[ ! -e $SCRIPT_DIR/.Books/initted ]] && $SCRIPT_DIR/init.sh +[[ ! -e $SCRIPT_DIR/backgrounds ]] && ln -s "$SCRIPT_DIR/.Books/backgrounds" "$SCRIPT_DIR/backgrounds" + +cd $SCRIPT_DIR && git pull +mv -f $SCRIPT_DIR/*.msk $SCRIPT_DIR/.Books/backup/ + +for dir in $SCRIPT_DIR/.Books/unpacked/*; do + TITLE=${dir##*/} + cd "$SCRIPT_DIR/.Books/unpacked/$TITLE" && zip -qu -9 -r "$SCRIPT_DIR/$TITLE.msk" * +done diff --git a/.Books/local.d/readme b/.Books/local.d/readme new file mode 100644 index 0000000..54541e0 --- /dev/null +++ b/.Books/local.d/readme @@ -0,0 +1 @@ +This folder is for storing local scripts that don't get synced diff --git a/.Books/rollback.sh b/.Books/rollback.sh new file mode 100755 index 0000000..6b2a57a --- /dev/null +++ b/.Books/rollback.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +# check args +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +if [[ $# -eq 2 && -e $1 && $2 =~ [0-9]+ ]]; then + # ls -1 /tmp/manuskriptbackups/ | wc -l + rollto=$(find /tmp/manuskriptbackups/ -name "*$1.*" -cmin +$2 | sort | tail -n1) + if [[ -n $rollto ]]; then + if [[ `pgrep -f "manuskript $1"` ]]; then + echo $1 is still open in Manuskript + else + mv $BOOK_DIR/$1 $BOOK_DIR/$1.$(date +"%Y-%m-%d_%H:%M:%S") + mv $rollto $BOOK_DIR/$1 + echo $1 rolled back to $rollto + fi + else + echo There is no backup of $1 from more than $2 minutes ago. + fi +else + echo + echo "USAGE : rollback FILE N" + echo + echo " FILE : .msk file" + echo " N : minutes to roll back" + echo +fi diff --git a/.Books/save.sh b/.Books/save.sh new file mode 100755 index 0000000..236b137 --- /dev/null +++ b/.Books/save.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) + +for msk in *.msk; do + TITLE="${msk%.msk}" + rm -rf "$SCRIPT_DIR/.Books/unpacked/$TITLE" + unzip -qou "$msk" -d "$SCRIPT_DIR/.Books/unpacked/$TITLE" +done + +cd $SCRIPT_DIR && git add . +git commit -m "Saved at $(date)" +git push diff --git a/.Books/themes/atmo.theme b/.Books/themes/atmo.theme new file mode 100644 index 0000000..93c33ee --- /dev/null +++ b/.Books/themes/atmo.theme @@ -0,0 +1,40 @@ +[General] +Name=Atmosphere + +[Background] +Color=#000000 +ImageFile=atmo.jpg +Type=3 + +[Foreground] +Color=#ffffff +Margin=40 +Opacity=85 +Padding=20 +Position=1 +Rounding=8 +RoundingDisabled=0 +Width=650 + +[ForegroundBlur] +Enabled=true +Radius=32 + +[ForegroundShadow] +Color=#000000 +Enabled=true +Offset=2 +Radius=16 + +[Spacings] +Alignment=0 +IndentFirstLine=true +LineSpacing=150 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#2e3436 +Font="DejaVu Serif,14,-1,5,50,0,0,0,0,0" +Misspelled=#ff0000 diff --git a/.Books/themes/gentleblues.theme b/.Books/themes/gentleblues.theme new file mode 100644 index 0000000..0de7584 --- /dev/null +++ b/.Books/themes/gentleblues.theme @@ -0,0 +1,40 @@ +[General] +LoadColor=#a8bacc +Name="Gentle Blues" + +[Background] +Color=#a8bacc +ImageFile= +Type=0 + +[Foreground] +Color=#a8bacc +Margin=65 +Opacity=0 +Padding=10 +Position=1 +Rounding=0 +RoundingDisabled=10 +Width=700 + +[ForegroundBlur] +Enabled=false +Radius=32 + +[ForegroundShadow] +Color=#000000 +Enabled=false +Offset=2 +Radius=8 + +[Spacings] +IndentFirstLine=false +LineSpacing=100 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#2d3f56 +Font="Times New Roman,12,-1,5,50,0,0,0,0,0" +Misspelled=#ff0000 diff --git a/.Books/themes/oldschool.theme b/.Books/themes/oldschool.theme new file mode 100644 index 0000000..e7427a0 --- /dev/null +++ b/.Books/themes/oldschool.theme @@ -0,0 +1,39 @@ +[General] +LoadColor=#000000 + +[Background] +Color=#000000 +ImageFile= +Type=0 + +[Foreground] +Color=#000000 +Margin=65 +Opacity=0 +Padding=10 +Position=1 +Rounding=0 +RoundingDisabled=10 +Width=700 + +[ForegroundBlur] +Enabled=false +Radius=32 + +[ForegroundShadow] +Color=#000000 +Enabled=false +Offset=2 +Radius=8 + +[Spacings] +IndentFirstLine=false +LineSpacing=100 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#0cf155 +Font="Courier New,12,-1,5,50,0,0,0,0,0" +Misspelled=#0d5322 diff --git a/.Books/themes/preview.txt b/.Books/themes/preview.txt new file mode 100644 index 0000000..a7c9a99 --- /dev/null +++ b/.Books/themes/preview.txt @@ -0,0 +1,37 @@ +The regular early morning yell of horror was the sound of Arthur Dent waking up and suddenly remembering where he was. +It wasn't just that the cave was cold, it wasn't just that it was damp and smelly. It was the fact that the cave was in the middle of Islington and there wasn't a bus due for two million years. +Time is the worst place, so to speak, to get lost in, as Arthur Dent could testify, having been lost in both time and space a good deal. At least being lost in space kept you busy. +He was stranded in prehistoric Earth as the result of a complex sequence of events which had involved him being alternately blown up and insulted in more bizarre regions of the Galaxy than he ever dreamt existed, and though his life had now turned very, very, very quiet, he was still feeling jumpy. +He hadn't been blown up now for five years. +Since he had hardly seen anyone since he and Ford Prefect had parted company four years previously, he hadn't been insulted in all that time either. +Except just once. +It had happened on a spring evening about two years previously. +He was returning to his cave just a little after dusk when he became aware of lights flashing eerily through the clouds. He turned and stared, with hope suddenly clambering through his heart. Rescue. Escape. The castaway's impossible dream --- a ship. +And as he watched, as he stared in wonder and excitement, a long silver ship descended through the warm evening air, quietly, without fuss, its long legs unlocking in a smooth ballet of technology. +It alighted gently on the ground, and what little hum it had generated died away, as if lulled by the evening calm. +A ramp extended itself. +Light streamed out. +A tall figure appeared silhouetted in the hatchway. It walked down the ramp and stood in front of Arthur. +"You're a jerk, Dent," it said simply. +It was alien, very alien. It had a peculiar alien tallness, a peculiar alien flattened head, peculiar slitty little alien eyes, extravagantly draped golden ropes with a peculiarly alien collar design, and pale grey-green alien skin which had about it that lustrous shine which most grey-green faces can only acquire with plenty of exercise and very expensive soap. +Arthur boggled at it. +It gazed levelly at him. +Arthur's first sensations of hope and trepidation had instantly been overwhelmed by astonishment, and all sorts of thoughts were battling for the use of his vocal chords at this moment. +"Whh ...?" he said. +"Bu ... hu ... uh ..." he added. +"Ru ... ra ... wah ... who?" he managed finally to say and lapsed into a frantic kind of silence. He was feeling the effects of having not said anything to anybody for as long as he could remember. +The alien creature frowned briefly and consulted what appeared to be some species of clipboard which he was holding in his thin and spindly alien hand. +"Arthur Dent?" it said. +Arthur nodded helplessly. +"Arthur Philip Dent?" pursued the alien in a kind of efficient yap. +"Er ... er ... yes ... er ... er," confirmed Arthur. +"You're a jerk," repeated the alien, "a complete asshole." +"Er ..." +The creature nodded to itself, made a peculiar alien tick on its clipboard and turned briskly back towards the ship. +"Er ..." said Arthur desperately, "er ..." +"Don't give me that!" snapped the alien. It marched up the ramp, through the hatchway and disappeared into the ship. The ship sealed itself. It started to make a low throbbing hum. +"Er, hey!" shouted Arthur, and started to run helplessly towards it. +"Wait a minute!" he called. "What is this? What? Wait a minute!" +The ship rose, as if shedding its weight like a cloak to the ground, and hovered briefly. It swept strangely up into the evening sky. It passed up through the clouds, illuminating them briefly, and then was gone, leaving Arthur alone in an immensity of land dancing a helplessly tiny little dance. +"What?" he screamed. "What? What? Hey, what? Come back here and say that!" +He jumped and danced until his legs trembled, and shouted till his lungs rasped. There was no answer from anyone. There was no one to hear him or speak to him. diff --git a/.Books/themes/spacedreams.theme b/.Books/themes/spacedreams.theme new file mode 100644 index 0000000..61ba90b --- /dev/null +++ b/.Books/themes/spacedreams.theme @@ -0,0 +1,39 @@ +[General] +LoadColor=#5d3e3d + +[Background] +Color=#000000 +ImageFile=spacedreams.jpg +Type=5 + +[Foreground] +Color=#beaf9b +Margin=65 +Opacity=50 +Padding=10 +Position=1 +Rounding=10 +RoundingDisabled=0 +Width=700 + +[ForegroundBlur] +Enabled=true +Radius=32 + +[ForegroundShadow] +Color=#000000 +Enabled=true +Offset=2 +Radius=16 + +[Spacings] +IndentFirstLine=false +LineSpacing=100 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#000000 +Font="Times New Roman,12,-1,5,50,0,0,0,0,0" +Misspelled=#ff0000 diff --git a/.Books/themes/weilong.theme b/.Books/themes/weilong.theme new file mode 100644 index 0000000..a25f070 --- /dev/null +++ b/.Books/themes/weilong.theme @@ -0,0 +1,29 @@ +[General] +Name=Wei Long + +[Background] +Color=#000000 +ImageFile=kowloon3.jpg +Type=3 + +[Foreground] +Color=#ffffff +Margin=40 +Opacity=75 +Padding=10 +Position=1 +Rounding=5 +Width=900 + +[Spacings] +Alignment=0 +IndentFirstLine=true +LineSpacing=150 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#2e3436 +Font="DejaVu Serif,14,-1,5,50,0,0,0,0,0" +Misspelled=#ff0000 diff --git a/.Books/themes/writingdesk.theme b/.Books/themes/writingdesk.theme new file mode 100644 index 0000000..f13faca --- /dev/null +++ b/.Books/themes/writingdesk.theme @@ -0,0 +1,39 @@ +[General] +LoadColor=#985a20 + +[Background] +Color=#985a20 +ImageFile=writingdesk.jpg +Type=5 + +[Foreground] +Color=#fffdf6 +Margin=65 +Opacity=100 +Padding=10 +Position=1 +Rounding=0 +RoundingDisabled=10 +Width=700 + +[ForegroundBlur] +Enabled=false +Radius=32 + +[ForegroundShadow] +Color=#000000 +Enabled=true +Offset=1 +Radius=4 + +[Spacings] +IndentFirstLine=false +LineSpacing=100 +ParagraphAbove=0 +ParagraphBelow=0 +TabWidth=48 + +[Text] +Color=#000000 +Font="Times New Roman,12,-1,5,50,0,0,0,0,0" +Misspelled=#ff0000 diff --git a/.Books/upload.sh b/.Books/upload.sh new file mode 100755 index 0000000..b7bc876 --- /dev/null +++ b/.Books/upload.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +cd $BOOK_DIR && git add . +git commit -m "Saved at $(date) from $(hostname)" +git push #&& find /tmp/manuskriptbackups/ -cmin +60 | xargs -I% rm -f % + +if [[ -e "$SCRIPT_DIR/local.d/postupload.sh" ]]; then + $SCRIPT_DIR/local.d/postupload.sh +fi diff --git a/.Books/watchy.sh b/.Books/watchy.sh new file mode 100755 index 0000000..7d99c33 --- /dev/null +++ b/.Books/watchy.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) +BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +# PERIOD=10 + +mds() { + md5sum "$1" | awk '{print $1}' +} + +savey() { + newhash=$(mds "$1") + if [[ ! $newhash == $hash ]]; then + cp "$1" "/tmp/manuskriptbackups/$1.$(date +"%Y-%m-%d_%H:%M:%S")" + hash=$newhash + fi +} + + +while [[ ! `pgrep -f "manuskript $1"` ]]; do + sleep 0.5 +done +notify-send "Making backups of $1 every $PERIOD seconds." +tick=1 +hash=$(mds "$1") +while [[ `pgrep -f "manuskript $1"` ]]; do + sleep 1 + if [[ $tick -ge $PERIOD ]]; then + savey "$1" + tick=0 + fi + tick=$(( $tick + 1 )) +done +notify-send "No longer making backups of $1." +rm -f $BOOK_DIR/nohup.out diff --git a/.Books/write.sh b/.Books/write.sh new file mode 100755 index 0000000..01b3e17 --- /dev/null +++ b/.Books/write.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +# SCRIPT_DIR=$(dirname $(realpath $0)) +# BOOK_DIR=${SCRIPT_DIR/\/.Books/} + +# PERIOD=10 + +# bronch() { +# screen -d -m nohup $MANUSKRIPT_BIN "$1" & +# screen -d -m nohup $SCRIPT_DIR/branchy.sh "$1" & +# } + +# worch() { +# screen -d -m nohup $MANUSKRIPT_BIN "$1" & +# screen -d -m nohup $SCRIPT_DIR/watchy.sh "$1" & +# } + +# if [[ -f "$1" && -d "${1/.msk/}" ]]; then +# bronch "$1" +# elif [[ -d "$1" && -f "$1.msk" ]]; then +# bronch "$1.msk" +# fi + +# if [[ -e "$1" && $(cat $1 | wc -c) -gt 10 ]]; then +# bronch "$1" +# else +# screen -d -m nohup $MANUSKRIPT_BIN & +# fi + +screen -d -m nohup $MANUSKRIPT_BIN &>/dev/null & \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a726589 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +# Manuskript files. +#*.msk + +# Compiled Outputs +*.docx +*.epub + +# Standard archive formats +*.7z +*.jar +*.rar +*.zip +*.gz +*.gzip +*.tgz +*.bzip +*.bzip2 +*.bz2 +*.xz +*.lzma +*.cab +*.xar + +# Specific files and folders +/.Books/manuskript/ +/.Books/pandoc-templates/ +/.Books/initted +/.Books/local.d/*.sh +/backgrounds +/manuskript +nohup.out diff --git a/Sandersons3Laws.md b/Sandersons3Laws.md new file mode 100644 index 0000000..cf0aa2c --- /dev/null +++ b/Sandersons3Laws.md @@ -0,0 +1,11 @@ +##Sanderson's First Law: +An author's ability to solve conflict with magic is *directly proportional* to how well the reader understands said magic. +Mysterious magic systems can only *cause* problems + +##Sanderson's Second Law: Limitations > Power +The limitations of a magic system are more interesting than its capabilities. What the magic can't do is more interesting than what it can. + +##Sanderson's Third Law: Expand on what you have already, before you add something new. +A brilliant magic system for a book is less often one with a thousand different powers and abilities -- and is more often a magic system with relatively few powers that the author has considered in depth. + +###Sanderson's Zeroth Law: Err on the side of ***awesome***. diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..0f5d732 --- /dev/null +++ b/init.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +SCRIPT_DIR=$(dirname $(realpath $0)) + +lightbrown="\033[1;38;5;94m" +darkbrown="\033[38;5;95m" + +echo -e "$lightbrown 📚 running the Books! init script 📚 $darkbrown" + +al="alias Books=\". $HOME/.Books/booksenv.sh $SCRIPT_DIR\"" +if [[ $(grep -c "$al" ~/.bash_aliases) -eq 0 ]]; then + echo $al >> ~/.bash_aliases +fi + +if [[ $(grep -c "msk=1;38;5;95" ~/.bash_aliases) -eq 0 ]]; then + echo 'export LS_COLORS="$LS_COLORS:*.msk=1;38;5;95"' >> ~/.bash_aliases +fi + +mv "$SCRIPT_DIR/.Books" "$HOME/.Books" +rm -rf $SCRIPT_DIR/.git # Get rid of the Books git project, create a new one for YOUR writing + +########## Install screen, git & pandoc ############# + +if type yum &>/dev/null; then + pac='yum' +elif type apt &>/dev/null; then + pac='apt' +else + echo -e "$darkbrown You're Linuxing wrong." + exit +fi + +for i in git screen pandoc; do + type $i &>/dev/null || echo -e "$darkbrown Installing $i" && sudo $pac install -y $i +done + + +########## Install manuskript ############### + +function reresource() { + rm -rf "$HOME/.Books/manuskript/resources/$1" + ln -s "$HOME/.Books/$1" "$HOME/.Books/manuskript/resources/$1" +} + +cd $HOME/.Books && git clone https://github.com/olivierkes/manuskript.git +if [[ $? -ne 0 ]]; then + cd $HOME/.Books/manuskript && git pull +fi + +rm -rf "$HOME/.Books/manuskript/sample-projects" +reresource themes +reresource backgrounds +reresource dictionaries +rm $SCRIPT_DIR/backgrounds +ln -s "$HOME/.Books/backgrounds" "$SCRIPT_DIR/backgrounds" +# ln -s "$HOME/.Books/manuskript/bin/manuskript" "$SCRIPT_DIR/manuskript" + + +################# Install Prosegrinder pandoc templates ############ + +echo -e "$darkbrown Installing Pandoc Templates" +cd $HOME/.Books && git clone https://github.com/prosegrinder/pandoc-templates.git +if [[ $? -ne 0 ]]; then + cd $HOME/.Books/pandoc-templates && git pull +fi + +################# Install LanguageTool ############ + +# if type "languagetool" &>/dev/null; then +# fi +echo -e "$darkbrown Installing LanguageTool" +sudo snap install languagetool + +# if pip show language_tool_python &>/dev/null; then +# fi +echo -e "$darkbrown Installing LanguageTool Python" +sudo pip install language_tool_python + +################# Install viu ############ + +if [[ ! -e "$HOME/.Books/viu" ]]; then + curl -o "$HOME/.Books/viu" "https://github.com/atanunq/viu/releases/download/v1.4.0/viu" && chmod +x "$HOME/.Books/viu" +fi + + + +# cd $HOME/.Books + +##################### Add the password to the git config +cd $SCRIPT_DIR + +if [[ ! -d "$SCRIPT_DIR/.git" ]]; then + git init +fi + + +rou=$(git config --get remote.origin.url | sed 's$https://$$g') +if [[ $(echo $rou | egrep -c [^:]*:[^@]*@ ) -eq 0 ]]; then + echo -e '\n*******************************************************\n' + echo -n 'Enter the git username: ' + read username + echo -n "Enter the git password for $username: " + stty -echo + read password + stty echo + newurl="https://$username:$password@$rou" + git config --replace-all remote.origin.url "$newurl" + echo + #sed -i "s/https:\/\/git.grant-stuart.com/https:\/\/gordon:$answer@git.grant-stuart.com/g; s/https:\/\/git.grant-stuart.com/\&/g" $SCRIPT_DIR/.git/config +fi + +# sed -i "s%WIBBLE%$SCRIPT_DIR%g" $HOME/.Books/booksenv.sh +touch $HOME/.Books/initted