commit 3779fdce2c311a308e4458cf5b84b1be4f085dac Author: Lucas Date: Wed Sep 11 02:11:40 2019 +0000 Initial import diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..c7a74f9 --- /dev/null +++ b/COPYING @@ -0,0 +1,113 @@ +CC0 1.0 Universal + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator and +subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for the +purpose of contributing to a commons of creative, cultural and scientific +works ("Commons") that the public can reliably and without fear of later +claims of infringement build upon, modify, incorporate in other works, reuse +and redistribute as freely as possible in any form whatsoever and for any +purposes, including without limitation commercial purposes. These owners may +contribute to the Commons to promote the ideal of a free culture and the +further production of creative, cultural and scientific works, or to gain +reputation or greater distribution for their Work in part through the use and +efforts of others. + +For these and/or other purposes and motivations, and without any expectation +of additional consideration or compensation, the person associating CC0 with a +Work (the "Affirmer"), to the extent that he or she is an owner of Copyright +and Related Rights in the Work, voluntarily elects to apply CC0 to the Work +and publicly distribute the Work under its terms, with knowledge of his or her +Copyright and Related Rights in the Work and the meaning and intended legal +effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not limited +to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, communicate, + and translate a Work; + + ii. moral rights retained by the original author(s) and/or performer(s); + + iii. publicity and privacy rights pertaining to a person's image or likeness + depicted in a Work; + + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + + v. rights protecting the extraction, dissemination, use and reuse of data in + a Work; + + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation thereof, + including any amended or successor version of such directive); and + + vii. other similar, equivalent or corresponding rights throughout the world + based on applicable law or treaty, and any national implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention of, +applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and +unconditionally waives, abandons, and surrenders all of Affirmer's Copyright +and Related Rights and associated claims and causes of action, whether now +known or unknown (including existing as well as future claims and causes of +action), in the Work (i) in all territories worldwide, (ii) for the maximum +duration provided by applicable law or treaty (including future time +extensions), (iii) in any current or future medium and for any number of +copies, and (iv) for any purpose whatsoever, including without limitation +commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes +the Waiver for the benefit of each member of the public at large and to the +detriment of Affirmer's heirs and successors, fully intending that such Waiver +shall not be subject to revocation, rescission, cancellation, termination, or +any other legal or equitable action to disrupt the quiet enjoyment of the Work +by the public as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason be +judged legally invalid or ineffective under applicable law, then the Waiver +shall be preserved to the maximum extent permitted taking into account +Affirmer's express Statement of Purpose. In addition, to the extent the Waiver +is so judged Affirmer hereby grants to each affected person a royalty-free, +non transferable, non sublicensable, non exclusive, irrevocable and +unconditional license to exercise Affirmer's Copyright and Related Rights in +the Work (i) in all territories worldwide, (ii) for the maximum duration +provided by applicable law or treaty (including future time extensions), (iii) +in any current or future medium and for any number of copies, and (iv) for any +purpose whatsoever, including without limitation commercial, advertising or +promotional purposes (the "License"). The License shall be deemed effective as +of the date CC0 was applied by Affirmer to the Work. Should any part of the +License for any reason be judged legally invalid or ineffective under +applicable law, such partial invalidity or ineffectiveness shall not +invalidate the remainder of the License, and in such case Affirmer hereby +affirms that he or she will not (i) exercise any of his or her remaining +Copyright and Related Rights in the Work or (ii) assert any associated claims +and causes of action with respect to the Work, in either case contrary to +Affirmer's express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + + b. Affirmer offers the Work as-is and makes no representations or warranties + of any kind concerning the Work, express, implied, statutory or otherwise, + including without limitation warranties of title, merchantability, fitness + for a particular purpose, non infringement, or the absence of latent or + other defects, accuracy, or the present or absence of errors, whether or not + discoverable, all to the greatest extent permissible under applicable law. + + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without limitation + any person's Copyright and Related Rights in the Work. Further, Affirmer + disclaims responsibility for obtaining any necessary consents, permissions + or other rights required for any use of the Work. + + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to this + CC0 or use of the Work. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..738c5c5 --- /dev/null +++ b/Makefile @@ -0,0 +1,66 @@ +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . +.POSIX: +.SUFFIXES: + +PREFIX= $(HOME) + +DIRS= bin dotfiles spoon themes utils xdg-config-dir + +all: install + +clean: clean-bin clean-dotfiles clean-themes + rm -f env.tgz + +clean-bin: + cd bin && $(MAKE) clean + +clean-dotfiles: + cd dotfiles && $(MAKE) clean + +clean-themes: + cd themes && $(MAKE) clean + +diff: diff-dotfiles diff-xdg-config-dir + +diff-dotfiles: + -cd dotfiles && $(MAKE) diff + +diff-xdg-config-dir: + -cd xdg-config-dir && $(MAKE) diff + +dist: clean + mkdir -p env.dist-tmp + cp -fr Makefile $(DIRS) env.dist-tmp + pax -ws "/.dist-tmp//" env.dist-tmp | gzip >env.tgz + rm -fr env.dist-tmp + +install: install-bin install-dotfiles install-xdg-config-dir + +install-bin: + cd bin && $(MAKE) install + +install-dotfiles: + cd dotfiles && $(MAKE) install + +install-xdg-config-dir: + cd xdg-config-dir && $(MAKE) install + +uninstall: uninstall-bin uninstall-dotfiles uninstall-xdg-config-dir + +uninstall-bin: + cd bin && $(MAKE) uninstall + +uninstall-dotfiles: + cd dotfiles && $(MAKE) uninstall + +uninstall-xdg-config-dir: + cd xdg-config-dir && $(MAKE) uninstall diff --git a/bin/Makefile b/bin/Makefile new file mode 100644 index 0000000..9026d2f --- /dev/null +++ b/bin/Makefile @@ -0,0 +1,30 @@ +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . +.POSIX: +.SUFFIXES: +.SUFFIXES: .sh .c + +PREFIX= $(HOME) +BIN= ZZZ browser credentials fetch imgresize invidious rfcopen screenshot \ + tor-browser w3m-copy-link xsekrit + +all: $(BIN) + +clean: + rm -f $(BIN) + +install: all + mkdir -p $(PREFIX)/bin + cp -f $(BIN) $(PREFIX)/bin + cd $(PREFIX)/bin && chmod 555 $(BIN) + +uninstall: + cd $(PREFIX)/bin && rm -f $(BIN) diff --git a/bin/ZZZ.sh b/bin/ZZZ.sh new file mode 100644 index 0000000..9277d81 --- /dev/null +++ b/bin/ZZZ.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +doas true || exit $? + +printf "Hibernating in"; +for i in 3 2 1; do + printf " %d..." $i + sleep 1 +done +printf " now!\n" + +doas /usr/sbin/ZZZ "$@" +doas -L diff --git a/bin/browser.sh b/bin/browser.sh new file mode 100644 index 0000000..3e35f35 --- /dev/null +++ b/bin/browser.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +scp ~/.Xauthority _browser@localhost: +ssh -n _browser@localhost -- \ + env DISPLAY=${DISPLAY:-:0} /usr/local/bin/firefox "$@" diff --git a/bin/credentials.sh b/bin/credentials.sh new file mode 100644 index 0000000..cfaf1bf --- /dev/null +++ b/bin/credentials.sh @@ -0,0 +1,109 @@ +#!/bin/sh +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +usage() { + cat - <<. >&2 +Usage: + ${0##*/} [-2pu] service +. + exit 1 +} + +clip() { xclip -q -r -l 1 -sel clip 2>/dev/null; } + +get_user() { + echo user + sekrit get services/"$1"/user | clip +} + +get_pass() { + echo pass + sekrit get services/"$1"/pass | clip +} + +get_2fa() { + echo 2fa + otpcli_opts= + case $1 in + isnic) otpcli_opts="-H sha512 -d 8" + ;; + esac + sekrit get services/"$1"/2fa | otpcli $otpcli_opts | clip +} + +get_from_flags() { + user=$1 + pass=$2 + sfa=$3 + s=$4 + + if [ $user = yes ] && ! sekrit has services/"$s"/user; then + printf "%s: service \"%s\" has no user.\n" \ + "${0##*/}" "$s" >&2 + exit 1 + fi + if [ $pass = yes ] && ! sekrit has services/"$s"/pass; then + printf "%s: service \"%s\" has no pass.\n" \ + "${0##*/}" "$s" >&2 + exit 1 + fi + if [ $sfa = yes ] && ! sekrit has services/"$s"/2fa; then + printf "%s: service \"%s\" has no 2fa.\n" \ + "${0##*/}" "$s" >&2 + exit 1 + fi + + [ $user = yes ] && get_user "$s" + [ $pass = yes ] && get_pass "$s" + [ $sfa = yes ] && get_2fa "$s" +} + +get_all() { + s=$1 + if ! sekrit has services/"$s"/pass; then + printf "%s: Unknown service \"%s\".\n" \ + "${0##*/}" "$s" >&2 + exit 1 + fi + + sekrit has services/"$s"/user && get_user "$s" + get_pass "$s" + sekrit has services/"$s"/2fa && get_2fa "$s" +} + +sfa=no +pass=no +user=no +while getopts 2pu flag; do + case $flag in + 2) sfa=yes + ;; + p) pass=yes + ;; + u) user=yes + ;; + *) usage + ;; + esac +done +shift $(($OPTIND - 1)) + +if [ $# -ne 1 ] || [ -z "$1" ]; then + usage +fi +service=$1 + +if [ $sfa = yes ] || [ $pass = yes ] || [ $user = yes ]; then + get_from_flags $user $pass $sfa "$service" +else + get_all "$service" +fi diff --git a/bin/fetch.sh b/bin/fetch.sh new file mode 100644 index 0000000..5dc100c --- /dev/null +++ b/bin/fetch.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +usage() { + printf "Usage: %s [-T] URL [URLs...]\n" "${0##*/}">&2 + exit 1 +} + +torsocks=torsocks +while getopts T flag; do + case $flag in + T) torsocks= + ;; + *) usage + ;; + esac +done +shift $(($OPTIND - 1)) +if [ $# -eq 0 ]; then + usage +fi + +: ${ARCHIVE_BASEDIR:=~/tmp/archive} +mkdir -p "$ARCHIVE_BASEDIR" + +everything=$ARCHIVE_BASEDIR/everything +test -f "$everything" || touch "$everything" + +dir=$ARCHIVE_BASEDIR/$(date +%Y/%m/%d) +mkdir -p "$dir" || exit 1 + +rc=0 +for url; do + sha=$(printf "%s" "$url" | sha256) + outdir=$dir/$sha + + if grep -q "^$url\$" "$everything"; then + printf "%s: \"%s\" already fetched.\n" "${0##*/}" "$url" >&2 + printf "%s\n" "$outdir/file" + continue + fi + + mkdir -p "$outdir" + + { + $torsocks ftp -o "$outdir/file" "$url" \ + && printf "%s\n" "$url" >"$outdir/url" \ + && printf "%s\n" "$name" >"$outdir/name" \ + && printf "%s\n" "$url" >>"$everything" \ + && printf "%s\n" "$outdir/file" + } || rc=1 +done +exit $rc diff --git a/bin/imgresize.sh b/bin/imgresize.sh new file mode 100644 index 0000000..f1007dd --- /dev/null +++ b/bin/imgresize.sh @@ -0,0 +1,74 @@ +#!/bin/sh +# env +# Written in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +usage() { + cat - <<. >&2 +Usage: + ${0##*/} size in-file out-file + +"size" is WxH or Wx or xH. +. + exit 1 +} + +check_dimension_format() { + printf "%s\n" "$1" | grep -q "^[0-9]*x[0-9]*\$" \ + && [ "$1" != "x" ] +} + +if [ $# -ne 3 ] || ! check_dimension_format "$1"; then + usage +fi +if [ -z "$2" ]; then + printf "%s: Input file name can't be empty.\n" \ + "${0##*/}" >&2 + exit 1 +fi +if [ -z "$3" ]; then + printf "%s: Output file name can't be empty.\n" \ + "${0##*/}" >&2 + exit 1 +fi + +size=$1 +w=${size#x*} +h=${size%*x} +infile=$2 +outfile=$3 + +inprog= +case $infile in +*.jpg | *.jpeg) + inprog=jpegtopnm + ;; +*.png) inprog=pngtopam + ;; +*) printf "%s: Unknown input format.\n" "${0##*/}" >&2 + exit 1 + ;; +esac + +outprog= +case $outfile in +*.jpg | *.jpeg) + outprog=pnmtojpeg + ;; +*.png) outprog=pamtopng + ;; +*) printf "%s: Unknown output format.\n" "${0##*/}" >&2 + exit 1 + ;; +esac + +"$inprog" <"$infile" \ + | pamscale ${w:+-width "$w"} ${h:+-height "$h"} \ + | "$outprog" >"$outfile" diff --git a/bin/invidious.sh b/bin/invidious.sh new file mode 100644 index 0000000..8d77d61 --- /dev/null +++ b/bin/invidious.sh @@ -0,0 +1,54 @@ +#!/bin/sh +# env +# Written in 2019 by Leslie +# Modified in 2019 by Lucas +# CC0 1.0 Universal/Public domain - No rights reserved +# +# To the extent possible under law, the author(s) have dedicated all +# copyright and related and neighboring rights to this software to the +# public domain worldwide. This software is distributed without any +# warranty. You should have received a copy of the CC0 Public Domain +# Dedication along with this software. If not, see +# . + +usage() { + printf "Usage: %s url\n" "${0##*/}" >&2 + exit 1 +} + +if [ $# -ne 1 ]; then + usage +fi + +case $1 in +"https://invidio.us/watch?v="*) + ;; +*) printf "%s: Not an invidio.us url.\n" "${0##*/}" >&2 + exit 1 +esac + +video_id= +for param in $(printf "%s\n" "${1##*"?"}" | tr "&" "\n"); do + k=${param%%=*} + [ "$k" = v ] || continue + + v=${param#*=} + if [ ${#v} -ne 11 ]; then + printf "%s: "%s": not a video id.\n" "${0##*/}" "$v" >&2 + continue + fi + video_id=$v + break +done + +if [ -z "$video_id" ]; then + printf "%s: no video ID in URL.\n" "${0##*/}" >&2 + exit 1 +fi + +dl_option=$(ftp -o - "$1" 2>/dev/null \ + | grep "