diff --git a/install/desktop/printer.sh b/install/desktop/printer.sh index 17b2d31..930eea1 100644 --- a/install/desktop/printer.sh +++ b/install/desktop/printer.sh @@ -1,4 +1,16 @@ #!/bin/bash -sudo pacman -S --noconfirm cups cups-pdf cups-filters system-config-printer +sudo pacman -S --noconfirm cups cups-pdf cups-filters cups-browsed system-config-printer avahi nss-mdns sudo systemctl enable --now cups.service + +# Disable multicast dns in resolved. Avahi will provide this for better network printer discovery +sudo mkdir -p /etc/systemd/resolved.conf.d +echo "[Resolve]\nMulticastDNS=no" | sudo tee /etc/systemd/resolved.conf.d/10-disable-multicast.conf +sudo systemctl enable --now avahi-daemon.service + +# Enable automatically adding remote printers +if ! grep -q '^CreateRemotePrinters Yes' /etc/cups/cups-browsed.conf; then + echo 'CreateRemotePrinters Yes' | sudo tee -a /etc/cups/cups-browsed.conf +fi + +sudo systemctl enable --now cups-browsed.service diff --git a/migrations/1754215533.sh b/migrations/1754215533.sh new file mode 100644 index 0000000..05a0774 --- /dev/null +++ b/migrations/1754215533.sh @@ -0,0 +1,17 @@ +echo "Enable auto-discovery of network printers" + +if [[ ! -f /etc/systemd/resolved.conf.d/10-disable-multicast.conf ]]; then + sudo pacman -S --noconfirm avahi nss-mdns + + # Disable multicast dns in resolved. Avahi will provide this for better network printer discovery + sudo mkdir -p /etc/systemd/resolved.conf.d + echo "[Resolve]\nMulticastDNS=no" | sudo tee /etc/systemd/resolved.conf.d/10-disable-multicast.conf + sudo systemctl enable --now avahi-daemon.service +fi + +if ! grep -q '^CreateRemotePrinters Yes' /etc/cups/cups-browsed.conf; then + sudo pacman -S --noconfirm cups-browsed + # Enable automatically adding remote printers + echo 'CreateRemotePrinters Yes' | sudo tee -a /etc/cups/cups-browsed.conf + sudo systemctl enable --now cups-browsed.service +fi