dot

packages and services management
Log | Files | Refs | README

commit f6e239f55875eb8ee573d8eb6da776400ab6be90
parent b77779904c18437f9eeb0927d2d74c0a97242224
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu, 21 Dec 2017 13:22:57 +0100

organizing xdg-open into categories

Diffstat:
Abin/attach | 24++++++++++++++++++++++++
Mbin/xdg-open | 44++++++++++++++++++++++----------------------
Adot/config/mblaze/filter | 0
3 files changed, 46 insertions(+), 22 deletions(-)

diff --git a/bin/attach b/bin/attach @@ -0,0 +1,24 @@ +#!/bin/sh + +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) + +# 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 "$*" && exec "$*" + +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 && exec "$@" + +[ "$SSH_TTY" ] && e='^Z' || e='^\' +ABDUCO=$hash exec abduco -e "$e" -A "$hash" "$@" diff --git a/bin/xdg-open b/bin/xdg-open @@ -91,9 +91,9 @@ case $scheme in exec "$0" "$HOME/var/torrent/${path##*/}" ;; (*.jpg|*.JPG|*.jpeg|*.JPEG|*.png|*.PNG|*.gif) - mkdir -p "$HOME/lib/http/image/$host" - curl -Lo "$HOME/lib/http/image/$host" "$1" - exec "$0" "$HOME/lib/http/image/$host" + mkdir -p "$HOME/lib/http/image/$host/${path##*/}" + curl -Lo "$HOME/lib/http/image/$host/${path##*/}" "$1" + exec "$0" "$HOME/lib/http/image/$host/${path##*/}" ;; (*.opus|*.ogg|*.mp3|*.flac) mkdir -p "$HOME/lib/http/music/$host" @@ -114,7 +114,7 @@ case $scheme in for b in retawq firefox chromium chromium-browser chrome x-www-browser do command -v "$b" && break done - $b "$1" + exec $b "$1" ;; (irc) [ "$port" = . ] && port=6667 @@ -160,6 +160,13 @@ esac (*.torrent) exec transmission-cli "$1" ;; +(*.img|*.iso) + exec doas qemu-system-x86_64 -m 500M \ + -device e1000,netdev=net0 \ + -netdev user,id=net0,hostfwd=tcp::5555-:22 \ + "$1" + ;; +#--- media --------------------------------------------------------------------- (*.pdf) exec mupdf "$1" ;; @@ -172,44 +179,37 @@ esac (*.webm|*.mp4|*.mkv|*.mp3|*.flac|*.ogg|*.opus) exec mplayer "$1" ;; -(*.img|*.iso) - exec doas qemu-system-x86_64 -m 500M \ - -device e1000,netdev=net0 \ - -netdev user,id=net0,hostfwd=tcp::5555-:22 \ - "$1" +(*/music/*|*.opus|*.mp3|*.flac|*.ogg) + exec play "$1" ;; +#--- pager --------------------------------------------------------------------- (*.[0-9]|*.[0-9]p|*.[0-9].gz) exec mandoc -a "$1" ;; (*.o|*.a) exec radare2 "$1" ;; -(*/music/*|*.opus|*.mp3|*.flac) - exec play "$1" - ;; -(*.tar) - exec tar -xf "$1" +#--- archive ------------------------------------------------------------------- +(*.tgz) + mv "$1" "${1%.tgz}.tar.gz" + exec "$0" "${1%.tgz}.tar.gz" ;; (*.tbz) mv "$1" "${1%.tbz}.tar.bz2" exec "$0" "${1%.tbz}.tar.bz2" ;; +(*.txz) + mv "$1" "${1%.txz}.tar.xz" + exec "$0" "${1%.txz}.tar.xz" + ;; (*.bz2) bzip2 -d "$1" exec "$0" "${1%.bz2}" ;; -(*.tgz) - mv "$1" "${1%.tgz}.tar.bz" - exec "$0" "${1%.tgz}.tar.gz" - ;; (*.gz) gzip -d "$1" exec "$0" "${1%.gz}" ;; -(*.tzz) - mv "$1" "${1%.txz}.tar.xz" - exec "$0" "${1%.txz}.tar.xz" - ;; (*.xz) xz -d "$1" exec "$0" "${1%.xz}" diff --git a/dot/config/mblaze/filter b/dot/config/mblaze/filter