dot

packages and services management
Log | Files | Refs | README

commit 20fb069256eef520e4aaba7d80fbab06fad43d79
parent 618b1e40a0b781454f6a52790b01c63202b2df7c
Author: Josuah Demangeon <mail@josuah.net>
Date:   Fri, 22 Dec 2017 02:04:14 +0100

found a rather sane format for calendar(1)

Diffstat:
Mbin/calendar | 106++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------
Mbin/mblaze-filter | 10++++++----
Dbin/mv-sane | 11-----------
Dbin/mv-split | 9---------
Apack/lchat/git | 1+
Mpack/tinc/build | 4++++
6 files changed, 81 insertions(+), 60 deletions(-)

diff --git a/bin/calendar b/bin/calendar @@ -1,44 +1,10 @@ #!/bin/sh # awk functions to deal with calendar -awk_convert=' -BEGIN { - FS = ":"; -} - -{ - gsub("\015", ""); - gsub("\t", " "); -} - -/BEGIN:VEVENT/,/END:VEVENT/ { - if (substr($0, 1, 1) != " ") { - type = $1; - vevent[type] = substr($0, \ - index($0, ":") + 1, length($0) - length($1)); - } else { - vevent[type] = vevent[type] substr($0, 2, length($0) - 1); - } -} - -/END:VEVENT/ { - gsub(/\\n/, " ", vevent["DESCRIPTION"]); - gsub(/\\/, "", vevent["DESCRIPTION"]); - gsub(/\\/, "", vevent["LOCATION"]); - gsub(/\\/, "", vevent["SUMMARY"]); - - printf("%04d/%02d/%02d %02d:%02d %s %s %s\n", - substr(vevent["DTSTART"], 1, 4), - substr(vevent["DTSTART"], 5, 2), - substr(vevent["DTSTART"], 7, 2), - substr(vevent["DTSTART"], 10, 2), - substr(vevent["DTSTART"], 12, 2), - vevent["SUMMARY"], - vevent["LOCATION"], - vevent["DESCRIPTION"]); -}' +CALENDAR="$HOME/var/cal" awk_date=' + function bissextile(yrs) { return yrs % 4 == 0 && (yrs % 100 != 0 || yrs % 400 == 0); @@ -94,4 +60,72 @@ function rfc3339(str) { sub("^[^ ]+\\.[0-9]+", "", str); off = substr(str, 1, 1) == "Z" ? 0 : substr(str, 1, 3); return to_sec(yrs, mth, day, hrs, min, sec) - off * 3600; +} + +function ical(str) { + yrs = substr(event["DTSTART"], 1, 4); + mth = substr(event["DTSTART"], 5, 2); + day = substr(event["DTSTART"], 7, 2); + hrs = substr(event["DTSTART"], 10, 2); + min = substr(event["DTSTART"], 12, 2); + return to_sec(yrs, mth, day, hrs, min, 0); }' + +awk_import=$awk_date' +#-v off=[+-]HH + +BEGIN { + FS = "[:;]"; +} + +{ + gsub("\r", ""); + gsub("\t", " "); +} + +/BEGIN:VEVENT/,/END:VEVENT/ { + if (substr($0, 1, 1) == " ") { + event[type] = event[type] substr($0, 2, length($0) - 1); + } else { + type = $1; + i = index($0, ":"); + event[type] = substr($0, i + 1, length($0) - i); + } +} + +/END:VEVENT/ { + gsub("<[a-zA-Z0-9/]*>", "", event["DESCRIPTION"]); + gsub("\\\\n", "\n:D:", event["DESCRIPTION"]); + printf("%d %d\n:S:%s\n:C:%s\n:L:%s\n:D:%s\n:\n", + ical(event["DTSTART"]), ical(event["DTEND"]), + event["SUMMARY"], event["CATEGORIES"], event["LOCATION"], + event["DESCRIPTION"]); +}' + +awk_show=' +/^[0-9]+ [0-9]+$/ { + +} +' + +mkdir -p "$CALENDAR" + +case $1 in +(import) + [ $# -ne 4 ] && exec "$0" + awk -v off="$4" "$awk_import" "$2" > "$CALENDAR/$3" + ;; +(list) + [ $# -ne 1 ] && exec "$0" + ls -C "$CALENDAR" + ;; +(show) + [ $# -ne 2 ] && exec "$0" + awk "$awk_show" "$CALENDAR/$2" + ;; +(*) + printf 'usage: calendar import ics_file name [+-]HH\n' + printf ' calendar list\n' + printf ' calendar show name\n' + ;; +esac diff --git a/bin/mblaze-filter b/bin/mblaze-filter @@ -17,15 +17,17 @@ amazon.com "From" ~~~ "*@amazon.*" amnesty.org "From" ~~~ "*amnesty.*" bandcamp.com "From" ~~~ "*Cryo Chamber*" bandcamp.com "From" ~~~ "*makeupandvanityset.com*" -bandcamp.com "List-Id" ~~~ "*bandcamp.com*" +bandcamp.com "From" ~~~ "*bandcamp.com*" breizh-entropy.org "List-Id" ~~~ "*breizh-entropy.org*" coinbase.com "From" ~~~ "*coinbase.com*" crous-rennes.fr "From" ~~~ "*crous-rennes.fr*" dropbox.com "From" ~~~ "*dropbox.*" ebay.com "From" ~~~ "*ebay.*" -epitech.eu "From" ~~~ "*bde.epitech.rennes@gmail.com*" -epitech.eu "From" ~~~ "*epitech.eu*" -epitech.eu "From" ~~~ "*ionis-group.org*" +epitech.eu/bde "From" ~~~ "*bde.epitech.rennes@gmail.com*" +epitech.eu/intra "From" ~~~ "*@intra.epitech.eu*" +epitech.eu/marvin "From" ~~~ "*nao.marvin@epitech.eu*" +epitech.eu/@ "From" ~~~ "*@epitech.eu*" +epitech.eu/@ "From" ~~~ "*ionis-group.org*" free.fr "From" ~~~ "*@free-mobile.fr*" freebsd.org "From" ~~~ "*freebsd.org*" fsf.org "From" ~~~ "*fsf.org*" diff --git a/bin/mv-sane b/bin/mv-sane @@ -1,11 +0,0 @@ -#!/bin/sh -# only keep '[:alnum:]', ',' and '.' and convert everyting else to '_' - -find . -depth -exec sh -c ' - old=$(basename "$0") - new=$(basename "$0" | tr -d "\\n" | tr -c " \"\\\\$;(),." "_" | - sed -r -e "s/_+/_/g" -e "s/([0-9]+)\\.*_/\\1_/") - dir=$(dirname "$0") - - [ "$dir/$old" != "$dir/$new" ] && mv -- "$dir/$old" "$dir/$new" -' {} ';' diff --git a/bin/mv-split b/bin/mv-split @@ -1,9 +0,0 @@ -#!/bin/sh -# split all names at the separator $1 into subdirectories - -find . -exec sh -c ' - old=$1 - new=$(printf %s "$1" | sed "s|$(printf %s "$0" | sed "s|.|[&]|g")|/|g") - mkdir -p "$(dirname "$new")" - mv -- "$old" "$new" -' "$1" "{}" ';' diff --git a/pack/lchat/git b/pack/lchat/git @@ -0,0 +1 @@ +git://git.suckless.org/lchat diff --git a/pack/tinc/build b/pack/tinc/build @@ -1,3 +1,7 @@ +#!/bin/sh -e + ./configure --prefix="$OPT" --disable-lzo --sysconfdir="$HOME/.config" + case $(uname) in (*BSD) gmake install ;; (*) make install ;; esac + mv "$OPT/sbin" "$OPT/bin"