dot

packages and services management
Log | Files | Refs | README

commit 4c10924b32c824f898e4115ea5c2e7ba4742cd65
parent 559bcf37a409e035c512a778704dab7f4a15b752
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed,  7 Mar 2018 11:19:08 +0100

single-file xdg-open is less hassle

Diffstat:
M.bashrc | 5++---
M.msmtprc | 2+-
M.profile | 4++++
Tbin/o | 0
Dbin/xdg-connect | 50--------------------------------------------------
Mbin/xdg-open | 193++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
Dbin/xdg-store | 87-------------------------------------------------------------------------------
Dbin/xdg-uri | 52----------------------------------------------------
Apack/sacc/tar | 1+
Apack/vorbis-tools/build | 2++
Msfeed | 1+
Muri | 7++++---
12 files changed, 198 insertions(+), 206 deletions(-)

diff --git a/.bashrc b/.bashrc @@ -1,6 +1,5 @@ . ./.profile export TERM=screen -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")" +PS1='\[\033[31;1m\]$([ $? -gt 0 ] && printf "x\\n ")\033[m\] +\[\033]0;$PWD\a\]\h\$ ' diff --git a/.msmtprc b/.msmtprc @@ -8,6 +8,6 @@ from mail@josuah.net user mail@josuah.net auth on passwordeval "enchive -a$((3600*12)) extract /mnt/key/vault/mpop /dev/stdout" -logfile ~/.cache/log/msmtp +logfile /dev/stderr account default : mail@josuah.net diff --git a/.profile b/.profile @@ -49,3 +49,7 @@ export PKG_PATH="https://ftp.fr.openbsd.org/pub/OpenBSD/" export SSH_AUTH_SOCK="/tmp/ssh-agent" export SVDIR="$HOME/var/runit" + +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")" diff --git a/bin/o b/bin/o diff --git a/bin/xdg-connect b/bin/xdg-connect @@ -1,50 +0,0 @@ -#!/bin/sh - -# connect to the uri passed as argument - -# Call xdg-uri to parse the uri then open it with apropriate program -# and arguments. - -IFS=' ' read scheme user pass host port path << EOF -$(xdg-uri "$1") -EOF - -[ "${host##*.}" = "onion" ] && [ -z "$TOR" ] && TOR=1 exec torsocks "$0" "$@" - -case "$scheme" in -(9p) - dir="$HOME/var/9p/$host" - mkdir -p "$dir" - exec doas 9pfs "$host" "$dir" - ;; -(ftp) - exec ftp "$1" - ;; -(gopher) - exec sacc "$1" - ;; -(http|https) - exec firefox "$1" - ;; -(irc) - [ "$port" = . ] && port='6667' - cp -r "$HOME/etc/runit/ii" "$SVDIR/ii-$host" - [ "$path" = . ] && exit - sleep 3 - printf '/j #%s\n' "$path" > "$HOME/var/irc/$host/in" - ;; -(news) - exec retawq "$1" - ;; -(sftp) - [ "$port" = . ] && port='22' - exec sftp -P "$port" "$host" - ;; -(ssh) - [ "$port" = . ] && port='22' - exec ssh -p "$port" "${1#*://}" - ;; -(telnet) - exec telnet "$port" "$host" - ;; -esac diff --git a/bin/xdg-open b/bin/xdg-open @@ -2,16 +2,180 @@ # override the xdg-open utility +# [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; + sub("[#?].*", "", path); + + printf("%s\t%s\t%s\t%s\t%s\t%s", scheme, user, pass, host, port, path); +}') +EOF + +case "$host" in +(*.onion) + [ -z "$TOR" ] && TOR=1 exec torsocks "$0" "$@" + ;; +esac + +file="" +case "$path" in +(*.torrent) + file="$HOME/var/torrent/${path##*/}" + ;; +(*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.gif|*.GIF) + file="$HOME/lib/image/$host/${path##*/}" + ;; +(*.opus|*.ogg|*.mp3|*.flac) + file="$HOME/lib/music/$host/${path##*/}" + ;; +(*.webm|*.mp4|*.mkv|*.ogv|*.avi) + file="$HOME/lib/video/$host/${path##*/}" + ;; +(*.pdf|*.ps) + file="$HOME/lib/doc/$host/${path##*/}" + ;; +(*.txt) + file="$HOME/lib/text/$host/${path##*/}" + ;; +(*.tar|*.gz|*.bz2|*.xz|*.tgz|*.tgz|*.tbz2|*.txz|*.zip|*.rar) + file="$HOME/tmp/${path##*/}" + ;; +esac + +[ "$file" ] && mkdir -p "$(dirname "$file")" + case "$(uname)" in (Linux) - play="aucat" + play="aplay -f cd" ;; (*BSD) play="aucat -r 44100 -i -" ;; esac -[ -e "$1" ] && case "$1" in +case "$1" in +(git://*) + mkdir -p "$HOME/git/$host" + cd "$HOME/git/$host" + exec git clone "$1" + ;; +(magnet:*) + transmission-cli "$1" + exec "$0" "$file" + ;; +(9p://*) + dir="$HOME/var/9p/$host" + mkdir -p "$dir" + exec su -c "9pfs '$host' '$dir'" + ;; +(ftp://*) + if [ "$file" ] + then + mkdir "$(dirname "$file")" + curl -o "$file" "$1" + exec "$0" "$file" + else + exec ftp "$1" + fi + ;; +(gopher://*) + if [ "$file" ] + then + printf '/%s\r\n' "$path" | nc "$host" + else + exec sacc "$1" + fi + ;; +(http://*|https://*) + case "$1" in + (*vimeo.com*|*youtube.com*|*youtu.be*|*openload.co*) + mkdir -p "$HOME/lib/video/$host" + cd "$HOME/lib/video/$host" + file="$PWD/$(youtube-dl --get-filename "$1")" + youtube-dl "$1" + 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 "$0" "$file" + ;; + (*) + if [ "$file" ] + then + curl -o "$file" "$1" + exec "$0" "$file" + else + exec firefox "$1" + fi + ;; + esac + ;; +(irc://*) + [ "$port" = . ] && port='6667' + cp -r "$HOME/etc/runit/ii" "$SVDIR/ii-$host" + [ "$path" = . ] && exit + sleep 3 + printf '/j #%s\n' "$path" > "$HOME/var/irc/$host/in" + ;; +(news://*) + exec retawq "$1" + ;; +(sftp://*) + [ "$port" = . ] && port='22' + exec sftp -P "$port" "$host" + ;; +(ssh://*) + [ "$port" = . ] && port='22' + exec ssh -p "$port" "${1#*://}" + ;; +(telnet://*) + exec telnet "$port" "$host" + ;; +(*://*) + exec printf 'unsupported protocol\n' 1>&2 + ;; (*.torrent) exec transmission-cli "$1" ;; @@ -20,15 +184,12 @@ esac ;; (*.pdf) mupdf "$1" & - exit ;; (*.png|*.PNG) png2ff < "$1" | lel & - exit ;; (*.jpg|*.jpeg|*.JPG|*.JPEG) jpg2ff < "$1" | lel & - exit ;; (*.gif) exec mplayer -loop 0 "$1" @@ -36,7 +197,19 @@ esac (*.opus) exec opusdec "$1" ;; -(*.webm|*.mp4|*.mkv|*.ogv|*.avi|*.mp3|*.flac|*.ogg|*.wav) +(*.mp3) + exec mpg123 "$1" + ;; +(*.flac) + flac -cd "$1" | $play + ;; +(*.ogg|*.vorbis) + oggdec -e 1 -o - "$1" | $play + ;; +(*.wav) + exec $play < "$1" + ;; +(*.webm|*.mp4|*.mkv|*.ogv|*.avi) exec ffplay "$1" ;; (*/music/*) @@ -45,7 +218,6 @@ esac printf '%s\n' "$song" ffplay "$song" done - exit ;; (*.[0-9]|*.[0-9]p|*.[0-9].gz) exec mandoc -a -T utf8 "$1" @@ -98,7 +270,8 @@ esac (*.deb) exec ar vx "$1" ;; +(*) + [ -d "$1" ] && exec io grep "$1" + [ -f "$1" ] && exec $EDITOR "$1" + ;; esac - -[ -d "$1" ] && exec io grep "$1" -[ -f "$1" ] && exec $EDITOR "$1" diff --git a/bin/xdg-store b/bin/xdg-store @@ -1,87 +0,0 @@ -#!/bin/sh -e - -# store a file from an uri scheme given as argument - -# Call xdg-uri to parse the uri then call apropriate program to store -# the file, then print the path to the local file. The directory the file -# is saved to is determined according to its extension. - -IFS=' ' read scheme user pass host port path << EOF -$(xdg-uri "$1") -EOF - -if [ "${host##*.}" = "onion" ] && [ -z "$TOR" ] -then - TOR="1" exec torsocks "$0" "$@" -fi - -[ "$file" ] || case "$path" in -(*.torrent) - file="$HOME/var/torrent/${path##*/}" - ;; -(*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.gif|*.GIF) - file="$HOME/lib/image/$host/${path##*/}" - ;; -(*.opus|*.ogg|*.mp3|*.flac) - file="$HOME/lib/music/$host/${path##*/}" - ;; -(*.webm|*.mp4|*.mkv|*.ogv|*.avi) - file="$HOME/lib/video/$host/${path##*/}" - ;; -(*.pdf|*.ps) - file="$HOME/lib/doc/$host/${path##*/}" - ;; -(*.txt) - file="$HOME/lib/text/$host/${path##*/}" - ;; -(*.gz|*.bz2|*.xz|*.tgz|*.tgz|*.tbz2|*.txz|*.zip|*.rar) - file="$HOME/tmp/${path##*/}" - ;; -esac - -[ -z "$file" ] || mkdir -p "$(dirname "$file")" - -case "$scheme" in -(http|https) - case "$host" in - (vimeo.com|*youtube.com|*youtu.be|*openload.co*) - mkdir -p "$HOME/lib/video/$host" - cd "$HOME/lib/video/$host" - file="$PWD/$(youtube-dl --get-filename "$1")" - youtube-dl "$1" - ;; - (*bandcamp.com) - mkdir -p "$HOME/lib/music/$host" - cd "$HOME/lib/music/$host" - file="$PWD/$(youtube-dl --get-filename "$1")" - youtube-dl "$1" - ;; - (*) - curl -o "$file" "$1" - ;; - esac - ;; -(git) - file="$HOME/git/$host/${path%.git}" - mkdir -p "$(dirname "$file")" - git clone "$1" "$file" - ;; -(magnet) - transmission-cli "$1" - file="." - ;; -(sftp) - [ "$port" = . ] && port="22" - printf 'get %s\n' "$path" | sftp -P "$port" "$host" - ;; -(ssh) - [ "$port" = . ] && port="22" - scp -p "$port" "${1#*://}" "$file" - ;; -(gopher) - [ "$port" = . ] && port="70" - printf '%s\r\n' "$path" | nc "$host" "$port" > "$file" - ;; -esac - -printf '%s\n' "$file" diff --git a/bin/xdg-uri b/bin/xdg-uri @@ -1,52 +0,0 @@ -#!/usr/bin/awk -f - -# uri parser - -# [scheme://][user[:pass]@]host[:port][/path] - -BEGIN { - URI = ARGV[1]; - ARGC = 0; - - 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; - sub("[#?].*", "", path); - - printf("%s\t%s\t%s\t%s\t%s\t%s", scheme, user, pass, host, port, path); -} diff --git a/pack/sacc/tar b/pack/sacc/tar @@ -0,0 +1 @@ +ftp://ftp@bitreich.org/releases/sacc/sacc-v1.00.tgz diff --git a/pack/vorbis-tools/build b/pack/vorbis-tools/build @@ -0,0 +1 @@ +../build/autotools+ \ No newline at end of file diff --git a/sfeed b/sfeed @@ -3,3 +3,4 @@ codemadness.nl http://www.codemadness.nl/rss.xml kernel.org http://kernel.org/kdist/rss.xml xkcd.com http://xkcd.com/atom.xml research.googleblog.com http://feeds.feedburner.com/blogspot/gJZg +bitreich.org gopher://bitreich.org/0/news.atom.xml diff --git a/uri b/uri @@ -20,7 +20,9 @@ gopher://z3bra.org http://198.204.250.219:19999 http://2f30.org http://bitreich.org:3232/live +http://bulbizarre.swordarmor.fr/munin/ http://calomel.org +http://code.dogmap.org http://fuwafuwa.moe http://gnu.moe http://gxamjbnu7uknahng.onion.rip/wiki/index.php/Infornography:_The_Tao_of_Memetic_(Meta)Engineering @@ -35,7 +37,9 @@ http://netsukuku.freaknet.org http://nixers.net http://nullprogram.com http://pdp11.aiju.de +http://radio.2f30.org:8443/live.mp3 http://radio.phallic.io:8000/listen +http://raft.github.io/ http://reddit.com http://suckless.org http://systemspace.network @@ -50,9 +54,6 @@ http://www.bottomupcs.com/global_offset_tables.xhtml http://www.destroyallsoftware.com/compendium/network-protocols http://www.mindfruit.co.uk/2012/06/relocations-relocations.html http://www.tldp.org/guides.html -http://bulbizarre.swordarmor.fr/munin/ -http://radio.2f30.org:8443/live.mp3 -http://raft.github.io/ irc://irc.cyberia.is/2f30 irc://irc.cyberia.is/airbnb irc://irc.cyberia.is/cyberia