aboutsummaryrefslogtreecommitdiffstats
path: root/.local
diff options
context:
space:
mode:
authorla-ninpre <leobrekalini@gmail.com>2021-07-12 16:27:52 +0300
committerla-ninpre <leobrekalini@gmail.com>2021-07-12 16:27:52 +0300
commite3bbee81de559c1b4dea7a83d46da3b4e00cc2a8 (patch)
tree697bca3add8a534bd6ed6a82308ef5869cc78393 /.local
parent2d5fa70da78d05147a4055c51c983b93a4bc32dd (diff)
downloaddotfiles-e3bbee81de559c1b4dea7a83d46da3b4e00cc2a8.tar.gz
dotfiles-e3bbee81de559c1b4dea7a83d46da3b4e00cc2a8.zip
move to GNU stow approach on managing dotfiles
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/fossil-update95
-rwxr-xr-x.local/bin/keylookup8
-rwxr-xr-x.local/bin/mocpnotify11
-rwxr-xr-x.local/bin/nimi_sewi10
-rwxr-xr-x.local/bin/paperbackup165
-rwxr-xr-x.local/bin/print_codes97
-rwxr-xr-x.local/bin/rand18
7 files changed, 0 insertions, 404 deletions
diff --git a/.local/bin/fossil-update b/.local/bin/fossil-update
deleted file mode 100755
index 5ea4d1e..0000000
--- a/.local/bin/fossil-update
+++ /dev/null
@@ -1,95 +0,0 @@
-#!/bin/sh
-
-SUDO=doas
-_fossil_co=$(fossil all ls -c | grep fossil) # fossil checkout location
-_ask_upgrade=1
-_ask_all=1
-_clean_build=0
-_make_jobs=8
-
-usage() {
- echo "usage: fossil-update [OPTIONS]"
- echo "options:"
- echo " -y upgrade without asking"
- echo " -a upgrade and turn off the fossil service(if it's running) without asking"
- echo " -c clean build, run 'make distclean' before building"
- echo " -h print this help message"
-}
-
-check_service() {
- _fsl_pid=$(pgrep -u root -f "$(which fossil)") && export _fsl_pid
- [ -n "$_fsl_pid" ] && {
- [ "$_ask_all" -ne 0 ] && {
- echo "fossil service is active. stop it? (Y/y)"
- read -r _stop_fsl
- case $_stop_fsl in
- [Yy] ) stop_service && return 0
- ;;
- * ) echo "upgrade is not possible" && exit 2
- ;;
- esac
- }
- stop_service
- }
-}
-
-stop_service() {
- # i am using systemd service to run fossil server
- $SUDO systemctl stop fossil
-}
-
-compile() {
- echo "configuring..." && \
- ./configure >/dev/null && \
- echo "building..." && make -j "$_make_jobs" >/dev/null \
- && echo "build done"
-}
-
-install() {
- check_service
- $SUDO make install >/dev/null && echo "upgrade done"
- [ -n "$_fsl_pid" ] && echo "don't forget to enable fossil service back" \
- || return 0
-}
-
-main() {
- cd "$_fossil_co" || return
- [ $_clean_build -gt 0 ] && {
- echo "cleaning previous build"
- [ -f Makefile ] && make distclean >/dev/null
- }
- fossil up trunk
- [ $_ask_all -eq 0 ] || [ $_ask_upgrade -eq 0 ] && {
- compile && install
- exit
- }
- echo "upgrade? (Y/y)" && \
- read -r _upgrade && \
- case $_upgrade in
- [Yy] ) compile && install
- ;;
- * ) exit 1
- ;;
- esac
-}
-
-while getopts yach opts
-do
- case "$opts" in
- y)
- _ask_upgrade=0
- ;;
- a)
- _ask_all=0
- ;;
- c)
- _clean_build=1
- ;;
- h|*)
- usage && exit 1
- ;;
- esac
-done
-
-main
-
diff --git a/.local/bin/keylookup b/.local/bin/keylookup
deleted file mode 100755
index 90e3a45..0000000
--- a/.local/bin/keylookup
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-main() {
- curl "http://hkps.pool.sks-keyservers.net/pks/lookup?op=get&search=0x$1"
-}
-
-main "$@"
-
diff --git a/.local/bin/mocpnotify b/.local/bin/mocpnotify
deleted file mode 100755
index f3aa72c..0000000
--- a/.local/bin/mocpnotify
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-case $1 in
- "next")
- notify-send -a mocp -t 3000 "now playing" "$2 - $3 [$4]"
- ;;
- "stop")
- notify-send -a mocp -t 3000 "mocp" "stopped playing"
- ;;
-esac
-
diff --git a/.local/bin/nimi_sewi b/.local/bin/nimi_sewi
deleted file mode 100755
index c21c40f..0000000
--- a/.local/bin/nimi_sewi
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-# generate random tokipona phrase(see nimisewi for details),
-# copy it to the clipboard and send notification with it
-
-_nimi_sewi=$(nimisewi)
-
-echo "$_nimi_sewi" | xclip -sel clipboard
-
-notify-send -a nimi_sewi -t 2000 "nimi sewi" "$_nimi_sewi"
diff --git a/.local/bin/paperbackup b/.local/bin/paperbackup
deleted file mode 100755
index 4300241..0000000
--- a/.local/bin/paperbackup
+++ /dev/null
@@ -1,165 +0,0 @@
-#!/bin/sh -e
-
-# Copyright (c) 2021, la-ninpre
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-#
-# ---------------------------------------------------------------------- #
-#
-# small script to backup secret gpg keys using paperkey and qrencode.
-#
-# basic usage:
-#
-# $ paperbackup -u user@email.com
-#
-# by default exports minimized public key and paperkeyed secret key
-# to qr-encoded images, which then are combined into one image for
-# easy printing.
-#
-# dependencies:
-# - gpg (obviously)
-# - paperkey
-# - qrencode
-# - imagemagick (optional, use -n to disable montage)
-
-usage() {
- echo "usage: ${0##*/} [OPTIONS]"
- echo
- echo "options:"
- echo " -u, --uid {UID}"
- echo " gpg keyid or uid (this is mandatory)"
- echo " -l, --level {L,M,Q,H}"
- echo " qrencode correction level"
- echo " -t, --term"
- echo " output to terminal instead of png image"
- echo " -n, --nomontage"
- echo " disable composing qrcodes to one image"
- echo " -h, --help"
- echo " print usage information"
- echo
-}
-
-check_uid() {
- [ -z "$1" ] && echo "uid could not be empty" && exit 1
-
- if ! gpg -K "$1" >/dev/null
- then
- exit 1
- fi
-
- PB_UID="$1"
-}
-
-check_corr_lvl() {
- case "$1" in
- l|L|m|M|q|Q|h|H)
- PB_CORR_LVL="$1"
- ;;
- *)
- echo "correction level should be one of L,M,Q,H"
- usage
- exit 1
- ;;
- esac
-}
-
-qr_encode() {
- PB_QRENCODE_FLAGS="-8 -l $PB_CORR_LVL -t $PB_TYPE"
-
- case "$PB_TYPE" in
- png)
- PB_QRENCODE_FLAGS="$PB_QRENCODE_FLAGS -o $1"
- ;;
- UTF8)
- ;;
- *)
- exit 1
- ;;
- esac
-
- # i don't know if it is safe to do so, but it's very convenient
- # shellcheck disable=SC2086
- qrencode $PB_QRENCODE_FLAGS
-}
-
-get_pubkey() {
- [ -n "$1" ] && gpg --export --export-options export-minimal "$1" \
- | qr_encode "$1-pubkey.png"
-}
-
-get_seckey() {
- [ -n "$1" ] && gpg --export-secret-key "$1" \
- | paperkey --output-type raw | qr_encode "$1-seckey.png"
-}
-
-montage_keys() {
- montage \
- -pointsize 18 \
- -title "\nsecret key backup for $PB_UID\n$PB_DATE" \
- -label pubkey "$PB_UID-pubkey.png" \
- -label seckey "$PB_UID-seckey.png" \
- -mode concatenate \
- "$PB_UID-keys.png"
-
- rm -f "$PB_UID-pubkey.png" "$PB_UID-seckey.png"
-}
-
-main() {
- PB_TYPE="png"
- PB_CORR_LVL="H"
- PB_DATE=$(date "+%F %T")
- PB_MONTAGE=1
-
- while [ -n "$1" ]
- do
- case "$1" in
- --uid|-u)
- shift
- check_uid "$1"
- ;;
- --level|-l)
- shift
- check_corr_lvl "$1"
- ;;
- --term|-t)
- PB_TYPE="UTF8"
- ;;
- --nomontage|-n)
- PB_MONTAGE=0
- ;;
- --help|-h)
- echo "backup secret gpg key using paperkey and qrencode"
- echo
- usage
- exit
- ;;
- *)
- usage
- exit 1
- ;;
- esac
- shift
- done
-
- [ -z "$PB_UID" ] && echo "please specify uid or keyid" && exit 1;
-
- get_pubkey "$PB_UID" && get_seckey "$PB_UID"
-
- [ "$PB_TYPE" = "png" ] \
- && [ "$PB_MONTAGE" -eq 1 ] \
- && montage_keys
-
- exit 0
-}
-
-main "$@"
diff --git a/.local/bin/print_codes b/.local/bin/print_codes
deleted file mode 100755
index bb8b708..0000000
--- a/.local/bin/print_codes
+++ /dev/null
@@ -1,97 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2021, la-ninpre
-#
-# Permission to use, copy, modify, and/or distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-
-# small script to create page with qr-coded recovery tokens for otp
-# uses: qrencode, imagemagick(convert, montage)
-#
-# file with codes should be in following format:
-# - recovery codes should be on separate lines
-# - every line beginning with # is ignored
-
-QRENCODE_ERR_CORR_LEVEL=H
-CODES_KEEP_PNG=0
-CODES_MAKE_PDF=0
-
-usage() {
- echo "create qr-coded recovery tokens for easy printing"
- echo
- echo "USAGE:"
- echo " $0 [OPTIONS] <text-file>"
- echo
- echo "OPTIONS:"
- echo " -k keep png files with qrcodes"
- echo " -l {L,M,Q,H}"
- echo " set qrencode error correction level"
- echo " -p produce pdf instead of image"
- echo " -h print this help message"
- echo
-}
-
-while getopts kl:ph arg
-do
- case "$arg" in
- k) CODES_KEEP_PNG=1
- ;;
- l) case $OPTARG in
- [lL]) QRENCODE_ERR_CORR_LEVEL=L ;;
- [mM]) QRENCODE_ERR_CORR_LEVEL=M ;;
- [qQ]) QRENCODE_ERR_CORR_LEVEL=Q ;;
- [hH]) QRENCODE_ERR_CORR_LEVEL=H ;;
- *) echo "error correction level should be one of L, M, Q or H"
- exit 1 ;;
- esac
- ;;
- p) CODES_MAKE_PDF=1
- ;;
- h|*) usage && exit 1
- ;;
- esac
-done
-
-shift $((OPTIND - 1))
-
-[ $# -ne 1 ] && usage && exit 1
-
-CODES_FILE="$1"
-CODES_BASENAME="${CODES_FILE%%.*}"
-CODES_EXT="${CODES_FILE##*.}"
-CODES_DIR="$PWD/${CODES_BASENAME}_${CODES_EXT}_dir"
-CODES_DATE="$(date +'%Y-%m-%d %H:%M')"
-CODES_OUTPUT="${CODES_BASENAME}_qrcodes"
-CODES_OUT_IMG="${CODES_OUTPUT}.png"
-CODES_OUT_PDF="${CODES_OUTPUT}.pdf"
-
-rm -f "$CODES_OUT_IMG" "$CODES_OUT_PDF"
-[ -d "$CODES_DIR" ] && rm -rf "$CODES_DIR"
-mkdir "$CODES_DIR"
-
-sed -e '/^#.*/ d' -e '/^\s*$/ d' < "$CODES_FILE" \
- | xargs -I{} \
- qrencode -l "$QRENCODE_ERR_CORR_LEVEL" -t png -d 150 \
- -o "$CODES_DIR/{}-code.png" {}
-
-montage -title "\n$CODES_FILE\n$CODES_DATE" \
- "$CODES_DIR/*-code.png" -page a4 -geometry 128x128\> "$CODES_OUT_IMG"
-
-[ "$CODES_MAKE_PDF" -ne 0 ] && {
- convert \( -size 1240x1754 xc: \) "$CODES_OUT_IMG" \
- -composite "$CODES_OUT_PDF"
- [ "$CODES_KEEP_PNG" -eq 0 ] && rm -f "$CODES_OUT_IMG"
- }
-
-[ "$CODES_KEEP_PNG" -eq 0 ] && rm -rf "$CODES_DIR" || exit 0
-
diff --git a/.local/bin/rand b/.local/bin/rand
deleted file mode 100755
index 795885b..0000000
--- a/.local/bin/rand
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-# rand (inspired by https://rgz.ee/random.html)
-#
-# generate random string from charset as first argument and length as second
-#
-# example:
-# $ rand '1-9a-f' 10
-# > 329402aa42
-#
-# defaults:
-# charset -- all printable characters and space
-# length -- 25
-
-[ -z $1 ] && charset=' -~' || charset=$1
-[ -z $2 ] && length=25 || length=$2
-
-tr -cd "$charset" < /dev/urandom | fold -w "$length" | head -n 1