#!/bin/sh

mangadir="$HOME/Pictures/gallery-dl/Manga"

manga=$(find "${mangadir}" -maxdepth 1 -type d -exec basename '{}' \; | tail -n +2 | {{ launcher }} {{ dmenu_flag }} -p 'Manga{{ (launcher == 'fuzzel') | ternary(': ', '') }}')

if [ -n "$manga" ]
then
	chapter=$(find "${mangadir}/${manga}" -type f -exec basename '{}' \; | {{ launcher }} {{ dmenu_flag }} -p 'Chapter{{ (launcher == 'fuzzel') | ternary(': ', '') }}')
	if [ -n "${chapter}" ]
	then
		zathura "${mangadir}/${manga}/${chapter}"
	else
		$0 "$1"
	fi
fi
