Skip to content

Commit

Permalink
chore: add source files
Browse files Browse the repository at this point in the history
  • Loading branch information
vittee committed Nov 17, 2024
1 parent f193f0a commit f2a6067
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM ubuntu:noble

LABEL org.opencontainers.image.source="https://github.com/vittee/drippybot"
LABEL org.opencontainers.image.description="DrippyBot"
LABEL org.opencontainers.image.author="Wittawas Nakkasem <vittee@hotmail.com>"
LABEL org.opencontainers.image.url="https://github.com/vittee/drippybot/blob/main/README.md"
LABEL org.opencontainers.image.licenses=MIT

ENV TZ=UTC

RUN apt update -y

RUN apt install fzf cups printer-driver-escpr -y

COPY entrypoint.sh /

ENTRYPOINT ["/entrypoint.sh"]
53 changes: 53 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

err() {
echo -e >&2 "$@"
exit 1
}

model() {
cupsd
lpinfo -m | fzf --tac --layout=reverse --with-nth 2.. --bind 'enter:become(echo {1})'
}

print() {
if [ -z ${URI+_} ]; then
err No printer URI is specified
fi

if [ -z ${MODEL+_} ]; then
err "No printer MODEL is specified\nTry running with \"model\" argument to select a supported model"
fi

cupsd

# Add the printer
lpadmin -p default -v "$URI" -m "$MODEL"
# Enable and accept print job
cupsaccept default
cupsenable default
# Set as a default printer
lpoptions -d default
# Send the print job
lp /usr/share/cups/data/testprint
# wait
sleep ${WAIT:-5}
}

case "$1" in
model)
model
;;

bash)
bash
;;

print)
print
;;

*)
sleep infinity
;;
esac

0 comments on commit f2a6067

Please sign in to comment.