#!/bin/sh

if [[ $1 == "show" || $# -lt 1 ]] ; then
    if [[ -e `which rofi` ]] ; then
        PAGE=`man -k . | awk -e '{print $1}' | rofi -dmenu -p "man page"`
        [[ $PAGE != "" ]] && exec urxvto -e man $PAGE
    else
        PAGE=`man -k . | awk -e '{print $1}' | dmenu`
        [[ $PAGE != "" ]] && exec urxvto -e man $PAGE
    fi
else
    exec urxvto -e man $1
fi

