summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbackup.sh4
-rwxr-xr-xch7
-rwxr-xr-xconnect-screen53
-rwxr-xr-xdump-ff-history2
-rwxr-xr-xget-hosts7
-rwxr-xr-xhttpscert2
-rwxr-xr-xhttpstest2
-rwxr-xr-xkd4
-rwxr-xr-xkill-ssh3
-rwxr-xr-xmailto-mutt6
-rwxr-xr-xmasterkey-sign.sh8
-rwxr-xr-xmasterkey.pl34
-rwxr-xr-xmute-toggle3
-rwxr-xr-xmutt-gpg-config-namespaced.sh14
-rwxr-xr-xmutt-search-address-book12
-rwxr-xr-xpulse-loopback9
-rwxr-xr-xqrcode3
m---------remotes/seblu-archutils0
-rwxr-xr-xsetup-noise-suppression21
-rwxr-xr-xsort-ip4
-rwxr-xr-xsupercherry7
-rwxr-xr-xsvn-commit-git-patch8
-rwxr-xr-xterm-open8
-rwxr-xr-xwg-genkey6
24 files changed, 215 insertions, 12 deletions
diff --git a/backup.sh b/backup.sh
index 2301ce9..f1a90e8 100755
--- a/backup.sh
+++ b/backup.sh
@@ -127,7 +127,7 @@ backup_borg() {
local src=("$@")
local -a options=(
--verbose
- --numeric-owner
+ --numeric-ids
--compression lz4
--exclude-from "$TMPDIR/exclude-list-borg"
)
@@ -140,7 +140,7 @@ backup_borg() {
# Only purge when doing full backups. Increases partial backup speed and
# ensure that we have at least one recent full backup when we purge.
- if [[ $backup_prefix == 'backup-' ]]; then
+ if [[ $backup_prefix == 'backup' ]]; then
borg prune --prefix "backup-" --keep-within 7d --keep-daily 7 --keep-weekly 12 --keep-monthly 6 --keep-yearly 0 -v "$dst"
borg prune --prefix "partial-" --keep-within 31d -v "$dst"
fi
diff --git a/ch b/ch
index 2211fb7..b76acaa 100755
--- a/ch
+++ b/ch
@@ -46,6 +46,11 @@ if [[ ! -d "$CHROOTS" ]]; then
return 1
fi
+# Always build official packages reproducibly
+if [[ ! -v SOURCE_DATE_EPOCH ]]; then
+ export SOURCE_DATE_EPOCH=$(date +%s)
+fi
+
__genchroot() {
sudo btrfs subvolume snapshot "$chrootdir/root" "$copydir"
}
@@ -175,6 +180,7 @@ chclean() {
continue
fi
+ sudo btrfs subvolume delete "$copy/var/lib/portables" || true
sudo btrfs subvolume delete "$copy/var/lib/machines" || true
sudo btrfs subvolume delete "$copy"
sudo rm -f "${copy%/}.lock"
@@ -184,6 +190,7 @@ chclean() {
chclean-single() {
__chrootalias_resolve_create "$1" || return
if [[ -e $copydir ]]; then
+ sudo btrfs subvolume delete "$copydir/var/lib/portables" || true
sudo btrfs subvolume delete "$copydir/var/lib/machines" || true
sudo btrfs subvolume delete "$copydir"
sudo rm -f "${copydir%/}.lock"
diff --git a/connect-screen b/connect-screen
index 58fa6cd..4f4403e 100755
--- a/connect-screen
+++ b/connect-screen
@@ -4,15 +4,46 @@ xrandr --output VIRTUAL1 --off
xrandr --output HDMI2 --off
xrandr --output DP1 --off
xrandr --output DP2 --off
+xrandr --output DP1-1 --off
+xrandr --output DP1-2 --off
+xrandr --output DP2-1 --off
+xrandr --output DP2-2 --off
xset r rate 250 50
has_hdmi2=$(xrandr | grep '^HDMI2 connected')
has_dp1=$(xrandr | grep '^DP1 connected')
+has_dp1_1=$(xrandr | grep '^DP1-1 connected')
+has_dp1_2=$(xrandr | grep '^DP1-2 connected')
has_dp2=$(xrandr | grep '^DP2 connected')
+has_dp2_2=$(xrandr | grep '^DP2-2 connected')
-if [[ $has_hdmi2 && $has_dp1 ]]; then
- xrandr --output DP1 --right-of eDP1 --auto
+output_left=""
+output_right=""
+
+if [[ $has_dp1_1 && $has_dp1_2 ]]; then
+ xrandr --output DP1-2 --right-of eDP1 --mode 640x480 -r 60
+ xrandr --output DP1-1 --right-of DP1-2 --mode 2560x1440 -r 60
+ xrandr --output DP1-1 --primary
+ output_left=DP1-2
+ output_right=DP1-1
+elif [[ $has_hdmi2 && $has_dp1_2 ]]; then
+ xrandr --output DP1-2 --right-of eDP1 --auto
+ xrandr --output HDMI2 --right-of DP1-2 --auto
+ xrandr --output DP1-2 --primary
+ output_left=DP1-2
+ output_right=HDMI2
+elif [[ $has_hdmi2 && $has_dp1 ]]; then
+ xrandr --output DP1-1 --right-of eDP1 --auto
xrandr --output HDMI2 --right-of DP1 --auto
+ xrandr --output DP1 --primary
+ output_left=DP1-1
+ output_right=HDMI2
+elif [[ $has_dp1 && $has_dp2_2 ]]; then
+ xrandr --output DP2-2 --right-of eDP1 --auto
+ xrandr --output DP1 --right-of DP2-2 --auto
+ xrandr --output DP2-2 --primary
+ output_left=DP2-2
+ output_right=DP1
else
if [[ $has_hdmi2 ]]; then
xrandr --output HDMI2 --right-of eDP1 --auto
@@ -25,6 +56,24 @@ else
if [[ $has_dp2 ]]; then
xrandr --output DP2 --right-of eDP1 --auto
fi
+
+ xrandr --output eDP1 --primary
fi
xkbcomp .xkbmap "$DISPLAY"
+
+# Reorganize workspaces across displays
+if [[ $output_left != "" ]] && [[ $output_right != "" ]]; then
+ workspaces_left=(3 4)
+ workspaces_right=(1 2 5 6 7 8 9 10 11 12 13 14 15)
+ for workspace in "${workspaces_left[@]}"; do
+ i3-msg "[workspace=\"$workspace\"]" move workspace to output $output_left
+ done
+
+ for workspace in "${workspaces_right[@]}"; do
+ i3-msg "[workspace=\"$workspace\"]" move workspace to output $output_right
+ done
+
+ i3-msg "workspace 3"
+ i3-msg "workspace 1"
+fi
diff --git a/dump-ff-history b/dump-ff-history
index 5f16837..33cf7f0 100755
--- a/dump-ff-history
+++ b/dump-ff-history
@@ -5,7 +5,7 @@ trap "rm -rf '${TMPDIR}'" EXIT TERM
cp -n ~/.mozilla/firefox/*.default/places.sqlite* "$TMPDIR"
-sqlite3 "$TMPDIR/places.sqlite" "SELECT datetime(visit_date/1000000,'unixepoch') AS visit_date, url, title
+sqlite3 "$TMPDIR/places.sqlite" "SELECT datetime(visit_date/1000000,'unixepoch', 'localtime') AS visit_date, url, title
FROM moz_places, moz_historyvisits
WHERE moz_places.id = moz_historyvisits.place_id AND visit_date/1000000 > $(date +%s -d "${1:-2 months ago}") AND visit_date/1000000 < $(date +%s -d "${2:-now}")
ORDER BY visit_date"
diff --git a/get-hosts b/get-hosts
new file mode 100755
index 0000000..e006222
--- /dev/null
+++ b/get-hosts
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+# Output filtered list of hostnames from known_hosts
+
+cut -d\ -f1 ~/.ssh/known_hosts ~/.ssh/known_hosts_work | tr , "\n" \
+ | sed -r 's#(_ecdsa|_rsa|_ed25519|_dsa)$##' | sort -u \
+ | grep -P "$@"
diff --git a/httpscert b/httpscert
index c2834c0..e5d44b1 100755
--- a/httpscert
+++ b/httpscert
@@ -1,3 +1,3 @@
#!/bin/bash
-httpstest $1 | sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -text
+httpstest "$@"| sed -n '/-----BEGIN/,/-----END/p' | openssl x509 -text
diff --git a/httpstest b/httpstest
index e4fb0da..93dc9e0 100755
--- a/httpstest
+++ b/httpstest
@@ -2,4 +2,4 @@
# usage: httpstest <domain>
-openssl s_client -servername $1 -connect $1:443 </dev/null
+openssl s_client -servername $1 -connect $1:${2:-443} </dev/null
diff --git a/kd b/kd
new file mode 100755
index 0000000..2bb5c48
--- /dev/null
+++ b/kd
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+kubectx --current
+kubens --current
diff --git a/kill-ssh b/kill-ssh
new file mode 100755
index 0000000..6d171df
--- /dev/null
+++ b/kill-ssh
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+pkill -f '^ssh: '"$HOME"'/.ssh/multi/.* \[mux\]$'
diff --git a/mailto-mutt b/mailto-mutt
new file mode 100755
index 0000000..fd53434
--- /dev/null
+++ b/mailto-mutt
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+# support spaces after "mailto:" even if they are probably wrong
+mailto=$(printf "%s" "$1" | sed -r 's#^mailto:\s*#mailto:#')
+
+term-open mutt "$mailto"
diff --git a/masterkey-sign.sh b/masterkey-sign.sh
index 4ea97ce..c83974b 100755
--- a/masterkey-sign.sh
+++ b/masterkey-sign.sh
@@ -4,8 +4,16 @@ set -e
key=$1
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+
gpg --quiet --recv-keys "$key"
# this signs ALL uids...
#printf 'y\ny\n' | gpg --default-key 0xA88E23E377514E00 --command-fd 0 --batch --quiet --sign-key "$key"
gpg --default-key 0xA88E23E377514E00 --only-sign-text-ids --edit-key "$key"
gpg --send-keys "$key"
+
+cd ~/git/arch/archlinux-keyring
+
+gpg --export "$key" > "$TMPDIR/key"
+./keyringctl import "$TMPDIR/key"
diff --git a/masterkey.pl b/masterkey.pl
index d532dfb..e82b350 100755
--- a/masterkey.pl
+++ b/masterkey.pl
@@ -67,6 +67,8 @@ on behalf of {$sender_name} ({$sender_key})
Your GPG key ({$recipient_key})
has been successfully signed by an Arch Linux master key.
+A copy of your signed key is attached to this message.
+
Best Regards,
SAMKIVS (Simple Automated Master Key Identity Verification System)
on behalf of {$sender_name} ({$sender_key})
@@ -98,6 +100,10 @@ on behalf of {$sender_name} ({$sender_key})
my $mail_body = $templates{$command}{'body'};
my $token = random_string('.' x 25);
+ if ($command eq 'verification') {
+ validate_key_parameters($id);
+ }
+
my $msg = build_email($command, $opts{from}, quotemeta($opts{'from-address'}), $id, $recipient_address_regex, $mail_subject, $mail_body, $token);
if ($command eq 'verification') {
@@ -138,19 +144,22 @@ fun gpg_get_users($key) {
my $user = Encode::decode('utf8', $uid->as_string);
unless ($user =~ m/^(?<name>.*?) (?:\((?<comment>.*?)\) )?\<(?<email>.*?@.*?)\>$/) {
- die "Failed to parse GPG user information for key $key; got $user";
+ warn "Warning: Failed to parse GPG user information for key $key; got '$user'. Ignoring...\n";
}
push @users, {%+};
}
+ die "Failed to parse even one UID from key. Giving up" unless (0+@users > 0);
+
return \@users;
}
fun gpg_get_user($key, $email_regex) {
my $users = gpg_get_users($key);
- return $users->[0] if $users->@* == 1;
+ # Disable this since we only want to use the userid matching the regex
+ #return $users->[0] if $users->@* == 1;
my $user = first {$_->{email} =~ m/$email_regex/} $users->@*;
@@ -168,6 +177,17 @@ fun gpg_get_user($key, $email_regex) {
return $user;
}
+fun validate_key_parameters($key) {
+ system("sq-keyring-linter <(gpg --export '$key')");
+ system("gpg --export '$key' | hokey lint");
+
+ print "Are there validation errors in the output above or is anything else wrong with the key? (Y/n) ";
+ my $answer = <STDIN>;
+ chomp($answer);
+
+ die "Key has validation errors" unless $answer eq 'n' or $answer eq 'N';
+}
+
fun build_email($command, $sender_key, $sender_address_regex, $recipient_key, $recipient_address_regex, $subject, $body, $token) {
# get from gpg keys
my ($sender_name, $sender_addr) = gpg_get_user($sender_key, $sender_address_regex)->@{qw(name email)};
@@ -203,6 +223,16 @@ fun build_email($command, $sender_key, $sender_address_regex, $recipient_key, $r
Data => [$body],
);
+ if ($command eq 'confirmation') {
+ my $recipient_key_data = `gpg --armor --export $recipient_key`;
+ $msg->attach(
+ Data => $recipient_key_data,
+ Filename => "$recipient_key-signed.asc",
+ Encoding => 'quoted-printable',
+ );
+ }
+
+
$msg->add("Message-ID", Email::MessageID->new->in_brackets);
$msg->replace("Return-Path", "<$sender_addr>");
diff --git a/mute-toggle b/mute-toggle
new file mode 100755
index 0000000..e3359eb
--- /dev/null
+++ b/mute-toggle
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+bash -c "pacmd list-sources | grep -oP 'index: \\d+' | awk '{ print \$2 }' | xargs -I{} pactl set-source-mute {} ${1:-toggle}"
diff --git a/mutt-gpg-config-namespaced.sh b/mutt-gpg-config-namespaced.sh
new file mode 100755
index 0000000..5921436
--- /dev/null
+++ b/mutt-gpg-config-namespaced.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# Add a --trustdb-name namespace to the gpg config options for mutt.
+# Use like this in muttrc:
+# source "mutt-gpg-config-namespaced /etc/Muttrc.gpg.dist foo"|
+
+set -eu
+
+sourcefile=$1
+dbname=$2
+
+grep -E -v "^\s*(#|$)" "$sourcefile" \
+ | grep 'command=' \
+ | sed "s#gpg #gpg --trustdb-name=$dbname #"
diff --git a/mutt-search-address-book b/mutt-search-address-book
new file mode 100755
index 0000000..bc5352a
--- /dev/null
+++ b/mutt-search-address-book
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+pattern=$1
+
+echo 'searching for '$pattern' ...'
+
+get_matches() {
+ gpg --list-keys --with-colons | grep '^uid:' | cut -d: -f10 | sed -rn 's#(.*) <([^>]+).*#\2\t\1\tgpg-mail#p' | grep -F "$pattern"
+ khard email --parsable --remove-first-line --search-in-source-files "$pattern"
+}
+
+get_matches | sort -u
diff --git a/pulse-loopback b/pulse-loopback
new file mode 100755
index 0000000..a756746
--- /dev/null
+++ b/pulse-loopback
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+source=$1
+
+id=$(pactl load-module module-loopback channels=1 source=$source)
+echo "$id"
+trap "pactl unload-module $id" EXIT TERM INT
+echo "press enter to remove loopback"
+read
diff --git a/qrcode b/qrcode
new file mode 100755
index 0000000..3051792
--- /dev/null
+++ b/qrcode
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+qrencode -o - "$1" --size 5 | feh -
diff --git a/remotes/seblu-archutils b/remotes/seblu-archutils
-Subproject 0d913bff7b232d224e1ca8e727bb4881481fa09
+Subproject c74d15cd127427c8d88db67ad789c23fb2bf9db
diff --git a/setup-noise-suppression b/setup-noise-suppression
new file mode 100755
index 0000000..dd0e9ce
--- /dev/null
+++ b/setup-noise-suppression
@@ -0,0 +1,21 @@
+#!/bin/bash
+#
+# Set up rnnoise-based microphone noise filtering
+#
+# - Install the ladspa noise-suppression plugin form here: https://github.com/werman/noise-suppression-for-voice
+# - Then use this script to play around with the settings until you have something that works well.
+# + Find potential sources with: pacmd list-sources | awk -F'[<>]' '/name: /{print $2}'
+# - Finally, put the "load-module *" lines into your /etc/pulse/default.pa for persistence.
+
+source="$1"
+control="${2:-40}"
+channels="${3:-2}"
+
+pacmd unload-module module-null-sink
+
+pacmd load-module module-null-sink sink_name=mic_denoised_out rate=48000 format=s16le
+pacmd load-module module-ladspa-sink sink_name=mic_raw_in sink_master=mic_denoised_out label=noise_suppressor_mono plugin=/usr/lib/ladspa/librnnoise_ladspa.so control="$control",20,0,0,0
+pacmd load-module module-loopback source="$source" sink=mic_raw_in channels="$channels" source_dont_move=true sink_dont_move=true latency_msec=1
+
+# remap to regular source for chromium
+pacmd load-module module-remap-source source_name=denoised master=mic_denoised_out.monitor channels="$channels"
diff --git a/sort-ip b/sort-ip
new file mode 100755
index 0000000..0a7f56b
--- /dev/null
+++ b/sort-ip
@@ -0,0 +1,4 @@
+#!/bin/bash
+# Sort ipv4 addresses
+
+sort -t . -n -k 1,1 -k 2,2 -k 3,3 -k 4,4
diff --git a/supercherry b/supercherry
index fad2460..568b342 100755
--- a/supercherry
+++ b/supercherry
@@ -5,6 +5,11 @@
base="${1:-master}"
+remotes=("${@:2}")
+
+if [[ "${#remotes[@]}" -eq 0 ]]; then
+ remotes=(refs/remotes)
+fi
RED="\e[1;31m"
GREEN="\e[0;32m"
@@ -15,7 +20,7 @@ GRAY="\e[0;37m"
NONE="\e[0;0m"
-for ref in $(git for-each-ref --format='%(refname)' refs/remotes); do
+for ref in $(git for-each-ref --format='%(refname)' "${remotes[@]}"); do
sha1="$(git rev-parse --verify $ref)"
if [ "$(git merge-base $ref $base)" = "$sha1" ]; then
continue
diff --git a/svn-commit-git-patch b/svn-commit-git-patch
index 54b345d..b25be44 100755
--- a/svn-commit-git-patch
+++ b/svn-commit-git-patch
@@ -49,5 +49,11 @@ while (my $line = <$fh>) {
$message = "$subject\n\n$message";
-system(qw(svn patch --strip 1), $patchfile);
+system(qw(patch -p 3 -i), $patchfile);
+
+system(qw(svn diff));
+
+print "Commit message will be:\n$message\n\n\n";
+print "Press Enter to commit";
+<STDIN>;
system(qw(svn commit -m), $message);
diff --git a/term-open b/term-open
index e61c7fc..d47367c 100755
--- a/term-open
+++ b/term-open
@@ -1,10 +1,16 @@
#!/bin/bash
+logger "Running term-open with args: $*"
+
cmd=$1; shift
term=termite
if [[ $cmd = "mutt" ]]; then
- exec termite -e "mutt -e 'set autoedit=yes' -- $*"
+ if [[ "$*" = 'mailto:?'* ]]; then
+ exec termite -e "mutt -- $*"
+ else
+ exec termite -e "mutt -e 'set autoedit=yes' -- $*"
+ fi
fi
exec termite -e "$cmd -- $*"
diff --git a/wg-genkey b/wg-genkey
new file mode 100755
index 0000000..d7410e4
--- /dev/null
+++ b/wg-genkey
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+key=$(wg genkey)
+echo "private: $key"
+printf "public: "
+wg pubkey <<<"$key"