aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/br2
-rw-r--r--bin/brxs3
-rwxr-xr-xbin/dmp28
-rw-r--r--bin/sd2u.sed2
-rw-r--r--bin/su2d.sed2
-rw-r--r--bin/unf.sed17
-rwxr-xr-xbin/urlh30
-rwxr-xr-xbin/urlmt3
-rwxr-xr-xbin/xgo33
-rw-r--r--bin/xgoc3
10 files changed, 119 insertions, 4 deletions
diff --git a/bin/br b/bin/br
index 1d982c04..399c6038 100755
--- a/bin/br
+++ b/bin/br
@@ -1,3 +1,3 @@
#!/bin/sh
-# Launch $BROWSER
+# Just launch $BROWSER with any given arguments
exec "$BROWSER" "$@"
diff --git a/bin/brxs b/bin/brxs
deleted file mode 100644
index 5324885d..00000000
--- a/bin/brxs
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-# Run $BROWSER with an URL retrieved from X's PRIMARY select
-exec br "$(xsel)"
diff --git a/bin/dmp b/bin/dmp
new file mode 100755
index 00000000..9ef58f67
--- /dev/null
+++ b/bin/dmp
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+# Get the password store directory, bail if we can't
+pwsd=${PASSWORD_STORE_DIR:-$HOME/.password-store}
+pwsd=${pwsd%/}
+[ -n "$pwsd" ] || exit
+
+# Get the password; get all the names from find(1)
+pw=$(
+ cd -- "$pwsd" || exit
+ # Get all the names from find(1)
+ find ./ -name \*.gpg |
+ # Sort them
+ sort |
+ # Strip the leading directory and the trailing .gpg
+ sed '
+s_^\./__
+s_\.gpg$__
+ ' |
+ # Use dmenu(1) to prompt the user to select one
+ dmenu
+) || exit
+
+# Bail if we don't have a password
+[ -n "$pw" ] || exit
+
+# Pump the password into the clipboard xsel(2); allow 10 seconds
+pass show "$pw" | xsel -ibt 10000
diff --git a/bin/sd2u.sed b/bin/sd2u.sed
new file mode 100644
index 00000000..14588623
--- /dev/null
+++ b/bin/sd2u.sed
@@ -0,0 +1,2 @@
+# Convert DOS line endings to UNIX ones
+s/\r$//g
diff --git a/bin/su2d.sed b/bin/su2d.sed
new file mode 100644
index 00000000..06998986
--- /dev/null
+++ b/bin/su2d.sed
@@ -0,0 +1,2 @@
+# Convert UNIX line endings to DOS ones
+/[^\r]$/s/$/\r/g
diff --git a/bin/unf.sed b/bin/unf.sed
new file mode 100644
index 00000000..23270fc6
--- /dev/null
+++ b/bin/unf.sed
@@ -0,0 +1,17 @@
+# Unfold lines with leading spaces (e.g. RFC 822 headers)
+/^[ \t]/!{
+ 1!{
+ x
+ p
+ x
+ }
+ h
+}
+/^[ \t]/{
+ H
+ x
+ s/[\r\n]//g
+ x
+}
+$!d
+x
diff --git a/bin/urlh b/bin/urlh
new file mode 100755
index 00000000..2c547ad0
--- /dev/null
+++ b/bin/urlh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# Get values for HTTP headers for the given URL
+
+# Check arguments
+if [ "$#" -ne 2 ] ; then
+ printf 'urlt: Need an URL and a header name\n'
+ exit 2
+fi
+url=$1 header=$2
+
+# Run cURL header request
+curl -I -- "$url" |
+
+# Unfold the headers
+unf |
+
+# Change the line endings to UNIX format
+sd2u |
+
+# Use awk to find any values for the header case-insensitively
+awk -v header="$header" '
+BEGIN {
+ FS=": *"
+ header = tolower(header)
+}
+tolower($1) == header {
+ sub(/^[^ ]*: */, "")
+ print
+}
+'
diff --git a/bin/urlmt b/bin/urlmt
new file mode 100755
index 00000000..465ff588
--- /dev/null
+++ b/bin/urlmt
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Get the MIME type for a given URL
+urlh "$1" Content-Type | sed 's/; .*//'
diff --git a/bin/xgo b/bin/xgo
new file mode 100755
index 00000000..56bbb0f9
--- /dev/null
+++ b/bin/xgo
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Test and open a clipboard URL with an apt program
+
+# Check arguments
+if [ "$#" -eq 0 ] ; then
+ printf 2>&1 'xgo: At least one URL required\n'
+fi
+
+# Iterate over the URL arguments
+for url ; do (
+
+ # If it's a YouTube video without a given start time, load it in mpv(1)
+ case $url in
+ *youtube.com/watch*[?\&]t=) ;;
+ *youtube.com/watch*)
+ mpv -- "$url" && continue
+ ;;
+ esac
+
+ # If the MIME type is an image, load it in feh(1)
+ case $mt in
+ image/gif) ;;
+ image/*)
+ curl -- "$url" | feh - && continue
+ ;;
+ esac
+
+ # Get the MIME type data
+ mt=$(urlmt "$url")
+
+ # Otherwise, just pass it to br(1)
+ br "$url"
+) & done
diff --git a/bin/xgoc b/bin/xgoc
new file mode 100644
index 00000000..9e4b0929
--- /dev/null
+++ b/bin/xgoc
@@ -0,0 +1,3 @@
+#!/bin/sh
+# Run xgo(1) with the contents of the X clipboard
+xgo "$(xsel)"