-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
;; | ||
|
||
*) | ||
sleep infinity | ||
;; | ||
esac |