Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- COMIX=${COMIX:-"mcomix -fmdh"}
- COLLECT=${COLLECT:-"collect"}
- D=${PREFIX:-"/tmp/mb-$$"}
- ######
- ###### Initialize
- ######
- set -m
- exec 2>/dev/null
- ### tmp directory
- mkdir -p "$D"
- mkfifo "$D/event"
- mkfifo "$D/history"
- mkfifo "$D/book"
- ### file descriptors
- exec 7<>"$D/event"
- exec 8<>"$D/history"
- exec 9<>"$D/book"
- ### initial run
- echo next >&7 &
- ### trap
- function cleanup () {
- for pid in `jobs -p`; do
- kill -TERM -"${pid}"
- done
- wait
- exec 7<&- 7>&-
- exec 8<&- 8>&-
- exec 9<&- 9>&-
- rm -rf "$D";
- }
- trap "cleanup" EXIT
- ### working directory
- cd "${COLLECT}"
- ######
- ###### Main
- ######
- ### Generate Book List
- ls | sort -R >&9 &
- ### GUI
- (
- yad --text-info --tail \
- --button=Jobs:'echo jobs' \
- --button=Delete:'echo delete' \
- --button=Quit:'echo quit' ;
- echo quit
- ) <&8 >&7 &
- ### Event Loop
- while read event; do
- case "${event}" in
- delete)
- ;;
- next)
- read book <&9
- echo "${book}" >&8
- ( ${COMIX} "${book}"; echo next >&7 ) &
- ;;
- quit) break ;;
- jobs) jobs ;;
- esac
- done <&7
Add Comment
Please, Sign In to add comment