dot

packages and services management
Log | Files | Refs | README

commit ba8068f2ce56d291cf0a90eafe68b1f3c869ea1b
parent 2de1648660a030ee91efe563d5970aaf6d26cab6
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 26 Mar 2018 23:21:23 +0200

preparing u9fs

Diffstat:
M.profile | 3++-
Mbin/pack | 4++--
Abin/www | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mbin/xdg-abduco | 4+++-
Mbin/xdg-open | 140++++++++++++++++---------------------------------------------------------------
Dbin/xdg-ssh | 105-------------------------------------------------------------------------------
Dbin/xdg-store | 64----------------------------------------------------------------
Mconfigure | 10+++++-----
Apack/libixp/build | 2++
Mrunit/u9fs/run | 5+++--
10 files changed, 132 insertions(+), 292 deletions(-)

diff --git a/.profile b/.profile @@ -57,4 +57,5 @@ export SVDIR="$HOME/run" export TERM="screen" export PS1='$([ $? -gt 0 ] && printf "\\033[31;1mx\\033[m\\n\\r")'"$( [ "$(whoami)" = "root" ] && s='#' || s='$' - printf '\033]0;$PWD\a\n%s%s ' "$(uname -n)" "$s")" + printf '\033]0;$PWD\a\n%s%s ' "$(uname -n)" "$s" +)" diff --git a/bin/pack b/bin/pack @@ -55,8 +55,8 @@ case "$1" in cd "$PREFIX" exec find * -type d \ - -exec sh -c 'mkdir -p "$PACKROOT/$0"' {} \; -o \ - -exec sh -c 'ln -sf "$PREFIX/$0" "$PACKROOT/$0"' {} \; + -exec sh -c 'mkdir -p "$PACKROOT/$0"' {} \; -o \ + -exec sh -c 'ln -sf "$PREFIX/$0" "$PACKROOT/$0"' {} \; ;; (del) rm -rf "$PREFIX" diff --git a/bin/www b/bin/www @@ -0,0 +1,87 @@ +#!/bin/sh + +# static website generator for one particular website + +cd "$(dirname "$0")" + +export LAYOUT="$(cat layout.html)" || exit 1 +export ROOT="$PWD" + +parse() +{ #1 content of the layout to parse + + # print the input up to the next keyword, and shift position in input + printf %s "${1%%<%*}" + + # check for remaining keywords + [ "${1##*<%*}" ] && return 0 + + # take the separator out of the keyword + set -- "${1#*<%}" + + # execute the keyword action and print its output + case "${1%%%>*}" in + (*content*) printf %s "$(sed 1d index.txt)" ;; + (*gallery*) printf %s "$(gallery)" ;; + (*cover* ) printf %s "$(cover)" ;; + (*title*) printf %s "$(sed 1q index.txt)" ;; + (*root*) printf %s "$(root)" ;; + (*nav*) printf %s "$(nav)" ;; + (*sitemap*) printf %s "$(sitemap)" ;; + esac + + parse "${1#*%>}" +} + +gallery() +{ + ls -d *.[jJ][pP][gG] \ + *.[jJ][pP][eE][gG] \ + *.[pP][nN][gG] \ + 2>/dev/null | while IFS='' read -r img + do + printf '<a class="gallery" href="%s">\n' "$img" + printf '\t<img src="%s"></img>\n' "$img" + printf '</a>\n' + done +} + +root() +{ + printf '%s\n' "${PWD#$ROOT}" | + sed 's|[^/]||g; s|.|../|g; s|/$||; s|^$|.|' +} + +nav() +{ + ls -d */*/index.txt | while IFS='' read -r index + do + cat << EOF +<a class="nav" href="${index%.txt}.html"> + <span>$(sed q "$index")</span> + <img src="$( + ls -d "${index%/*}"/*.[jJ][pP][gG] \ + "${index%/*}"/*.[jJ][pP][eE][gG] \ + "${index%/*}"/*.[pP][nN][gG] \ + 2>/dev/null | sed q + )"></img> +</a> +EOF + done +} + +sitemap() +{ + tree=${PWD#$ROOT} root=$(root) sep='' + + while [ "$tree" ] + do + tree="${tree%/*}" + printf '<a href="%s%s/index.html">%s</a>%s\n' \ + "$root" "$tree" "$(sed q "$root/$tree/index.txt")" "$sep" + sep=' >' + done +} + +find . -name 'index.txt' \ + -exec sh 'cd "$0/.." && parse "$LAYOUT" > index.html' {} \; diff --git a/bin/xdg-abduco b/bin/xdg-abduco @@ -2,7 +2,9 @@ # wrapper over abduco for supporting any length session names -# usage: xdg-abduco <command> <long-name> +# usage: xdg-abduco <command> <path> + +exec 2>"$HOME/out" [ "$ABDUCO_SOCKET_DIR" ] && dir="$ABDUCO_SOCKET_DIR/abduco/$USER" || diff --git a/bin/xdg-open b/bin/xdg-open @@ -1,83 +1,28 @@ #!/bin/sh -# override the xdg-open utility - -[ "$DISPLAY" ] && case "$(tty)" in -(/dev/pts/*|/dev/ttyp*) - ;; -(*) - exec st -f terminus:pixelsize=16 -e xdg-open "$@" - ;; -esac - -[ "$ABDUCO" ] || exec xdg-abduco xdg-open "$@" +# open the resource given as argument according to its content # [scheme://][user[:pass]@]host[:port][/path] IFS=' ' read scheme user pass host port path << EOF -$(awk -v URI="$1" ' -BEGIN { - gsub(" ", "%20", URI); - gsub("\t", "%0b", URI); - - scheme = URI; - if (sub("^[^:/]*://", "", URI) > 0) - sub("://.*", "", scheme); - else - scheme = "."; - - user = URI; - if (sub("^[^@/]*@", "", URI) > 0) - sub("@.*", "", user); - else - user = "."; - - pass = user; - if (sub(":.*", "", user) > 0) - sub("[^:]*:", "", pass) ; - else - pass = "."; - - host = URI - if (sub("^[^:]*:", ":", URI) > 0) - sub(":.*", "", host); - else if (sub("[^/]*/", "/", URI) > 0) - sub("/.*", "", host); - - port = URI - if (sub("^:[0-9]+:", "", URI) > 0 || sub("^:[0-9]+/", "/", URI) > 0) { - sub(":", "", port); - sub("[:/].*", "", port); - } else if (sub("^:[0-9]+$", "", URI) > 0) { - sub(":", "", port); - } else { - port = "."; - } - - path = URI; - if (match(path, "^/") == 0) - path = ""; - sub("[#?].*", "", path); - - printf("%s\t%s\t%s\t%s\t%s\t%s", scheme, user, pass, host, port, path); -}') +$(xdg-uri "$1") EOF -case "$scheme" in -(ssh) - [ "$port" = . ] && port="" || port="-P $port" - [ "$user" = . ] && user="" || user="$user@" - [ "$pass" = . ] && pass="" || pass="$" +[ "$ABDUCO" ] || exec xdg-abduco "$0" "$@" + +case "$(tty)" in +(/dev/pts/*|/dev/ttyp*) + ;; +(*) + [ "$DISPLAY" ] && exec st -f terminus:pixelsize=16 -e "$0" "$@" ;; esac case "$host" in (*.onion) - [ "$TOR" ] || TOR="$1" exec torsocks xdg-open "$1" + [ "$TOR" ] || TOR="$1" exec torsocks "$0" "$1" ;; esac -file="" - case "$path" in (*.torrent) file="$HOME/var/torrent/${path##*/}" @@ -100,19 +45,13 @@ case "$path" in (*.tar|*.gz|*.bz2|*.xz|*.tgz|*.tgz|*.tbz2|*.txz|*.zip|*.rar) file="$HOME/tmp/${path##*/}" ;; +(*) + file="" + ;; esac [ "$file" ] && mkdir -p "$(dirname "$file")" -case "$(uname)" in -(Linux) - play="aplay -f cd" - ;; -(*BSD) - play="aucat -r 44100 -i -" - ;; -esac - case "$1" in (git://*) user="" @@ -121,14 +60,13 @@ case "$1" in user="$(dirname "$path")" ;; esac - mkdir -p "$HOME/git/$host/$user" cd "$HOME/git/$host/$user" exec git clone "$1" ;; (magnet:*) transmission-cli "$1" - exec xdg-open "$file" + exec "$0" "$file" ;; (9p://*) dir="$HOME/var/9p/$host" @@ -140,7 +78,7 @@ case "$1" in then mkdir "$(dirname "$file")" curl -o "$file" "$1" - exec xdg-open "$file" + exec "$0" "$file" else exec ftp "$1" fi @@ -155,20 +93,20 @@ case "$1" in cd "$HOME/lib/video/$host" file="$PWD/$(youtube-dl --get-filename "$1")" youtube-dl "$1" - exec xdg-open "$file" + exec "$0" "$file" ;; (*bandcamp.com*) mkdir -p "$HOME/lib/music/$host" cd "$HOME/lib/music/$host" file="$PWD/$(youtube-dl --get-filename "$1")" youtube-dl "$1" - exec xdg-open "$file" + exec "$0" "$file" ;; (*) if [ "$file" ] then curl -o "$file" "$1" - exec xdg-open "$file" + exec "$0" "$file" else exec firefox "$1" fi @@ -190,31 +128,10 @@ case "$1" in [ "$port" = . ] && port='22' exec sftp -P "$port" "$host" ;; -(ssh://*/*.pdf) - ssh $port "$user$host" xz -c - "$path" | xz -d - | mupdf /dev/stdin & - exit ;; -(ssh://*/*.ff) - ssh $port "$user$host" xz -c - "$path" | xz -d - | lel - exit ;; -(ssh://*/*.png|ssh://*/*.PNG) - ssh $port "$user$host" png2ff '<' "$path"| xz -c -" | xz -d - | lel - exit ;; -(ssh://*/*.jpg|ssh://*/*.jpeg|ssh://*/*.JPG|ssh://*/*.JPEG) - ssh $port "$user$host" jpg2ff '<' "$path" | xz -c -" | xz -d - | lel - exit ;; -(ssh://*/*.opus|ssh://*/*.flac|ssh://*/*.ogg|ssh://*/*.vorbis|ssh://*/*.wav) - ssh $port "$user$host" "opusenc '$path' -" #| ffplay - - exit ;; -(ssh://*/*.webm|ssh://*/*.mp4|ssh://*/*.mkv|ssh://*/*.ogv|ssh://*/*.avi) - ssh $port "$user$host" cat "$path" | ffplay - - exit ;; -(ssh://*/*.[0-9]|ssh://*/*.[0-9]p|ssh://*/ssh://*/*.[0-9].gz) - ssh $port "$user$host" mandoc -T utf8 "$path" | less - exit ;; -(ssh://*/*) - exec ssh $port "$user$host" "\$EDITOR '$path'" - ;; (ssh://*) + [ "$port" = . ] && port="" || port="-P $port" + [ "$user" = . ] && user="" || user="$user@" + [ "$pass" = . ] && pass="" || pass="$" exec ssh $port "$user$host" ;; (telnet://*) @@ -260,34 +177,34 @@ case "$1" in exec mandoc -a -T utf8 "$1" ;; (*.o|*.a) - exec radare2 "$1" + exec objdump -D "$1" ;; (*.html) exec firefox "$1" ;; (*.tgz) mv "$1" "${1%.tgz}.tar.gz" - exec xdg-open "${1%.tgz}.tar.gz" + exec "$0" "${1%.tgz}.tar.gz" ;; (*.tbz) mv "$1" "${1%.tbz}.tar.bz2" - exec xdg-open "${1%.tbz}.tar.bz2" + exec "$0" "${1%.tbz}.tar.bz2" ;; (*.txz) mv "$1" "${1%.txz}.tar.xz" - exec xdg-open "${1%.txz}.tar.xz" + exec "$0" "${1%.txz}.tar.xz" ;; (*.bz2) bzip2 -ds "$1" - exec xdg-open "${1%.bz2}" + exec "$0" "${1%.bz2}" ;; (*.gz) gzip -d "$1" - exec xdg-open "${1%.gz}" + exec "$0" "${1%.gz}" ;; (*.xz) xz -d "$1" - exec xdg-open "${1%.xz}" + exec "$0" "${1%.xz}" ;; (*.tar) exec tar -xf "$1" @@ -311,5 +228,4 @@ case "$1" in [ -f "$1" ] && exec $EDITOR "$1" [ -d "$1" ] && cd "$1" && exec "$SHELL" ;; - esac diff --git a/bin/xdg-ssh b/bin/xdg-ssh @@ -1,105 +0,0 @@ -#!/bin/sh -e - -# get content from remote or locally the same way - -# [scheme://][user[:pass]@]host[:port][/path] -IFS=' ' read scheme user pass host port path << EOF -$(xdg-uri "$1") -EOF - -[ "$port" = . ] && port="" -[ "$user" = . ] && user="" || user="$user@" -[ -d "$1" ] && path="$path/" - -[ "$port" = . ] && ssh="ssh -P $port $host" || ssh="ssh $host" -ssht="$ssh -t . ./.profile;" -ssh="$ssh . ./.profile;" - -case "$path" in -(*.pdf) - $ssh "xz -c - '$path'" | xz -d - | mupdf /dev/stdin & - exit ;; -(*.ff) - $ssh "xz -c - '$path'" | xz -d - | lel - exit ;; -(*.png|*.PNG) - $ssh "png2ff < '$path' | xz -c -" | xz -d - | lel - exit ;; -(*.jpg|*.jpeg|*.JPG|*.JPEG) - $ssh "jpg2ff < '$path' | xz -c -" | xz -d - | lel - exit ;; -(*.gif) - $ssh "xz -c - '$path'" ffplay -loop 0 "$path" - exit ;; -(*.opus|*.flac|*.ogg|*.vorbis|*.wav) - $ssh "opusenc '$path' -" | ffplay - - exit ;; -(*.webm|*.mp4|*.mkv|*.ogv|*.avi) - $ssh "xz -c - '$path'" | xz -d - | ffplay - - exit ;; -(*.[0-9]|*.[0-9]p|*/[0-9].gz) - $ssh mandoc -T utf8 "$path" | less - exit ;; -(*.torrent) - exec $ssh transmission-cli "$path" - ;; -(*/music/*) - $ssh "find '$path' -type f | sort" | while IFS='' read -r song - do xdg-ssh "$host" "$song" - done - exit ;; -(*.o|*.a) - $ssh "exec objdump -D '$path'" | less - exit ;; -(*.tgz) - $ssh "exec mv '$path' '${path%.tgz}.tar.gz'" - exec xdg-ssh "${path%.tgz}.tar.gz" - ;; -(*.tbz) - $ssh "exec mv '$path' '${path%.tbz}.tar.bz2'" - exec xdg-ssh "$host" "${path%.tbz}.tar.bz2" - ;; -(*.txz) - $ssh "exec mv '$path' '${path%.txz}.tar.xz'" - exec xdg-ssh "$host" "${path%.txz}.tar.xz" - ;; -(*.bz2) - $ssh "exec bzip2 -ds '$path'" - exec xdg-ssh "${path%.bz2}" - ;; -(*.gz) - $ssh "exec gzip -d '$path'" - exec xdg-ssh "${path%.gz}" - ;; -(*.xz) - $ssh "exec xz -d '$path'" - exec xdg-ssh "${path%.xz}" - ;; -(*.tar) - exec $ssh "exec tar -xf '$path'" - ;; -(*.rar) - exec $ssh "exec unrar x '$path'" - ;; -(*.zip) - exec $ssh "exec unzip '$path'" - ;; -(*.Z) - exec $ssh "exec uncompress '$path'" - ;; -(*.7z) - exec $ssh "exec 7z x '$path'" - ;; -(*.deb) - exec $ssh "exec ar vx '$path'" - ;; -('') - exec $ssh - ;; -(*/) - exec $ssht "cd '$path' && exec '$SHELL'" - ;; -(*) - exec $ssht "exec $EDITOR '$path'" - ;; -esac diff --git a/bin/xdg-store b/bin/xdg-store @@ -1,64 +0,0 @@ -#!/bin/sh -e - -# get resource from remote and store them - -# usage: xdg-store <uri> - -path="" - -[ "$ABDUCO" ] || exec xdg-abduco xdg-open "$1" - -# [scheme://][user[:pass]@]host[:port][/path] -IFS=' ' read scheme user pass host port path << EOF -$(xdg-uri "$1") -EOF - -# [scheme://][user[:pass]@]host[:port][/path] -IFS=' ' read scheme user pass host port path << EOF -$(xdg-uri "$1") -EOF - -case "$1" in (*.onion/*) [ "$TOR" ] || TOR="$1" exec torsocks "$0" "$1" ;; esac - -case "$1" in -(*vimeo.com*|*youtube.com*|*youtu.be*|*openload.co*) - mkdir -p "$HOME/lib/video/$host" - cd "$HOME/lib/video/$host" - path="$PWD/$(youtube-dl --get-filename "$1")" - youtube-dl "$1" - ;; -(*bandcamp.com*) - mkdir -p "$HOME/lib/music/$host" - cd "$HOME/lib/music/$host" - path="$PWD/$(youtube-dl --get-filename "$1")" - youtube-dl "$1" - ;; -(*.torrent) - path="$HOME/var/torrent/${path##*/}" - ;; -(*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.gif|*.GIF) - path="$HOME/lib/image/$host/${path##*/}" - ;; -(*.opus|*.ogg|*.mp3|*.flac) - path="$HOME/lib/music/$host/${path##*/}" - ;; -(*.webm|*.mp4|*.mkv|*.ogv|*.avi) - path="$HOME/lib/video/$host/${path##*/}" - ;; -(*.pdf|*.ps) - path="$HOME/lib/doc/$host/${path##*/}" - ;; -(*.txt) - path="$HOME/lib/text/$host/${path##*/}" - ;; -(*.tar|*.gz|*.bz2|*.xz|*.tgz|*.tgz|*.tbz2|*.txz|*.zip|*.rar) - path="$HOME/tmp/${path##*/}" - ;; -esac - -[ "$path" ] || exit - -mkdir -p "$(dirname "$path")" -curl -o "$path" "$1" - -printf '%s\n' "$path" diff --git a/configure b/configure @@ -14,17 +14,17 @@ find * \ -path './configure' -prune -o \ -path './man/*' -prune -o \ -path './runit/*' -prune -o \ - -type d -exec sh -c "$mkdir" "$HOME/.config" {} ';' -o \ - -type f -exec sh -c "$symln" "$HOME/.config" {} ';' + -type d -exec sh -c "$mkdir" "$HOME/.config" {} \; -o \ + -type f -exec sh -c "$symln" "$HOME/.config" {} \; # symlink ./.* into ~/.* find .* \ -name '.git' -prune -o \ -path './.' -prune -o \ -path './..' -prune -o \ - -type d -exec sh -c "$mkdir" "$HOME" {} ';' -o \ - -type f -exec sh -c "$symln" "$HOME" {} ';' -o \ - -type l -exec sh -c "$symln" "$HOME" {} ';' + -type d -exec sh -c "$mkdir" "$HOME" {} \; -o \ + -type f -exec sh -c "$symln" "$HOME" {} \; -o \ + -type l -exec sh -c "$symln" "$HOME" {} \; find -L "$HOME" -type l -exec rm {} + diff --git a/pack/libixp/build b/pack/libixp/build @@ -0,0 +1 @@ +../build/gmake+ \ No newline at end of file diff --git a/runit/u9fs/run b/runit/u9fs/run @@ -1,7 +1,8 @@ #!/bin/sh -e port="564" -path="$HOME/lib/music" +path="/usr/ufs1" -tcpserver 0.0.0.0 "$port" u9fs -u "$(whoami)" -a none "$path" +exec 2>&1 +exec tcpserver 0.0.0.0 "$port" u9fs -a p9any "$path"