Skip to content

Instantly share code, notes, and snippets.

@coreymwamba
Last active May 10, 2020 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreymwamba/de3e08c9dcd72c8a5c097ec190e87958 to your computer and use it in GitHub Desktop.
Save coreymwamba/de3e08c9dcd72c8a5c097ec190e87958 to your computer and use it in GitHub Desktop.
Dmenu-driven Arch Linux offine wiki search, using arch-wiki-lite.
#!/bin/bash
# This is just a barebones script -- needs dmenu,arch-wiki-lite, i3-sensible-terminal
# modify as needed
dm="-fn LiberationSans-12 -nb #404452 -sb #9899a0"
s=$(echo "" | dmenu -q $dm -p "ArchWiki")
if [ -n "$s" ]; then
wiki-search "$s" > /tmp/awms
a=$(cat /tmp/awms | awk -F' ' '{ print $2 }')
lines=$(cat /tmp/awms | wc -l)
b=$(cat /tmp/awms | awk -F' ' '{ printf "%s\\n", $2 }')
c=$(grep -o -P '.{0,4}$' /tmp/awms)
IFS=$'\n'
ART=( $a )
LIST=( $b )
NUM=( $c )
echo $lines
chooser=$(echo -e $LIST | dmenu -l $lines -p "Select page" -fn "LiberationSans-12" -nb "#404452" -sb "#>
for i in "${!ART[@]}"; do
if [[ "${ART[$i]}" = "${chooser}" ]]; then
choice="${NUM[$i]}";
i3-sensible-terminal -title "ArchWiki: ${chooser}" -e "wiki-search $choice";
fi
done
fi
rm /tmp/awms
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment