summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbrowser_launcher.pl6
-rwxr-xr-xconky-update-interval13
-rwxr-xr-xconnect-screen149
-rwxr-xr-xdbrel5
-rwxr-xr-xdd-parallel31
-rwxr-xr-xdecode-barcode9
-rwxr-xr-xdisconnect-screen15
-rwxr-xr-xdump-chrome-history29
-rwxr-xr-xdump-ff-history22
-rwxr-xr-xgen-perl-pkg19
-rwxr-xr-xgit-diff-gpg8
-rwxr-xr-xgrep-email3
-rwxr-xr-xgvim-term3
-rwxr-xr-xi3-continous-backup14
-rwxr-xr-xi3-dump-layout-all26
-rwxr-xr-xi3-load-layouts8
-rwxr-xr-xinvert-display1
-rwxr-xr-xmailer.pl3
-rw-r--r--mutt10
-rw-r--r--myip-dns3
-rwxr-xr-xpkgctl24
-rwxr-xr-xrofi-gpgpass80
-rwxr-xr-xrofi-hosts2
-rwxr-xr-xscreen-locker.sh23
-rwxr-xr-xsysinfo8
-rwxr-xr-xterm-open6
-rwxr-xr-xtoggle-nm19
-rwxr-xr-xtoggle-pulseaudio-mic-mute15
-rwxr-xr-xunload-pa4
-rwxr-xr-xupdate6
-rwxr-xr-xupdate-perl-pkg36
-rwxr-xr-xwireshark-remote3
32 files changed, 535 insertions, 68 deletions
diff --git a/browser_launcher.pl b/browser_launcher.pl
index 3bc2dfe..a77dc2a 100755
--- a/browser_launcher.pl
+++ b/browser_launcher.pl
@@ -14,6 +14,12 @@ use autodie qw(:all);
use Text::Template 'fill_in_string';
my $sites = {
+ 'ssh-git' => {
+ 'patterns' => [
+ qr|^ssh://(?:(?<username>\w+)@)?(?<domain>[\w.]+)(?::(?<port>\d+))?/(?<path>.*)\.git|,
+ ],
+ 'command' => ['firefox', 'https://{$domain}/{$path}'],
+ },
'youtube' => {
'patterns' => [
qr|^https://www.youtube.com|,
diff --git a/conky-update-interval b/conky-update-interval
new file mode 100755
index 0000000..94d794f
--- /dev/null
+++ b/conky-update-interval
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+set-conky-update-interval() {
+ sed -ri 's#^(update_interval) = .*,#\1 = '"$1"',#' ~/.i3/conkyrc-perl
+}
+
+if [[ $# -gt 0 ]]; then
+ set-conky-update-interval "$1"
+elif [[ "$(cat /sys/class/power_supply/ACAD/online)" = "0" ]]; then
+ set-conky-update-interval 3
+else
+ set-conky-update-interval 0.5
+fi
diff --git a/connect-screen b/connect-screen
index 4f4403e..271a6ee 100755
--- a/connect-screen
+++ b/connect-screen
@@ -1,71 +1,164 @@
#!/bin/bash
-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
+disconnect-screen
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_dp1=$(xrandr | grep '^DP-1 connected')
+has_dp3=$(xrandr | grep '^DP-3 connected')
+has_dp4=$(xrandr | grep '^DP-4 connected')
+has_dp3_1=$(xrandr | grep '^DP3-1 connected')
+has_dp3_2=$(xrandr | grep '^DP3-2 connected')
+has_dp4_1=$(xrandr | grep '^DP4-1 connected')
+has_dp4_2=$(xrandr | grep '^DP4-2 connected')
+has_dp_4_1=$(xrandr | grep '^DP-4-1 connected')
+has_dp_4_8=$(xrandr | grep '^DP-4-8 connected')
+has_dp_4_2=$(xrandr | grep '^DP-4-2 connected')
+has_dp_4_2_1=$(xrandr | grep '^DP-4-2-1 connected')
+has_dp_4_3_1=$(xrandr | grep '^DP-4-3-1 connected')
+has_dp_3_2_1=$(xrandr | grep '^DP-3-2-1 connected')
+has_dp_3_3_1=$(xrandr | grep '^DP-3-3-1 connected')
has_dp2=$(xrandr | grep '^DP2 connected')
has_dp2_2=$(xrandr | grep '^DP2-2 connected')
+home_wifi=true
+
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
+if [[ $has_dp_4_2_1 && $has_dp_4_3_1 ]]; then
+ xrandr --output DP-4-3-1 --right-of eDP-1 --mode 2560x1440 -r 60
+
+ # XXX: first 60, then 144 hz since sometimes the screen doesn't detect the signal otherwise
+ xrandr --output DP-4-2-1 --right-of DP-4-3-1 --mode 2560x1440 -r 60
+ xrandr --output DP-4-2-1 --right-of DP-4-3-1 --mode 2560x1440 -r 144
+ #for i in {0..10}; do
+ #xrandr --output DP-4-1 --right-of DP-4-8 --mode 2560x1440 -r 144 && continue
+ #sleep 1
+ #done
+ xrandr --output DP-4-3-1 --primary
+ output_left=DP-4-3-1
+ output_right=DP-4-2-1
+elif [[ $has_dp_3_2_1 && $has_dp_3_3_1 ]]; then
+ xrandr --output DP-3-3-1 --right-of eDP-1 --mode 2560x1440 -r 60
+
+ # XXX: first 60, then 144 hz since sometimes the screen doesn't detect the signal otherwise
+ xrandr --output DP-3-2-1 --right-of DP-3-3-1 --mode 2560x1440 -r 60
+ xrandr --output DP-3-2-1 --right-of DP-3-3-1 --mode 2560x1440 -r 144
+ #for i in {0..10}; do
+ #xrandr --output DP-4-1 --right-of DP-4-8 --mode 2560x1440 -r 144 && continue
+ #sleep 1
+ #done
+ xrandr --output DP-3-3-1 --primary
+ output_left=DP-3-3-1
+ output_right=DP-3-2-1
+elif [[ $has_dp_4_1 && $has_dp_4_8 ]]; then
+ xrandr --output DP-4-8 --right-of eDP-1 --mode 2560x1440 -r 60
+
+ # XXX: first 60, then 144 hz since sometimes the screen doesn't detect the signal otherwise
+ xrandr --output DP-4-1 --right-of DP-4-8 --mode 2560x1440 -r 60
+ xrandr --output DP-4-1 --right-of DP-4-8 --mode 2560x1440 -r 144
+ #for i in {0..10}; do
+ #xrandr --output DP-4-1 --right-of DP-4-8 --mode 2560x1440 -r 144 && continue
+ #sleep 1
+ #done
+ xrandr --output DP-4-8 --primary
+ output_left=DP-4-8
+ output_right=DP-4-1
+elif [[ $has_dp4_1 && $has_dp4_2 ]]; then
+ xrandr --output DP4-2 --right-of eDP-1 --mode 1920x1200 -r 60
+ xrandr --output DP4-1 --right-of DP4-2 --mode 2560x1440 -r 60
+ xrandr --output DP4-1 --primary
+ output_left=DP4-2
+ output_right=DP4-1
+elif [[ $has_dp_4_1 && $has_dp_4_2 ]]; then
+ xrandr --output DP-4-1 --right-of eDP-1 --auto
+ xrandr --output DP-4-2 --right-of DP-4-1 --auto
+ if [[ "$home_wifi" = "true" ]]; then
+ xrandr --output DP-4-1 --primary
+ fi
+ output_left=DP-4-1
+ output_right=DP-4-2
+elif [[ $has_dp3_1 && $has_dp3_2 ]]; then
+ xrandr --output DP3-2 --right-of eDP-1 --mode 1920x1200 -r 60
+ xrandr --output DP3-1 --right-of DP3-2 --mode 2560x1440 -r 60
+ xrandr --output DP3-1 --primary
+ output_left=DP3-2
+ output_right=DP3-1
elif [[ $has_hdmi2 && $has_dp1_2 ]]; then
- xrandr --output DP1-2 --right-of eDP1 --auto
+ xrandr --output DP1-2 --right-of eDP-1 --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 DP1-1 --right-of eDP-1 --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 DP2-2 --right-of eDP-1 --auto
xrandr --output DP1 --right-of DP2-2 --auto
xrandr --output DP2-2 --primary
output_left=DP2-2
output_right=DP1
+elif [[ $has_dp3 && $has_dp4 ]]; then
+ xrandr --output DP3 --right-of eDP-1 --auto
+ xrandr --output DP4 --right-of DP3 --auto
+ xrandr --output DP3 --primary
+ output_left=DP3
+ output_right=DP4
+elif [[ $has_dp1 && $has_dp4 ]]; then
+ xrandr --output DP1 --right-of eDP-1 --auto
+ xrandr --output DP4 --right-of DP1 --auto
+ xrandr --output DP1 --primary
+ output_left=DP1
+ output_right=DP4
+elif [[ $has_dp1 && $has_dp4_2 ]]; then
+ xrandr --output DP4-2 --right-of eDP-1 --auto
+ xrandr --output DP1 --right-of DP4-2 --auto
+ xrandr --output DP4-2 --primary
+ output_left=DP4-2
+ output_right=DP1
+elif [[ $has_dp4 && $has_dp3_2 ]]; then
+ xrandr --output DP3-2 --right-of eDP-1 --auto
+ xrandr --output DP4 --right-of DP3-2 --auto
+ xrandr --output DP3-2 --primary
+ output_left=DP3-2
+ output_right=DP4
+elif [[ $has_dp3 && $has_dp4_2 ]]; then
+ xrandr --output DP4-2 --right-of eDP-1 --auto
+ xrandr --output DP3 --right-of DP4-2 --auto
+ xrandr --output DP4-2 --primary
+ output_left=DP4-2
+ output_right=DP3
else
if [[ $has_hdmi2 ]]; then
- xrandr --output HDMI2 --right-of eDP1 --auto
+ xrandr --output HDMI2 --right-of eDP-1 --auto
fi
if [[ $has_dp1 ]]; then
- xrandr --output DP1 --right-of eDP1 --auto
+ xrandr --output DP-1 --right-of eDP-1 --auto
fi
if [[ $has_dp2 ]]; then
- xrandr --output DP2 --right-of eDP1 --auto
+ xrandr --output DP2 --right-of eDP-1 --auto
fi
xrandr --output eDP1 --primary
+ xrandr --output eDP-1 --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)
+# Reorganize workspaces across displays if at home
+if [[ $output_left != "" ]] && [[ $output_right != "" ]] && [[ "$home_wifi" = "true" ]]; then
+ workspaces_left=(4)
+ workspaces_right=(1 2 5 6 7 8 9 10 11 12 13 15)
+ # these don't need any handling, just for completeness
+ workspaces_laptop=(3)
+
for workspace in "${workspaces_left[@]}"; do
i3-msg "[workspace=\"$workspace\"]" move workspace to output $output_left
done
@@ -77,3 +170,5 @@ if [[ $output_left != "" ]] && [[ $output_right != "" ]]; then
i3-msg "workspace 3"
i3-msg "workspace 1"
fi
+
+conky-update-interval
diff --git a/dbrel b/dbrel
index 4c17642..bf0e51b 100755
--- a/dbrel
+++ b/dbrel
@@ -1,3 +1,4 @@
#!/bin/bash
-ssh repos.archlinux.org /packages/db-update
-ssh repos.archlinux.org /community/db-update
+#ssh repos.archlinux.org /packages/db-update
+#ssh repos.archlinux.org /community/db-update
+pkgctl db update
diff --git a/dd-parallel b/dd-parallel
new file mode 100755
index 0000000..0745225
--- /dev/null
+++ b/dd-parallel
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Run multiple dd processes in parallel to copy a single file/blockdevice. Each
+# dd process will operate on a dedicated part of the file at a time (1GB chunks
+# for big files).
+
+set -e
+
+# Source: https://stackoverflow.com/a/25268449
+min() {
+ printf "%s\n" "${@:2}" | sort "$1" | head -n1
+}
+max() {
+ # using sort's -r (reverse) option - using tail instead of head is also possible
+ min "${1}r" "${@:2}"
+}
+
+inputfile=$1
+if [[ -b "$inputfile" ]]; then
+ inputsize=$(blockdev --getsize64 "$inputfile")
+else
+ inputsize=$(stat --format %s "$inputfile")
+fi
+outputfile=$2
+
+stepsize=1000
+parallel=6
+# 1GB blocks or smaller blocks if we cannot achieve the required parallelization with 1GB
+blocksize=$(min -g 1000000 "$((inputsize / stepsize / parallel))" )
+
+seq 0 $stepsize $(($inputsize / $blocksize )) | xargs -P$parallel -I{} dd if="$inputfile" bs=$blocksize skip={} conv=sparse seek={} count=$stepsize status=none of="$outputfile"
diff --git a/decode-barcode b/decode-barcode
index 4d16780..29ae8ce 100755
--- a/decode-barcode
+++ b/decode-barcode
@@ -1,4 +1,9 @@
#!/bin/sh
-file=$(scrot -s -e 'echo $f')
+dir=$(mktemp --tmpdir -d)
+trap "rm -rf '$dir'" EXIT INT TERM
+
+file=$(mktemp --tmpdir="$dir" screenshot-XXXX.png)
+
+flameshot gui --accept-on-select -r > "$file"
+
zbarimg --raw $file
-rm "$file"
diff --git a/disconnect-screen b/disconnect-screen
new file mode 100755
index 0000000..2ec148e
--- /dev/null
+++ b/disconnect-screen
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+
+displays=(
+ $(xrandr | sed -rn 's#^([^ ]+) connected.*#\1#p' | grep -v '^eDP-1$')
+ $(xrandr | sed -rn 's#^([^ ]+) disconnected primary [0-9].*#\1#p' | grep -v '^eDP-1$')
+ $(xrandr | sed -rn 's#^([^ ]+) disconnected [0-9].*#\1#p' | grep -v '^eDP-1$')
+)
+
+for display in "${displays[@]}"; do
+ xrandr --output "$display" --off
+done
+
+xrandr --output eDP1 --primary
+xrandr --output eDP-1 --primary
diff --git a/dump-chrome-history b/dump-chrome-history
new file mode 100755
index 0000000..d99e561
--- /dev/null
+++ b/dump-chrome-history
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+TMPDIR="$(mktemp -d "/tmp/${0##*/}.XXXXXX")"
+trap "rm -rf '${TMPDIR}'" EXIT TERM
+
+cp -n ~/.config/chromium/Default/History "$TMPDIR"
+
+sqlite_opts=()
+
+case $MODE in
+ zsh-history-compat)
+ select_fields="last_visit_time/1000000-11644473600 AS visit_date, url, title"
+ sqlite_opts=(-separator ' | ')
+ ;;
+ *) select_fields="datetime(last_visit_time/1000000-11644473600,'unixepoch', 'localtime') AS visit_date, url, title";;
+esac
+
+output_filter() {
+ if [[ $MODE == 'zsh-history-compat' ]]; then
+ sed -r 's#^([0-9]+) \| (.*)$#: \1:0;\2#'
+ else
+ cat
+ fi
+}
+
+sqlite3 "${sqlite_opts[@]}" "$TMPDIR/History" "SELECT $select_fields
+FROM urls
+WHERE last_visit_time/1000000-11644473600 > $(date +%s -d "${1:-2 months ago}") AND last_visit_time/1000000-11644473600 < $(date +%s -d "${2:-now}")
+ORDER BY last_visit_time" | output_filter
diff --git a/dump-ff-history b/dump-ff-history
index 33cf7f0..c171aa3 100755
--- a/dump-ff-history
+++ b/dump-ff-history
@@ -5,7 +5,25 @@ trap "rm -rf '${TMPDIR}'" EXIT TERM
cp -n ~/.mozilla/firefox/*.default/places.sqlite* "$TMPDIR"
-sqlite3 "$TMPDIR/places.sqlite" "SELECT datetime(visit_date/1000000,'unixepoch', 'localtime') AS visit_date, url, title
+sqlite_opts=()
+
+case $MODE in
+ zsh-history-compat)
+ select_fields="visit_date/1000000 AS visit_date, url, title"
+ sqlite_opts=(-separator ' | ')
+ ;;
+ *) select_fields="datetime(visit_date/1000000,'unixepoch', 'localtime') AS visit_date, url, title";;
+esac
+
+output_filter() {
+ if [[ $MODE == 'zsh-history-compat' ]]; then
+ sed -r 's#^([0-9]+) \| (.*)$#: \1:0;\2#'
+ else
+ cat
+ fi
+}
+
+sqlite3 "${sqlite_opts[@]}" "$TMPDIR/places.sqlite" "SELECT $select_fields
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"
+ORDER BY visit_date" | output_filter
diff --git a/gen-perl-pkg b/gen-perl-pkg
index 46e5d18..d5a02a8 100755
--- a/gen-perl-pkg
+++ b/gen-perl-pkg
@@ -2,30 +2,29 @@
set -e
for pkg in "$@"; do
- export MAINTAINER="Florian Pritz <bluewind@xinu.at>"
- targets=(~/arch/{community,extra})
- target_new=~/arch/community
+ export MAINTAINER="Florian Pritz <bluewind@archlinux.org>"
+ targets=(~/arch/pkgs)
+ target_new=~/arch/pkgs
found_pkg=0
genpkg "$pkg"
for target in "${targets[@]}"; do
- if [[ -f "$target/$pkg/trunk/PKGBUILD" ]]; then
+ if [[ -f "$target/$pkg/PKGBUILD" ]]; then
found_pkg=1
- vimdiff "$target/$pkg/trunk/PKGBUILD" "$HOME/pkg/dest/$pkg/PKGBUILD"
+ vimdiff "$target/$pkg/PKGBUILD" "$HOME/pkg/dest/$pkg/PKGBUILD"
fi
done
if ((!found_pkg)); then
- if [[ $PWD =~ ($HOME/arch/(community|extra)).* ]]; then
+ if [[ $PWD =~ ($HOME/arch/pkgs).* ]]; then
target_new="${BASH_REMATCH[1]}"
echo "Found target directory $target_new"
fi
- echo "Package not found, creating new in '$target_new/$pkg/trunk'"
- mkdir -p "$target_new/$pkg/"{trunk,repos}
- cp "$HOME/pkg/dest/$pkg/PKGBUILD" "$target_new/$pkg/trunk/"
+ echo "Package not found, creating new in '$target_new/$pkg/'"
+ cp "$HOME/pkg/dest/$pkg/PKGBUILD" "$target_new/$pkg/"
cd "$target_new"
- svn add "$pkg"
+ git add "$pkg"
fi
done
diff --git a/git-diff-gpg b/git-diff-gpg
new file mode 100755
index 0000000..e249337
--- /dev/null
+++ b/git-diff-gpg
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+if grep -q 'BEGIN PGP PUBLIC KEY BLOCK' "$1"; then
+ cat "$1"
+else
+ echo "# GPG file SHA256 checksum: $(sha256sum - <"$1" | cut -d\ -f1)"
+ gpg --batch --decrypt 2>&1 "$1"
+fi
diff --git a/grep-email b/grep-email
new file mode 100755
index 0000000..c37eb92
--- /dev/null
+++ b/grep-email
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec grep -Eo "\b[^ ]*@[^ ]*\b" "$@"
diff --git a/gvim-term b/gvim-term
new file mode 100755
index 0000000..a08acd9
--- /dev/null
+++ b/gvim-term
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+exec term-open nvim "$@"
diff --git a/i3-continous-backup b/i3-continous-backup
new file mode 100755
index 0000000..2c8ef2a
--- /dev/null
+++ b/i3-continous-backup
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+echo "${0##*/}: starting new backup job master"
+
+while :; do
+ if pgrep firefox &>/dev/null; then
+ echo "${0##*/}: creating new i3 backup"
+ i3-dump-layout-all
+ echo "${0##*/}: i3 backup complete"
+ else
+ echo "${0##*/}: skipping i3 backup creation due to firefox not running. is the system in an unclean state?"
+ fi
+ sleep 5m
+done
diff --git a/i3-dump-layout-all b/i3-dump-layout-all
new file mode 100755
index 0000000..743328f
--- /dev/null
+++ b/i3-dump-layout-all
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+set -e
+
+for i in {1..20}; do
+ i3-resurrect save -w $i --swallow=class,instance,title
+done
+
+backupdir=~/.i3/i3-resurrect-backups
+keep_backups=30
+
+mkdir -p "$backupdir"
+cp -r ~/.i3/i3-resurrect $backupdir/0
+
+if [[ -d "$backupdir/$keep_backups" ]]; then
+ rm -rf "$backupdir/$keep_backups"
+fi
+
+i=$((keep_backups - 1))
+while ((i >= 0)); do
+ if [[ -d "$backupdir/$i/" ]]; then
+ mv -n "$backupdir/$i/" "$backupdir/$((i + 1))"/
+ fi
+ i=$((i - 1))
+done
+
diff --git a/i3-load-layouts b/i3-load-layouts
new file mode 100755
index 0000000..3c736c6
--- /dev/null
+++ b/i3-load-layouts
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+for i in {1..20}; do
+ #i3-msg "workspace $i; append_layout /home/flo/.i3/layouts/workspace-$i.json"
+ #sleep 2
+ i3-resurrect restore -w $i --layout-only "$@"
+done
+
diff --git a/invert-display b/invert-display
index ce584fc..371f0c8 100755
--- a/invert-display
+++ b/invert-display
@@ -6,3 +6,4 @@ sleep 0.2
xcalib -invert -alter -o 0
xcalib -invert -alter -o 1
+xcalib -invert -alter -o 2
diff --git a/mailer.pl b/mailer.pl
index cab1509..3028b2d 100755
--- a/mailer.pl
+++ b/mailer.pl
@@ -18,6 +18,9 @@ use Path::Tiny;
use Pod::Usage;
use Time::HiRes qw(gettimeofday tv_interval);
+# apt install cpanminus libemail-sender-perl libmce-perl libemail-stuffer-perl libpath-tiny-perl
+# cpanm MCE::Shared
+
use open ':encoding(locale)';
@ARGV = map { decode(locale => $_, 1) } @ARGV;
diff --git a/mutt b/mutt
new file mode 100644
index 0000000..11efce8
--- /dev/null
+++ b/mutt
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+set -e
+
+cachedir="$HOME/.cache/mutt"
+if [[ ! -d "$cachedir" ]]; then
+ mkdir "$cachedir"
+fi
+
+/usr/bin/mutt "$@"
diff --git a/myip-dns b/myip-dns
new file mode 100644
index 0000000..7052b07
--- /dev/null
+++ b/myip-dns
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+dig +short myip.opendns.com @resolver1.opendns.com
diff --git a/pkgctl b/pkgctl
new file mode 100755
index 0000000..a54084d
--- /dev/null
+++ b/pkgctl
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+cleanup_logs() {
+ if [[ -f PKGBUILD ]]; then
+ shopt -s nullglob
+
+ dir="."
+ files=("$dir/"*.log "$dir/"*.log.*)
+ if [[ -f "${files[0]}" ]]; then
+ mkdir -p "$dir/logs"
+ mv "${files[@]}" "$dir/logs/" || return
+ gzip -f "$dir/logs/"*.log "$dir/logs/"*.log.{1,2,3,4,5,6,7,8,9}
+ fi
+ fi
+}
+
+/usr/bin/pkgctl "$@"
+exitcode=$?
+
+if [[ "$1" == "build" ]]; then
+ cleanup_logs
+fi
+
+exit "$exitcode"
diff --git a/rofi-gpgpass b/rofi-gpgpass
new file mode 100755
index 0000000..5193ee2
--- /dev/null
+++ b/rofi-gpgpass
@@ -0,0 +1,80 @@
+#!/usr/bin/env ruby
+
+#
+# rofi-gpgpass - small script to type passwords from my passwords.gpg
+#
+# Copyright (c) 2022 Florian Pritz <bluewind@xinu.at>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http: #www.gnu.org/licenses/
+#
+
+require 'open3'
+
+$pwfile = "#{ENV['HOME']}/passwords.gpg"
+
+def get_passwords(pwfile)
+ data = `gpg --quiet --batch --decrypt "#{pwfile}" | grep -v '^HIDEOLD'`
+ raise "Failed to get passwords" if $? != 0 or data == '""'
+ return data
+end
+
+def get_single_password(passwords, identifier)
+ identifier.chomp!
+ passwords.split("\n").each do |line|
+ if line.end_with?(identifier)
+ return line.gsub(/^"([^"]+)" .*$/, '\1').chomp if line =~ /^"/
+ return line.gsub(/^([^ ]+) .*$/, '\1').chomp
+ end
+ end
+ return nil
+end
+
+def get_identifiers(passwords)
+ pass_array = passwords.split("\n").map do |line|
+ next line.gsub(/^"([^"]+)" (.*)$/, '\2') if line =~ /^"/
+ next line.gsub(/^([^ ]+) (.*)$/, '\2')
+ end
+ return pass_array.join("\n")
+end
+
+def rofi_select(passwords)
+ Open3.popen2("rofi -lines 20 -dmenu -i -p password") do |stdin, stdout, wait_thr|
+ stdin.puts get_identifiers(passwords)
+ return stdout.gets
+ end
+end
+
+def type_password(identifier, passwords)
+ password = get_single_password(passwords, identifier)
+
+ x_repeat_enabled = `xset q | awk '/auto repeat:/ {print $3}'`.chomp
+ system("xset r off")
+
+ Open3.popen2("xdotool type --clearmodifiers --file -") do |stdin, stdout, wait_thr|
+ stdin.write password
+ end
+
+ system("xset r '#{x_repeat_enabled}'")
+end
+
+def main()
+ passwords = get_passwords($pwfile)
+ selection = rofi_select(passwords)
+ type_password(selection, passwords)
+
+ return 1
+end
+
+
+exit(main())
diff --git a/rofi-hosts b/rofi-hosts
index 92031a2..0935ab2 100755
--- a/rofi-hosts
+++ b/rofi-hosts
@@ -24,6 +24,6 @@ set -euo pipefail
input=$(cut -d\ -f1 .ssh/known_hosts .ssh/known_hosts_work | tr , "\n" \
| sed -r 's#(_ecdsa|_rsa|_ed25519|_dsa)$##' | sort -u \
- | rofi -lines 20 -dmenu -p "host")
+ | rofi -matching fuzzy -lines 20 -dmenu -p "host")
printf "%s" "$input" | xclip
diff --git a/screen-locker.sh b/screen-locker.sh
index 51b6110..8950978 100755
--- a/screen-locker.sh
+++ b/screen-locker.sh
@@ -1,5 +1,12 @@
#!/bin/bash
+lock="$HOME/.screen-locker.lck"
+exec 9>"${lock}"
+if ! flock -n 9; then
+ logger "screen locker lock already locked"
+ exit
+fi
+
if pidof i3lock &> /dev/null; then exit 1; fi
revert() {
@@ -7,8 +14,22 @@ revert() {
logger "unlocking screen"
}
trap revert SIGHUP SIGINT SIGTERM EXIT
+
+# XXX: this seems to be broken so we also have our own loop to do essentially the same
xset +dpms dpms 10 10 10
-xset dpms force off
+dpms-loop() {
+ exec 9>&-
+
+ sleep 20
+ while pidof i3lock &> /dev/null; do
+ xset dpms force off
+ sleep 30
+ done
+}
+
+dpms-loop &
+loop_pid=$!
+
logger "locking screen"
i3lock -n -c 000000
diff --git a/sysinfo b/sysinfo
index ea285d7..6be8e33 100755
--- a/sysinfo
+++ b/sysinfo
@@ -3,8 +3,12 @@ BLUE="\e[1;34m"
NC="\e[0m"
clear
-cat /etc/motd
-echo
+
+if [[ -e /etc/motd ]]; then
+ cat /etc/motd
+ echo
+fi
+
echo -e "${BLUE}Host:${NC} $HOST"
echo -e "${BLUE}Uptime:$NC ${${$(uptime)%%,*}##*up }, ${$(</proc/loadavg)% *}"
diff --git a/term-open b/term-open
index d47367c..7307741 100755
--- a/term-open
+++ b/term-open
@@ -7,10 +7,10 @@ term=termite
if [[ $cmd = "mutt" ]]; then
if [[ "$*" = 'mailto:?'* ]]; then
- exec termite -e "mutt -- $*"
+ exec termite -e "mutt -- ${*@Q}"
else
- exec termite -e "mutt -e 'set autoedit=yes' -- $*"
+ exec termite -e "mutt -e 'set autoedit=yes' -- ${*@Q}"
fi
fi
-exec termite -e "$cmd -- $*"
+exec termite -e "$cmd -- ${*@Q}"
diff --git a/toggle-nm b/toggle-nm
new file mode 100755
index 0000000..2f55119
--- /dev/null
+++ b/toggle-nm
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+VPN="$1"
+
+if [[ -z "$VPN" ]]; then
+ #echo "usage: ${0##*/} <name>" >&2
+ #exit 1
+ VPN=$(nmcli --terse --fields NAME connection show | rofi -lines 20 -dmenu -i -p "network")
+fi
+
+ACTIVE=$(nmcli con show --active "$VPN")
+
+if [[ -z "$ACTIVE" ]]; then
+ nmcli con up id "$VPN"
+else
+ nmcli con down id "$VPN"
+fi
+
+exit 0
diff --git a/toggle-pulseaudio-mic-mute b/toggle-pulseaudio-mic-mute
new file mode 100755
index 0000000..d96b599
--- /dev/null
+++ b/toggle-pulseaudio-mic-mute
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+target_value=$(if [[ $(pactl get-source-mute '@DEFAULT_SOURCE@' | sed 's/Mute: //') == "yes" ]]; then echo "no"; else echo "yes"; fi)
+
+pacmd list-sources | grep -oP 'index: \d+' | awk '{ print $2 }' | xargs -I{} pactl set-source-mute {} "$target_value"
+
+
+notify_opts=()
+if [[ "$target_value" = "yes" ]]; then
+ notify_opts=(-h "string:bgcolor:#ff0000" -h "string:fgcolor:#000000")
+else
+ notify_opts=(-h "string:bgcolor:#00ff00" -h "string:fgcolor:#000000")
+fi
+
+notify-send "${notify_opts[@]}" -h string:x-canonical-private-synchronous:"${0##*/}" -t 3000 "Microphone mute: $target_value"
diff --git a/unload-pa b/unload-pa
new file mode 100755
index 0000000..3b4494c
--- /dev/null
+++ b/unload-pa
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+pacmd unload-module module-null-sink
+pacmd unload-module module-ladspa-sink
diff --git a/update b/update
new file mode 100755
index 0000000..6365666
--- /dev/null
+++ b/update
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+set -ex
+
+pacman -Sy --needed archlinux-keyring
+pacman -Su
diff --git a/update-perl-pkg b/update-perl-pkg
index b8cd65f..621e6ee 100755
--- a/update-perl-pkg
+++ b/update-perl-pkg
@@ -4,35 +4,37 @@ set -euo pipefail
pkg=$1
-targets=(~/arch/{community,extra})
+targets=(~/arch/pkgs)
found_pkg=0
for target in "${targets[@]}"; do
- if [[ -f "$target/$pkg/trunk/PKGBUILD" ]]; then
+ if [[ -f "$target/$pkg/PKGBUILD" ]]; then
found_pkg=1
cd "$target/$pkg"
- svn up
- cd trunk
+ git pull --rebase --autostash
break
fi
done
if ((!found_pkg)); then
- echo "Package not found. Creating not supported here"
- exit 1
+ cd ~/arch/pkgs
+ pkgctl repo clone "$pkg"
+ cd "$pkg"
+ #echo "Package not found. Creating not supported here"
+ #exit 1
fi
-case "${target##*/}" in
- extra) relcmd=(extrapkg);;
- community) relcmd=(communitypkg);;
- *) echo "Unable to determine release command for target '$target'"; exit 1; ;;
-esac
+#case "${target##*/}" in
+ #extra) relcmd=(extrapkg);;
+ #community) relcmd=(communitypkg);;
+ #*) echo "Unable to determine release command for target '$target'"; exit 1; ;;
+#esac
gen-perl-pkg "$pkg"
-ch update 64
-ch cbuild 64
-checkpkg
-echo "About to release with command: ${relcmd[*]}"
+#ch update 64
+#ch cbuild 64
+pkgctl build
+echo "About to release"
read -r -p "Hit enter to release or ^C to abort"
-"${relcmd[@]}" "upstream update"
-
+#"${relcmd[@]}" "upstream update"
+pkgctl release --message "upstream update"
diff --git a/wireshark-remote b/wireshark-remote
index 756771b..e07e8a5 100755
--- a/wireshark-remote
+++ b/wireshark-remote
@@ -13,4 +13,5 @@ fi
#wireshark -k -i <(ssh "$host" /home/flo/capture.sh "$iface")
#wireshark-gtk -k -i <(ssh "$host" dumpcap -q -P -i "$iface" -w - -f 'not\ port\ 22')
-wireshark-gtk -k -i <(ssh "$host" tcpdump -i "$iface" -w - "'not port 22 $filter'")
+sed -i "s/^gui\.window_title: .*/gui.window_title: $host $iface $filter/" ~/.config/wireshark/preferences
+wireshark -k -i <(stdbuf -o0 ssh "$host" stdbuf -o0 sudo stdbuf -o0 tcpdump -s 65535 -i "$iface" -w - "'not port 22 $filter'")