dot

packages and services management
Log | Files | Refs | README

commit c3adca64731244e9b83fd2922401cfc434eaf050
parent 19361eba7715653a0541977f1f5c9451599fc96d
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 22 Dec 2017 00:13:04 +0100

merged store and xdg-open

Diffstat:
Dbin/store | 25-------------------------
Mbin/xdg-open | 105++++++++++++++++++++++++++++++++++++++++++-------------------------------------
2 files changed, 56 insertions(+), 74 deletions(-)

diff --git a/bin/store b/bin/store @@ -1,25 +0,0 @@ -#!/bin/sh -# store a file into $HOME/lib/http - -domain=$(printf %s "$1" | sed -r 's|^[^:]*(://)?([^/]+).*|\2|') -filename=$(printf %s "$1" | sed -r 's|.*/||') - -mkdir -p "$HOME/lib/http/$domain" -cd "$HOME/lib/http/$domain" || exit 1 - -case $1 in -(*vimeo.com/*|*youtube.com/*|*.bandcamp.com/*) - youtube-dl "$1" - ;; -(*://*.torrent) - curl -L "$1" > "$HOME/var/torrent/$filename" - ;; - -(*://*) - curl -L "$1" > "$filename" - ;; -(*) - printf 'uri not handled\n' 1>&2 - exit 1 - ;; -esac diff --git a/bin/xdg-open b/bin/xdg-open @@ -4,33 +4,6 @@ tty | grep -q -e '^/dev/pts/.*' -e '^/dev/tty*' || exec st -f terminus:pixelsize=18 -e "$0" "$@" -#--- manage sessions ----------------------------------------------------------- - -N=$ABDUCO_SOCKET_DIR/abduco/$USER/names - -# set the filename and the hash -[ $# = 1 ] && [ -e "$1" ] && set "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" -hash=$(printf %s "$*" | cksum | cut -d ' ' -f 1) - -aexec() { - [ "$SSH_TTY" ] && e='^Z' || e='^\' - ABDUCO=$hash exec abduco -e "$e" -A "$hash" "$@" -} - -# remove terminated session from names list -abduco | sed 1d | cut -f 3 | xargs -I {} grep -F -e{} "$N" | sort -uo "$N" - -# only list session if no argument is given -[ $# = 0 ] && exec cut -f 2 "$N" - -# attach to session if arguments match a session name -cut -f 2 "$N" | grep -Fxq "$*" && aexec "$*" - -printf '%s\t%s\n' "$hash" "$*" >> "$N" - -# execute commands if no file/dir of the same name exist -! [ -e "$1" ] && command -v "$1" > /dev/null && aexec "$@" - #--- parse uri ----------------------------------------------------------------- # scheme://[user[:pass]@]host[:port][/path] @@ -85,24 +58,58 @@ case $scheme in (9p) dir=$HOME/var/9p/$address mkdir -p "$dir" - aexec doas 9pfs "$address" "$dir" + exec doas 9pfs "$address" "$dir" ;; (ftp) - aexec ftp "$1" + exec ftp "$1" ;; (git) mkdir -p "$HOME/git" cd "$HOME/git" || exit 1 - aexec git clone "$1" + exec git clone "$1" ;; (gopher) - aexec sacc "$1" + exec sacc "$1" ;; (http|https) + case $host in + (vimeo.com|*youtube.com|*youtu.be) + mkdir -p "$HOME/lib/video/$host" + cd "$HOME/lib/video/$host" + exec youtube-dl "$1" + ;; + (*bandcamp.com) + mkdir -p "$HOME/lib/music/$host" + cd "$HOME/lib/music/$host" + exec youtube-dl "$1" + ;; + esac + case $path in + (*.torrent) + mkdir -p "$HOME/var/torrent" + curl -Lo "$HOME/var/torrent/${path##*/}" "$1" + exec "$0" "$HOME/var/torrent/${path##*/}" + ;; + (*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.gif) + mkdir -p "$HOME/lib/image/$host" + curl -Lo "$HOME/lib/image/$host" "$1" + exec "$0" "$HOME/lib/image/$host" + ;; + (*.opus|*.ogg|*.mp3|*.flac) + mkdir -p "$HOME/lib/http/music/$host" + curl -Lo "$HOME/lib/http/music/$host/${path##*/}" "$1" + exec "$0" "$HOME/lib/http/music/$host/${path##*/}" + ;; + (*.mkv|*.avi|*.webm) + mkdir -p "$HOME/lib/http/video/$host" + curl -Lo "$HOME/lib/http/video/$host/${path##*/}" "$1" + exec "$0" "$HOME/lib/http/video/$host/${path##*/}" + ;; + esac for b in retawq firefox chromium chromium-browser chrome x-www-browser do command -v "$b" && break done - aexec "$b" "$1" + $b "$1" ;; (irc) [ "$port" = . ] && port=6667 @@ -111,23 +118,23 @@ case $scheme in > "$HOME/var/irc/$host/log" 2> "$HOME/var/log/ii/$host" & ;; (news) - aexec retawq "$1" + exec retawq "$1" ;; (sftp) address=${1#*://} address=${address%*:} [ "$port" = . ] && port=22 - aexec sftp -p "$port" "$address" + exec sftp -p "$port" "$address" ;; (ssh) address=${1#*://} address=${address%:*} [ "$port" = . ] && port=22 - aexec ssh -p "$port" "$address" + exec ssh -p "$port" "$address" ;; (telnet) address=${1#telnet://} - aexec telnet "${address%:*}" "${address##*:}" + exec telnet "${address%:*}" "${address##*:}" ;; esac @@ -135,10 +142,10 @@ esac case $1 in (mailto:*) - aexec mcom "${1#mailto:}" + exec mcom "${1#mailto:}" ;; (magnet:*) - aexec transmission-cli "$1" + exec transmission-cli "$1" ;; esac @@ -146,33 +153,33 @@ esac [ -e "$1" ] && case "$1" in (*.torrent) - aexec transmission-cli "$1" + exec transmission-cli "$1" ;; (*.pdf) - aexec mupdf "$1" + exec mupdf "$1" ;; (*.jpg|*.jpeg|*.png) - aexec feh -. "$1" + exec feh -. "$1" ;; (*.gif) - aexec mplayer -loop 0 "$1" + exec mplayer -loop 0 "$1" ;; (*.webm|*.mp4|*.mkv|*.mp3|*.flac|*.ogg|*.opus) - aexec mplayer "$1" + exec mplayer "$1" ;; (*.img) - aexec qemu-start "$1" + exec qemu-start "$1" ;; (*.[0-9]|*.[0-9]p|*.[0-9].gz) - aexec mandoc -a "$1" + exec mandoc -a "$1" ;; (*.o|*.a) - aexec radare2 "$1" + exec radare2 "$1" ;; -(*bandcamp.com*|*/music/*|*.opus|*.mp3|*.flac) - aexec play "$1" +(*/music/*|*.opus|*.mp3|*.flac) + exec play "$1" ;; esac [ -d "$1" ] && exec io-src "$1" -[ -f "$1" ] && aexec $EDITOR "$1" +[ -f "$1" ] && exec $EDITOR "$1"