initial dump
authorMatthewOwens <matthew@owens.tech>
Sun, 21 Jun 2020 17:26:38 +0000 (18:26 +0100)
committerMatthewOwens <matthew@owens.tech>
Sun, 21 Jun 2020 17:26:38 +0000 (18:26 +0100)
30 files changed:
auto-multimonitor [new file with mode: 0755]
booksplit [new file with mode: 0755]
brave-new-world [new file with mode: 0755]
bt [new file with mode: 0755]
camtoggle [new file with mode: 0755]
colours.sh [new file with mode: 0755]
cpuhogs [new file with mode: 0755]
cputemp [new file with mode: 0755]
dproj [new file with mode: 0755]
dsurf [new file with mode: 0755]
dwmbar [new file with mode: 0755]
kb.sh [new file with mode: 0755]
linkhandler [new file with mode: 0755]
memhogs [new file with mode: 0755]
mkbar.sh [new file with mode: 0755]
mm.sh [new file with mode: 0755]
netflix [new file with mode: 0755]
papefix.sh [new file with mode: 0755]
pokemon-emerald [new file with mode: 0755]
rclick.sh [new file with mode: 0755]
resolution [new file with mode: 0755]
screen_blank.sh [new file with mode: 0755]
sss [new file with mode: 0755]
tag [new file with mode: 0755]
tearfix.sh [new file with mode: 0755]
thecproglang [new file with mode: 0755]
toRebuild.sh [new file with mode: 0755]
unicode.sh [new file with mode: 0755]
webview [new file with mode: 0755]
whoneeds.sh [new file with mode: 0755]

diff --git a/auto-multimonitor b/auto-multimonitor
new file mode 100755 (executable)
index 0000000..eb76a23
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/bash
+
+# Vertical monitor is connected as DP-0, Horizontal monitor is connected as HDMI-0
+# Horizontal monitor is disconnected for the PS4. This script monitors the output
+# of xrandr and runs the multimonitor script if needed
+
+MMSCRIPT=~/.screenlayout/multimonitor.sh
+HDMI=$(xrandr | grep -c HDMI-0)
+
+if [[ HDMI -eq 1 ]]; then
+       $MMSCRIPT
+fi
diff --git a/booksplit b/booksplit
new file mode 100755 (executable)
index 0000000..3d0ab07
--- /dev/null
+++ b/booksplit
@@ -0,0 +1,44 @@
+#!/bin/sh
+
+# Requires ffmpeg (audio splitting) and my `tag` wrapper script.
+
+[ ! -f "$2" ] && printf "The first file should be the audio, the second should be the timecodes.\\n" && exit
+
+echo "Enter the album/book title:"; read -r booktitle
+
+echo "Enter the artist/author:"; read -r author
+
+echo "Enter the publication year:"; read -r year
+
+inputaudio="$1"
+
+# Get a safe file name from the book.
+escbook="$(echo "$booktitle" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
+
+! mkdir -p "$escbook" && echo "Do you have write access in this directory?" && exit 1
+
+# As long as the extension is in the tag script, it'll work.
+ext="opus"
+#ext="${1#*.}"
+
+# Get the total number of tracks from the number of lines.
+total="$(wc -l < "$2")"
+
+while read -r x;
+do
+       end="$(echo "$x" | cut -d' ' -f1)"
+       [ -n "$start" ] &&
+       echo "From $start to $end; $track $title"
+       file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
+       [ -n "$start" ] && echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -to "$end" -vn "$file" &&
+               echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
+       title="$(echo "$x" | cut -d' ' -f 2-)"
+       esctitle="$(echo "$title" | iconv -cf UTF-8 -t ASCII//TRANSLIT | tr -d '[:punct:]' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | sed "s/-\+/-/g;s/\(^-\|-\$\)//g")"
+       track="$((track+1))"
+       start="$end"
+done < "$2"
+# The last track must be done outside the loop.
+echo "From $start to the end: $title"
+file="$escbook/$(printf "%.2d" "$track")-$esctitle.$ext"
+echo "Splitting \"$title\"..." && ffmpeg -nostdin -y -loglevel -8 -i "$inputaudio" -ss "$start" -vn "$file" &&
+               echo "Tagging \"$title\"..." && tag -a "$author" -A "$booktitle" -t "$title" -n "$track" -N "$total" -d "$year" "$file"
diff --git a/brave-new-world b/brave-new-world
new file mode 100755 (executable)
index 0000000..15ba322
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mupdf ~/documents/books/BraveNewWorld.pdf
diff --git a/bt b/bt
new file mode 100755 (executable)
index 0000000..155174e
--- /dev/null
+++ b/bt
@@ -0,0 +1,32 @@
+#!/bin/bash
+function connect()
+{
+       echo  -e "connect E8:AB:FA:25:43:EE\n" | bluetoothctl
+}
+
+function disconnect()
+{
+       echo -e "disconnect\n" | bluetoothctl
+}
+
+function usage()
+{
+       echo "Usage: $0 {c|d}"
+       echo "_C_onnect/_D_isconnect from bluetooth headphones"
+}
+
+if [[ $# -ne 1 ]]; then
+       usage
+       exit 1
+fi
+
+if [[ $1 == "c" ]]; then
+       connect
+       exit 0
+elif [[ $1 == "d" ]]; then
+       disconnect
+       exit 0
+else
+       usage
+       exit 0
+fi
diff --git a/camtoggle b/camtoggle
new file mode 100755 (executable)
index 0000000..affd652
--- /dev/null
+++ b/camtoggle
@@ -0,0 +1,4 @@
+#!/bin/bash
+#pkill -f /dev/video || mpv --geometry=-0-0 --autofit=30% --no-cache-pause /dev/video0
+#pkill -f camout.mkv || ffmpeg -f mjpg -video_size 640x480 -i /dev/video0 camout.mkv ; mpv --geometry=-0-0 --autofit=30% camout.mkv
+pkill -f vlc || cvlc v4l2:///dev/video0 --live-caching=10 
diff --git a/colours.sh b/colours.sh
new file mode 100755 (executable)
index 0000000..38ae137
--- /dev/null
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+#
+# colorbars - smpte color bars in bash
+#
+
+echo
+
+for y in {0..13};
+  do
+  echo -n "           "
+  for color in 7 3 6 2 5 1 4;
+    do tput setab $color
+    printf "        ";
+  done
+  tput sgr0
+  echo;
+done
+
+for y in {0..1};
+  do
+  echo -n "           "
+  for color in 4 0 5 0 6 0 7;
+    do tput setab $color
+    printf "        ";
+  done
+  tput sgr0
+  echo;
+done
+
+for y in {0..4};
+  do
+  echo -n "           "
+  for color in 4 4 4 4 4 7 7 7 7 7 5 5 5 5 5 0 0 0 0 0 0 0 0 0 0 0 0 0;
+      do tput setab $color
+      printf "  ";
+  done
+  tput sgr0
+  echo;
+done
+
+echo
diff --git a/cpuhogs b/cpuhogs
new file mode 100755 (executable)
index 0000000..7cb903b
--- /dev/null
+++ b/cpuhogs
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ps axch -o cmd:15,%cpu --sort=-%cpu | sed 11q
diff --git a/cputemp b/cputemp
new file mode 100755 (executable)
index 0000000..866c81c
--- /dev/null
+++ b/cputemp
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+sensors | awk '/^temp1:/ {print $2}'
diff --git a/dproj b/dproj
new file mode 100755 (executable)
index 0000000..0044ed2
--- /dev/null
+++ b/dproj
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+rootDir='/home/mokou/git/cecse'
+proj=$(ls $rootDir | dmenu  -l 10 \
+       -fn 'xos4 Terminus-15' -nb '#1c1c1c' -sb '#b35050')
+
+[ -z $proj ] && exit
+
+# creating the project if it doesn't exist
+projExists=$(find $rootDir -maxdepth 1 -type d -name $proj)
+if [ -z $projExists ]; then
+       cd $rootDir
+       notify-send 'cecse' "creating $proj module, please wait..."
+       ./scripts/new_module $proj
+       notify-send 'cecse' "adding owens.tech remotes..."
+       ssh git@owens.tech "mkdir cecse/$proj.git cecse/test-$proj.git;\ 
+               cd $proj.git; git init --bare; cd ../$test-proj.git;\ 
+               git init --bare"
+       cd $proj
+       git remote set-url --add --push origin git@github.com:cecse/$proj.git
+       git remote set-url --add --push origin git@owens.tech:cecse/$proj.git
+       cd ../test-$proj
+       git remote set-url --add --push origin git@github.com:cecse/$proj.git
+       git remote set-url --add --push origin git@owens.tech:cecse/$proj.git
+       cd ..
+fi
+
+(tmux has-session -t $proj)
+sessionExists="$?"
+
+if [ $sessionExists -eq 1 ]; then
+       cd $rootDir/$proj
+       tmux new-session -d -s $proj
+
+       # rename default window
+       tmux rename-window -t $proj.0 'src'
+       tmux new-window -t $proj -n 'tests'
+       tmux new-window -t $proj -n 'build'
+       tmux send-keys -t $proj:src 'cd src;ls' C-m
+       tmux send-keys -t $proj:tests "cd test-$proj;ls" C-m
+       tmux send-keys -t $proj:build 'ls' C-m
+fi
+
+client=$(tmux list-clients | grep -v '0 ' | cut -d: -f1)
+tmux switch-client -c $client -t $proj
diff --git a/dsurf b/dsurf
new file mode 100755 (executable)
index 0000000..7c07c56
--- /dev/null
+++ b/dsurf
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+site=$(cat ~/.surf/bookmarks | dmenu  -l 10 \
+       -fn 'xos4 Terminus-15' -nb '#1c1c1c' -sb '#b35050')
+[ -z "$site" ] || surf -b $site
diff --git a/dwmbar b/dwmbar
new file mode 100755 (executable)
index 0000000..e9c1106
--- /dev/null
+++ b/dwmbar
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# statusbar loop
+while true; do
+       xsetroot -name "$(date +"%F %T")"
+       sleep 1s
+done
diff --git a/kb.sh b/kb.sh
new file mode 100755 (executable)
index 0000000..893c283
--- /dev/null
+++ b/kb.sh
@@ -0,0 +1 @@
+setxkbmap gb && setxkbmap -option caps:swapescape
diff --git a/linkhandler b/linkhandler
new file mode 100755 (executable)
index 0000000..bb6f6d9
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Feed script a url or file location.
+# If an image, it will view in feh,
+# if a video or gif, it will view in mpv
+# if a music file or pdf, it will download,
+# otherwise it opens link in browser.
+
+# If no url given. Opens browser. For using script as $BROWSER.
+[ -z "$1" ] && { "$BROWSER"; exit; }
+
+case "$1" in
+       *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtu.be*|*hooktube.com*|*bitchute.com*)
+               setsid mpv -quiet "$1" >/dev/null 2>&1 & ;;
+       *png|*jpg|*jpe|*jpeg|*gif)
+               curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && feh -a "/tmp/$(echo "$1" | sed "s/.*\///")"  >/dev/null 2>&1 & ;;
+       *mp3|*flac|*opus|*mp3?source*)
+               setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;;
+       *)
+               if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1"
+               else setsid $BROWSER "$1" >/dev/null 2>&1 & fi ;;
+esac
diff --git a/memhogs b/memhogs
new file mode 100755 (executable)
index 0000000..b0c8475
--- /dev/null
+++ b/memhogs
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+ps axch -o cmd:15,%mem --sort=-%mem | sed 11q
diff --git a/mkbar.sh b/mkbar.sh
new file mode 100755 (executable)
index 0000000..0be8eef
--- /dev/null
+++ b/mkbar.sh
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# z3bra - (c) wtfpl 2014
+# Fetch infos on your computer, and print them to stdout every second.
+
+clock() {
+       date '+%Y-%m-%d %H:%M:%S'
+}
+
+battery() {
+       BATC=/sys/class/power_supply/BAT1/capacity
+       BATS=/sys/class/power_supply/BAT1/status
+
+       test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
+
+       sed -n p $BATC
+}
+
+volume() {
+       amixer get Master | sed -n 'N;s/^.*\[\([0-9]\+%\).*$/\1/p'
+}
+
+cpuload() {
+       LINE=`ps -eo pcpu |grep -vE '^\s*(0.0|%CPU)' |sed -n '1h;$!H;$g;s/\n/ +/gp'`
+       bc <<< $LINE
+}
+
+memused() {
+       read t f <<< `grep -E 'Mem(Total|Free)' /proc/meminfo |awk '{print $2}'`
+       bc <<< "scale=2; 100 - $f / $t * 100" | cut -d. -f1
+}
+
+network() {
+       read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
+       if iwconfig $int1 >/dev/null 2>&1; then
+               wifi=$int1
+               eth0=$int2
+       else
+               wifi=$int2
+               eth0=$int1
+       fi
+       ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 ||int=$wifi
+
+       #int=eth0
+
+       ping -c 1 8.8.8.8 >/dev/null 2>&1 && 
+               echo "$int connected" || echo "$int disconnected"
+}
+
+groups() {
+       cur=`xprop -root _NET_CURRENT_DESKTOP | awk '{print $3}'`
+       tot=`xprop -root _NET_NUMBER_OF_DESKTOPS | awk '{print $3}'`
+
+       for w in `seq 0 $((cur - 1))`; do line="${line}="; done
+               line="${line}|"
+       for w in `seq $((cur + 2)) $tot`; do line="${line}="; done
+               echo $line
+}
+
+nowplaying() {
+   cur=`mpc current`
+       # this line allow to choose whether the output will scroll or not
+       test "$1" = "scroll" && PARSER='skroll -n20 -d0.5 -r' || PARSER='cat'
+       test -n "$cur" && $PARSER <<< $cur || echo "- stopped -"
+}
+
+# This loop will fill a buffer with our infos, and output it to stdout.
+while :; do
+    buf=""
+       buf="${buf} %{F#ffffff}[$(groups)]"
+#buf="${buf} %{c}NET: $(network) -"
+       buf="${buf} %{c}%{F#b35050}$(nowplaying)"
+       buf="${buf} %{r}%{F#ffffff}CPU: $(cpuload)% | "
+       buf="${buf} RAM: $(memused)% |"
+#buf="${buf} VOL: $(volume)"
+       buf="${buf} $(clock)"
+
+       echo $buf
+       # use `nowplaying scroll` to get a scrolling output!
+       sleep 1 # The HUD will be updated every second
+       done
diff --git a/mm.sh b/mm.sh
new file mode 100755 (executable)
index 0000000..05611b3
--- /dev/null
+++ b/mm.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+xrandr --output DVI-I-0 --off --output DVI-I-1 --off --output HDMI-0 --mode 1920x1080 --pos 0x511 --rotate normal --output DP-0 --mode 1920x1080 --pos 1920x0 --rotate left --output DP-1 --off --output DVI-D-0 --off
diff --git a/netflix b/netflix
new file mode 100755 (executable)
index 0000000..601ce42
--- /dev/null
+++ b/netflix
@@ -0,0 +1,2 @@
+#!/bin/bash
+qtwebflix
diff --git a/papefix.sh b/papefix.sh
new file mode 100755 (executable)
index 0000000..d75b14c
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+cd ~/pictures/wallpapers/vaporwave/
+#feh --bg-scale bust.jpg 156890-free-download-vaporwave-iphone-wallpaper-1080x1920-notebook.jpg
+feh --bg-scale moonscape.jpg purple-rain-vert.jpg
diff --git a/pokemon-emerald b/pokemon-emerald
new file mode 100755 (executable)
index 0000000..5c62245
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mgba ~/games/gba/Pokemon\ -\ Emerald\ Version\ \(U\).gba
diff --git a/rclick.sh b/rclick.sh
new file mode 100755 (executable)
index 0000000..1a0efa7
--- /dev/null
+++ b/rclick.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+while(true)
+       xdotool click 2
diff --git a/resolution b/resolution
new file mode 100755 (executable)
index 0000000..afec231
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+xrandr --output DisplayPort-0 --off --output DisplayPort-1 --off --output DisplayPort-2 --mode 1920x1080 --pos 2011x0 --rotate right --output HDMI-A-0 --primary --mode 1920x1080 --pos 0x673 --rotate normal
diff --git a/screen_blank.sh b/screen_blank.sh
new file mode 100755 (executable)
index 0000000..9c132fc
--- /dev/null
@@ -0,0 +1 @@
+xset s noblank && xset -dpms
diff --git a/sss b/sss
new file mode 100755 (executable)
index 0000000..b794460
--- /dev/null
+++ b/sss
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+import /tmp/ss.png
diff --git a/tag b/tag
new file mode 100755 (executable)
index 0000000..c23be4e
--- /dev/null
+++ b/tag
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+err() { echo "Usage:
+       tag [OPTIONS] file
+Options:
+       -a: artist/author
+       -t: song/chapter title
+       -A: album/book title
+       -n: track/chapter number
+       -N: total number of tracks/chapters
+       -d: year of publication
+       -g: genre
+       -c: comment
+You will be prompted for title, artist, album and track if not given." && exit 1 ;}
+
+while getopts "a:t:A:n:N:d:g:c:f:" o; do case "${o}" in
+       a) artist="${OPTARG}" ;;
+       t) title="${OPTARG}" ;;
+       A) album="${OPTARG}" ;;
+       n) track="${OPTARG}" ;;
+       N) total="${OPTARG}" ;;
+       d) date="${OPTARG}" ;;
+       g) genre="${OPTARG}" ;;
+       c) comment="${OPTARG}" ;;
+       f) file="${OPTARG}" ;;
+       *) printf "Invalid option: -%s\\n" "$OPTARG" && err ;;
+esac done
+
+shift $((OPTIND - 1))
+
+file="$1"
+
+[ ! -f "$file" ] && echo "Provide file to tag." && err
+
+[ -z "$title" ] && echo "Enter a title." && read -r title
+[ -z "$artist" ] && echo "Enter an artist." && read -r artist
+[ -z "$album" ] && echo "Enter an album." && read -r album
+[ -z "$track" ] && echo "Enter a track number." && read -r track
+
+case "$file" in
+       *.ogg) echo "Title=$title
+Artist=$artist
+Album=$album
+Track=$track
+Total=$total
+Date=$date
+Genre=$genre
+Comment=$comment" | vorbiscomment -w "$file" ;;
+       *.opus) echo "Title=$title
+Artist=$artist
+Album=$album
+Track=$track
+Total=$total
+Date=$date
+Genre=$genre
+Comment=$comment" | opustags -i -S "$file" ;;
+       *.mp3) eyeD3 -Q --remove-all -a "$artist" -A "$album" -t "$title" -n "$track" -N "$total" -Y "$date" "$file" ;;
+       *) echo "File type not implemented yet." ;;
+esac
diff --git a/tearfix.sh b/tearfix.sh
new file mode 100755 (executable)
index 0000000..f0cd30b
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+cd ~/scripts;
+nvidia-settings --assign CurrentMetaMode="nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }" && ./mm.sh
diff --git a/thecproglang b/thecproglang
new file mode 100755 (executable)
index 0000000..d8ce42d
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/bash
+
+mupdf ~/documents/books/The\ C\ Programming\ Language\ -\ 2nd\ Edition\ -\ Ritchie\ Kernighan.pdf
diff --git a/toRebuild.sh b/toRebuild.sh
new file mode 100755 (executable)
index 0000000..4059cda
--- /dev/null
@@ -0,0 +1,10 @@
+    #!/bin/bash
+
+
+    while read pkg; do
+
+               mapfile -t files < <(pacman -Qlq $pkg | grep -v /$)
+
+               grep -Fq libstdc++.so.6 "${files[@]}" 2>/dev/null && echo $pkg
+                                                                                             
+                           done < <(pacman -Qmq)
diff --git a/unicode.sh b/unicode.sh
new file mode 100755 (executable)
index 0000000..8e85db1
--- /dev/null
@@ -0,0 +1,31 @@
+fast_chr() {
+    local __octal
+    local __char
+    printf -v __octal '%03o' $1
+    printf -v __char \\$__octal
+    REPLY=$__char
+}
+
+function unichr {
+    local c=$1    # Ordinal of char
+    local l=0    # Byte ctr
+    local o=63    # Ceiling
+    local p=128    # Accum. bits
+    local s=''    # Output string
+
+    (( c < 0x80 )) && { fast_chr "$c"; echo -n "$REPLY"; return; }
+
+    while (( c > o )); do
+        fast_chr $(( t = 0x80 | c & 0x3f ))
+        s="$REPLY$s"
+        (( c >>= 6, l++, p += o+1, o>>=1 ))
+    done
+
+    fast_chr $(( t = p | c ))
+           echo -n "$REPLY$s"
+}
+
+## test harness
+for (( i=0x0000; i<0xE000; i++ )); do
+    unichr $i
+       done
diff --git a/webview b/webview
new file mode 100755 (executable)
index 0000000..8348ea4
--- /dev/null
+++ b/webview
@@ -0,0 +1,16 @@
+#!/bin/bash
+ext="${1##*.}"
+mpvFiles="mkv mp4 gif"
+fehFiles="png jpg jpeg jpe"
+wgetFiles="mp3 flac opus mp3?source=feed pdf"
+
+if echo $fehFiles | grep -w $ext > /dev/null; then
+       nohup feh "$1" >/dev/null &
+elif echo $mpvFiles | grep -w $ext > /dev/null; then
+       nohup mpv --loop --quiet "$1" > /dev/null &
+elif echo $wgetFiles | grep -w $ext > /dev/null; then
+       nohup wget "$1" >/dev/null &
+else
+       #nohup $BROWSER "$1" >/dev/null &
+       nohup surf "$1" >/dev/null &
+fi
diff --git a/whoneeds.sh b/whoneeds.sh
new file mode 100755 (executable)
index 0000000..92540e4
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+# whoneeds package : shows explicitly installed packages that require some package
+
+# we use associative arrays to get uniqueness for "free"
+typeset -A root_packages
+typeset -A walked_nodes
+query="$1"
+
+function walk_nodes () {
+    local package="$1"
+
+    # if we've walked this node before, skip. This drastically
+    # reduces overhead for a relatively cheap operation
+    [[ "${walked_nodes[$package]}" -eq 1 ]] && return 0
+    walked_nodes["$package"]=1
+
+    # we do this so that we can make a single call to pacman
+    # to get both bits of information that we require
+    result=( $(LC_ALL=c pacman -Qi "$package" | awk -F':' \
+      'BEGIN { tag = ""; dependents = ""; explicit = 0 }
+       {
+          # since the formatting of the pacman output is more for human
+          # consumption than programmatic, we find ourselves with the following need.
+          # if we have two fields, then we know we have a proper identifier on the line
+          # so we store the identifier as a current tag
+          # All identifier checks are made against the current tag, which allows us
+          # to deal with instances where "Required By" spans lines
+          if (NF == 2) { tag = $1 }
+          if (tag ~ /^Required By[ ]*$/) {  dependents = dependents $(NF) }
+          if ($1 ~ /^Install Reason $/ && $2 ~/^ Explicitly installed/) { explicit = 1 }
+       }
+       END { print explicit,dependents}') )
+
+    # and if we hit an issue retrieving package information
+    if [[ ${#result[*]} -lt 2 ]]; then
+            echo "error: could not get information on $package" 1>&2
+            exit 3
+    fi
+    if [[ ${result[0]} -eq 1 ]]; then
+        # we found an explicitly installed package that relies on
+        # the original query. Add it to our array, provided it isn't
+        # the original query, as that would be useless information
+        [[ "$query" != "$package" ]] && root_packages["$package"]=1
+    fi
+    if [[ "${result[1]}" != "None" ]]; then
+        # iterate over our 'Required By:' packages
+        dependents="${result[@]:1:${#result[*]}}"
+        for i in "$dependents"; do
+            walk_nodes "$i"
+        done
+    fi
+}
+
+if [ $# -ne 1 ]; then
+    echo "error: unexpected number of arguments" 1>&2
+    echo "Usage: $(basename $0) <package-name>"
+    exit 2
+fi
+
+walk_nodes "$1"
+echo "Packages that depend on [$query]"
+if [[ -n "${!root_packages[*]}" ]]; then
+    for pkg in "${!root_packages[@]}"; do
+        echo "  $pkg"
+    done | sort
+    exit 0
+fi
+echo "  None"
+exit 1
+
+# vim: set ts=4 sw=4 et:
+