dot

packages and services management
Log | Files | Refs | README

commit e6af4a453db6fa1b696e9de7148d9f2d8412ba11
parent 39fd4e72207f71825bfe5946675b735e0bff25ba
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed,  6 Dec 2017 17:43:33 +0100

use hash for session names again

Diffstat:
Mbin/xdg-open | 47+++++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)

diff --git a/bin/xdg-open b/bin/xdg-open @@ -1,18 +1,37 @@ #!/bin/sh # override the xdg-open utility -aexec() -{ - name=$(printf %s "$name" | tr / ! | sed -r 's/.*(.{53})$/\1/') +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=$name exec abduco -e "$e" -A "$name" "$@" + ABDUCO=$hash exec abduco -e "$e" -A "$hash" "$@" } -for name in "$@"; do continue; done -[ -e "$name" ] && name=$(cd "$(dirname "$1")"; pwd)/$(basename "$1") +# remove terminated session from names list +abduco | sed 1d | cut -f 3 | xargs -I {} grep -F -e{} "$N" | sort -uo "$N" -tty | grep -q -e '^/dev/pts/.*' -e '^/dev/tty*' || -exec st -f terminus:pixelsize=18 -e "$0" "$@" +# 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] IFS=' ' read scheme user pass host port path << EOF @@ -109,18 +128,18 @@ case $scheme in ;; esac -#--- other uri ----------------------------------------------------------------- +#--- short uri ----------------------------------------------------------------- -case ${1%%*:} in -(mailto) +case $1 in +(mailto:*) aexec mcom "${1#mailto:}" ;; -(magnet) +(magnet:*) aexec transmission-cli "$1" ;; esac -#--- local resources ----------------------------------------------------------- +#--- files --------------------------------------------------------------------- [ -e "$1" ] && case "$1" in (*.torrent) @@ -141,7 +160,7 @@ esac (*.o|*.a) aexec radare2 "$1" ;; -(*/music/*) +(*/music/*|*.opus|*.mp3|*.flac) aexec play "$1" ;; (*)