Had to deal with the same CUPS nonsense here... Solution for me was a systemd script that runs every n minutes.
Create a folder, if not exist and create a script
sudo mkdir -p /usr/local/cups/
sudo nano /usr/local/cups/enable_cups_printers.sh
/usr/local/cups/enable_cups_printers.sh
#!/bin/sh
for printer in $(lpstat -p|awk '{print $2}')
do
echo "Forcibly enabling: $printer"
# PrinterId:-p Enable:-E
lpadmin -p "$printer" -E
done
Make the script executable for all users
sudo chmod +x /usr/local/cups/enable_cups_printers.sh
Test the script to ensure it won't produce errors
sudo sh /usr/local/cups/enable_cups_printers.sh
Create a service file
sudo nano /etc/systemd/system/cups.enable.printers.service
cups.enable.printers.service
[Unit]
Description = Forcibly enable printer occassionally. Why CUPS disables printers in the first place has yet to be determined.
[Service]
Type = simple
ExecStart = /usr/local/cups/enable_cups_printers.sh
[Install]
WantedBy = multi-user.wants
Create a timer file
sudo nano /etc/systemd/system/cups.enable.printers.timer
cups.enable.printers.timer
[Unit]
Description=Run enable printers frequently to ensure connection difficulties are remedied.
[Timer]
OnBootSec=15min
OnUnitActiveSec=300
[Install]
WantedBy = timers.target
Good place for *.service and *.target files would be
- system-wide: /etc/systemd/system/
- current user: ~/.config/systemd/user/
As lpadmin requires sudo privilege, it would be necessary to use system-wide approach.
Enable timer and start it
sudo systemctl enable cups.enable.printers.timer
sudo systemctl start cups.enable.printers.timer
If changed timer file, then restarting
sudo systemctl daemon-reload
sudo systemctl restart cups.enable.printers.timer
Checking status
systemctl status cups.enable.printers.timer
Checking log
journalctl -u cups.enable.printers.service
Checking all systemd timers
systemctl list-timers
Checking created timer only
systemctl list-timers | grep -i "next\|cups"