Cleaning house

This commit is contained in:
Daniel Lundin 2020-09-27 13:56:54 +02:00
parent 17be0441c5
commit af1f0bc926
110 changed files with 50 additions and 6585 deletions

View file

@ -1,2 +0,0 @@
#!/bin/sh
exec alacritty --config-file /home/dln/.config/alacritty/alacritty-light.yml "$@"

View file

@ -1,3 +0,0 @@
#!/bin/bash
set -e
bw-ssh-add id_rsa id_rsa_embark

View file

@ -1,57 +0,0 @@
#!/bin/bash
set -eu
AUTO_LOCK=3600
BW_SESSION=
exit_error() {
echo "$2"
keyctl purge user bw_master || true
keyctl purge user bw_session || true
exit "$1"
}
ask_password() {
systemd-ask-password --keyname=bw_master --accept-cached --timeout=10 "Master Password: " \
| bw unlock --raw 2>/dev/null || exit_error $? "Could not unlock vault"
}
get_session_key() {
if [ $AUTO_LOCK -eq 0 ]; then
keyctl purge user bw_session &>/dev/null
BW_SESSION=$(ask_password)
else
if ! key_id=$(keyctl request user bw_session 2>/dev/null); then
session=$(ask_password)
[[ -z "$session" ]] && exit_error 1 "Could not unlock vault"
key_id=$(echo "$session" | keyctl padd user bw_session @u)
fi
keyctl timeout "$key_id" $AUTO_LOCK
BW_SESSION=$(keyctl pipe "$key_id")
fi
}
get_session_key
folder=$(bw list folders --session ${BW_SESSION} --search ssh | jq -r '.[].id')
items=$(bw list items --session ${BW_SESSION} --folderid ${folder})
keys="$@"
if [[ -z "$keys" ]]; then
keys=$(jq -r '.[].name' <<< $items | fzf -1 -0)
fi
for key in $keys; do
_tmp=$(mktemp -d)
cd $_tmp
mkdir -p $(dirname $key)
ln -s /dev/stdin $key
function cleanup {
rm -rf $_tmp
}
trap cleanup EXIT
jq -r ".[] | select(.name == \"${key}\") | .notes" <<< $items | ssh-add $key
done

View file

@ -1,4 +0,0 @@
#!/bin/sh
set -e
# exec echo -en "\x1b]52;c;$(base64 -w0)\x07"
printf "\033]52;c;$(base64 -w0)\a"

BIN
bin/dwm

Binary file not shown.

View file

@ -1,12 +0,0 @@
#!/bin/bash
set -e
if [ "$#" -lt 2 ]; then
echo "Usage: ${0} [kubectl options] secret key"
exit 0
fi
secret="${@:$(($#-1)):1}"
key="${@:$(($#)):1}"
set -- "${@:1:$(($#-2))}"
kubectl get secret "$@" "${secret}" -o "go-template={{index .data \"${key}\"}}" | base64 -d

View file

@ -1,8 +0,0 @@
#!/bin/bash
set -xeuo pipefail
selector="$1"
shift
pod=$(kubectl get pods -l ${selector} --field-selector=status.phase=Running -o template --template="{{with index .items 0}}{{.metadata.name}}{{end}}")
kubectl port-forward $pod "$@"

View file

@ -1,3 +0,0 @@
#!/bin/bash
set -xeuo pipefail
kubectl config set-context $(kubectl config current-context) --namespace "$1"

View file

@ -1,8 +0,0 @@
#!/bin/bash
set -xe
ns=$1
shift
selector="$@"
pod=$(kubectl get pods --namespace=$ns $selector -o template --template="{{with index .items 0}}{{.metadata.name}}{{end}}")
exec kubectl --namespace=$ns exec -ti $pod /bin/sh

View file

@ -1,4 +0,0 @@
#!/bin/bash
lpass login --trust dln@eintr.org
lp-ssh-add ssh/id_rsa
lp-ssh-add ssh/id_rsa_embark

View file

@ -1,23 +0,0 @@
#!/bin/bash
set -e
if [[ "$SSH_ASKPASS" == $0 ]]; then
exec lpass show --field Passphrase $_KEYID
fi
if [[ -z "$1" ]]; then
_key=$(lpass ls --color=never ssh | cut -d ' ' -f1 | fzf -1 -0)
exec $0 $_key
fi
_tmp=$(mktemp -d)
cd $_tmp
mkdir -p $(dirname $1)
ln -s /dev/stdin $1
function cleanup {
rm -rf $_tmp
}
trap cleanup EXIT
lpass show --field='Private Key' $1 | SSH_ASKPASS=$0 _KEYID=$1 ssh-add $1

View file

@ -1,19 +0,0 @@
#!/usr/bin/env python
from i3ipc import Connection
import sys
try:
mark=sys.argv[1]
except IndexError:
mark=None
c = Connection()
c.command('workspace 1')
# Focus on widest window
windows = c.get_tree().find_focused().workspace().descendants()
w = sorted(windows, key=lambda w: w.window_rect.width)[-1]
w.command('focus')
if mark:
w.command(f'swap container with mark {mark}')

View file

@ -1,21 +0,0 @@
#!/bin/bash
# Date and time
date_fmt=$(date "+%b %d")
current_time=$(date "+%H:%M")
#############
# Commands
#############
battery_charge=$(upower --show-info $(upower --enumerate | grep 'BAT') | egrep "percentage" | awk '{print $2}')
battery_status=$(upower --show-info $(upower --enumerate | grep 'BAT') | egrep "state" | awk '{print $2}')
if [ "$battery_status" = "discharging" ]; then
battery_pluggedin='⚠'
else
battery_pluggedin='⚡'
fi
echo "$battery_pluggedin$battery_charge | $date_fmt | $current_time "
sleep 5
exec $0

View file

@ -1,7 +0,0 @@
#!/bin/bash
set -exo pipefail
app_id="$1"
swaymsg -t get_tree \
| jq -r "recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.app_id==\"${app_id}\")|select(.focused==false)|\"[con_id=\"+ (.id|tostring) + \"] focus\"" \
| head -n 1 \
| xargs -e swaymsg