Is there a way to run a bash script everytime I print something?
that might be very interesting, funny and useful ! I have not yet a complete answer but what i think could do the trick is to use a daemon that watch and act when something is printed.
You could use this documentation :
https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html
And especially this example : "Monitoring a Directory" The following example starts the job whenever any of the paths being watched have changed:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.watchhostconfig</string>
<key>ProgramArguments</key>
<array>
<string>syslog</string>
<string>-s</string>
<string>-l</string>
<string>notice</string>
<string>somebody touched /etc/hostconfig</string>
</array>
<key>WatchPaths</key>
<array>
<string>/etc/hostconfig</string>
</array>
</dict>
</plist>
You should monitor the directory "/var/spool/cups" as mentioned here https://www.cups.org/doc/spec-design.html and do something when there is change. So in your case, change the background image.
You could also see the command "lpstat -o" that could be useful for that task (cf https://www.computerhope.com/unix/ulpstat.htm)
To be continued...