dot

packages and services management
Log | Files | Refs | README

commit c47d0138b45fac76d5335c2ea6c53f91b789b524
parent 4e7062969ef370d1f673d39d42922ad4b23c81e4
Author: Josuah Demangeon <mail@josuah.net>
Date:   Wed, 21 Mar 2018 03:19:34 +0100

bring abduco back in the party

Diffstat:
M.profile | 2+-
Mbin/cc-printf | 14+++++++++++++-
Mbin/edit | 2+-
Mbin/io | 8+++++++-
Mbin/io-agenda | 4+---
Mbin/proto | 4++--
Mbin/qemu | 2+-
Mbin/twt | 13++++++++-----
Abin/xdg-abduco | 33+++++++++++++++++++++++++++++++++
Mbin/xdg-open | 34+++++++++++++++-------------------
Mpack/abduco/config.mk | 2+-
Mpack/build/make | 2++
12 files changed, 85 insertions(+), 35 deletions(-)

diff --git a/.profile b/.profile @@ -33,7 +33,7 @@ export MANPATH="$PACKROOT/share/man:$MANPATH" export MANPAGER="less" export ABDUCO_CMD="dvtm-status" -export ABDUCO_SOCKET_DIR="$HOME/run" +export ABDUCO_SOCKET_DIR="/tmp" export BLIH="josuah.demangeon@epitech.eu" diff --git a/bin/cc-printf b/bin/cc-printf @@ -1,6 +1,6 @@ #!/bin/sh -e -cat > a.c << EOF +[ $# = 2 ] && cat > a.c << EOF #include <stdio.h> int @@ -11,6 +11,18 @@ main(void) } EOF +[ $# = 3 ] && cat > a.c << EOF +#include <stdio.h> + +int +main(void) +{ + $1 + printf("$2", $3); + return 0; +} +EOF + cc a.c ./a.out diff --git a/bin/edit b/bin/edit @@ -6,6 +6,6 @@ # emacs(1)-style input key bindings for everything REPL. This also permit to # change the $EDITOR without reloading the environment variables. -cd "$(dirname "$@")" +cd "$(dirname "$1")" exec vi "$@" diff --git a/bin/io b/bin/io @@ -12,4 +12,10 @@ mkdir -p "$(dirname "$cache")" find "$HOME" \( -name .git -o -name CVS \) -prune -o -print | sort -o "$cache" -exec xdg-open "$(cat "$cache" "$HOME/etc/uri" | iomenu)" +h='----------------------------------------------------------------------------' + +exec xdg-open "$({ + xdg-abduco + printf '#%s\n' "$h$h$h$h$h$h$h$h$h$h$h$hh$h$h" + cat "$cache" "$HOME/etc/uri" +} | iomenu -# | cut -f 2-)" diff --git a/bin/io-agenda b/bin/io-agenda @@ -1,5 +1,3 @@ #!/bin/sh -e -a="$(agenda | iomenu | cut -d ' ' -f 4-)" - -[ "$a" ] && $EDITOR "$a" +exec $EDITOR "$(agenda | iomenu | sed -r 's:.* (/.*):\1:')" diff --git a/bin/proto b/bin/proto @@ -30,9 +30,9 @@ function print_tabs(len) print_tabs((length(symbol) + length(ptr))); gsub("[*][a-z0-9_]+,", "*,"); - gsub("[*][a-z0-9_]+)", "*)"); + gsub("[*][a-z0-9_]+\\)", "*)"); gsub("[ ][a-z0-9_]+,", ","); - gsub("[ ][a-z0-9_]+)", ")"); + gsub("[ ][a-z0-9_]+\\)", ")"); printf("%s;\n", $0); } diff --git a/bin/qemu b/bin/qemu @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh -ex mkdir -p "$HOME/var/log/qemu" "$HOME/var/qemu" "$HOME/lib/qemu" diff --git a/bin/twt b/bin/twt @@ -6,7 +6,7 @@ TWT_FEED="${TWT_FEED-$HOME/.config/twtxt.txt}" TWT_CONF="${TWT_CONF-$HOME/.config/twt}" TWT_PATH="${TWT_PATH-$HOME/.cache/twt}" -show=' +view=' function leap(yrs) { @@ -81,7 +81,10 @@ function rfc3339(str) { hrs = substr(str, 12, 2); min = substr(str, 15, 2); sec = substr(str, 18, 2); - off = substr(str, 20, 1) == "Z" ? 0 : substr(str, 20, 3); + if (substr(str, 20, 1) == "Z") + off = 0; + else + off = substr(str, 20, 3); return to_sec(yrs, mth, day, hrs, min, sec) - off * 3600; } @@ -90,7 +93,7 @@ BEGIN { sub("..$", "", OFF); } -/^[0-9]{4}/ { +/^[0-9][0-9][0-9][0-9]/ { sec = rfc3339($1) + OFF * 3600; sub("[^\t]*\t", "", $0); gsub("\t", " ", $0); @@ -140,12 +143,12 @@ case "$1" in (view) [ "$#" -ne 2 ] && exec "$0" [ -f "$TWT_PATH/$2" ] || err "$2 feed not found, try update" - awk "$show" "$TWT_PATH/$2" + awk "$view" "$TWT_PATH/$2" ;; (timeline) [ "$#" -ne 1 ] && exec "$0" ls "$TWT_PATH"/* 2> /dev/null 1>&2 || err 'no feed found, twt update' - find "$TWT_PATH" -type f -exec awk "$show" {} + + find "$TWT_PATH" -type f -exec awk "$view" {} + ;; (update) while read -r usr url diff --git a/bin/xdg-abduco b/bin/xdg-abduco @@ -0,0 +1,33 @@ +#!/bin/sh -e + +# wrapper over abduco for supporting any length session names + +[ "$ABDUCO_SOCKET_DIR" ] && + dir="$ABDUCO_SOCKET_DIR/abduco/$USER" || + dir="$HOME/.abduco" + +mkdir -p "$dir" +touch "$dir/sessions" + +# only keep existing session names +grep -e"^$(abduco | sed -rn 's/.* ([0-9]+)$/\1/p')" "$dir/sessions" | +sort -uo "$dir/sessions" + +# get the reas path name +! [ -h "$1" ] || set -- "$(readlink -f "$1")" +! [ -e "$1" ] || set -- "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" +! [ -d "$1" ] || set -- "$(cd "$1"; pwd)" + +case "$#" in +(0) + cut -f 2 "$dir/sessions" + ;; +(1) + + printf '\033]0;%s\a' "$1" 1>&2 + + hash="$(printf %s "$1" | cksum | cut -d ' ' -f 1)" + printf '%s\t%s\n' "$hash" "$1" >> "$dir/sessions" + [ "$ABDUCO" ] || ABDUCO="$1" exec abduco -A "$hash" xdg-open "$1" + ;; +esac diff --git a/bin/xdg-open b/bin/xdg-open @@ -4,14 +4,10 @@ [ "$DISPLAY" ] && case "$(tty)" in (/dev/pts/*|/dev/ttyp*) ;; -(*) exec st -f terminus:pixelsize=16 -e "$0" "$@" ;; +(*) exec st -f terminus:pixelsize=16 -e xdg-open "$@" ;; esac -[ -h "$1" ] && set -- "$(readlink -f "$1")" -[ -e "$1" ] && set -- "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")" -[ -d "$1" ] && set -- "$(cd "$1"; pwd)" - -printf '\033]0;%s\a' "$1" +[ "$ABDUCO" ] || exec xdg-abduco "$@" # [scheme://][user[:pass]@]host[:port][/path] IFS=' ' read scheme user pass host port path << EOF @@ -63,7 +59,7 @@ EOF case "$host" in (*.onion) - [ "$TOR" ] || TOR="$1" exec torsocks "$0" "$1" + [ "$TOR" ] || TOR="$1" exec torsocks xdg-open "$1" ;; esac @@ -112,7 +108,7 @@ case "$1" in ;; (magnet:*) transmission-cli "$1" - exec "$0" "$file" + exec xdg-open "$file" ;; (9p://*) dir="$HOME/var/9p/$host" @@ -124,7 +120,7 @@ case "$1" in then mkdir "$(dirname "$file")" curl -o "$file" "$1" - exec "$0" "$file" + exec xdg-open "$file" else exec ftp "$1" fi @@ -145,20 +141,20 @@ case "$1" in cd "$HOME/lib/video/$host" file="$PWD/$(youtube-dl --get-filename "$1")" youtube-dl "$1" - exec "$0" "$file" + exec xdg-open "$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" + exec xdg-open "$file" ;; (*) if [ "$file" ] then curl -o "$file" "$1" - exec "$0" "$file" + exec xdg-open "$file" else exec chromium "$1" fi @@ -234,27 +230,27 @@ case "$1" in ;; (*.tgz) mv "$1" "${1%.tgz}.tar.gz" - exec "$0" "${1%.tgz}.tar.gz" + exec xdg-open "${1%.tgz}.tar.gz" ;; (*.tbz) mv "$1" "${1%.tbz}.tar.bz2" - exec "$0" "${1%.tbz}.tar.bz2" + exec xdg-open "${1%.tbz}.tar.bz2" ;; (*.txz) mv "$1" "${1%.txz}.tar.xz" - exec "$0" "${1%.txz}.tar.xz" + exec xdg-open "${1%.txz}.tar.xz" ;; (*.bz2) bzip2 -ds "$1" - exec "$0" "${1%.bz2}" + exec xdg-open "${1%.bz2}" ;; (*.gz) gzip -d "$1" - exec "$0" "${1%.gz}" + exec xdg-open "${1%.gz}" ;; (*.xz) xz -d "$1" - exec "$0" "${1%.xz}" + exec xdg-open "${1%.xz}" ;; (*.tar) exec tar -xf "$1" @@ -276,7 +272,7 @@ case "$1" in ;; (*) [ -f "$1" ] && exec $EDITOR "$1" - [ -d "$1" ] && exec "$0" "$(io-find "$1")" + [ -d "$1" ] && exec xdg-open "$(io-find "$1")" ;; esac diff --git a/pack/abduco/config.mk b/pack/abduco/config.mk @@ -9,7 +9,7 @@ MANPREFIX = ${PREFIX}/share/man INCS = -I. LIBS = -lc -lutil -CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE +CPPFLAGS = -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -D_BSD_SOURCE=1 CFLAGS += -std=c99 -pedantic -Wall ${INCS} -DVERSION=\"${VERSION}\" -DNDEBUG ${CPPFLAGS} LDFLAGS += ${LIBS} diff --git a/pack/build/make b/pack/build/make @@ -1,4 +1,6 @@ #!/bin/sh -ex +cp -f "$PACK/abduco/config.mk" config.mk + make make PREFIX="$PREFIX" install