dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Get printer toner and paper level over network

Open samhh opened this issue 5 years ago • 3 comments

The Brother app can do it...

samhh avatar Nov 10 '20 22:11 samhh

https://github.com/samhh/dotfiles/commit/c8b85177165b9db331b0a8668b640c85a9b83c32

Experimenting with media-ready for the paper level.

samhh avatar Nov 15 '20 23:11 samhh

Not had a chance to test this yet, so for redundancy:

diff --git a/home/scripts/printer-toner.sh b/home/scripts/printer-toner.sh
index 9ad5073..a3ed061 100755
--- a/home/scripts/printer-toner.sh
+++ b/home/scripts/printer-toner.sh
@@ -1,6 +1,16 @@
 #!/bin/sh
 
-n=$(ipptool -tv ipp://BRW7440BBBDE8DC/BINARY_P1 get-printer-attributes.test | grep marker-levels | cut -d = -f 2 | xargs)
+data=$(ipptool -tv ipp://BRW7440BBBDE8DC/BINARY_P1 get-printer-attributes.test)
 
-echo "Printer toner: $n% remaining"
+toner_perc=$(echo "$data" | grep marker-levels | cut -d = -f 2 | xargs)
+
+# Don't know if this changes upon running out of paper, needs verifying
+if echo "$data" | grep -q 'media-ready (keyword) = iso_a4_210x297mm'; then
+  paper_available="Paper is available."
+else
+  paper_available="WARNING: No paper is available."
+fi
+
+echo "$paper_available"
+echo "Printer toner: $toner_perc% remaining"

Edit: No luck.

samhh avatar May 12 '21 21:05 samhh

https://www.pwg.org/ipp/ippguide.html

samhh avatar Aug 17 '21 13:08 samhh