Fedora silverblue/kinoite hp-plugin

Hello,

I have fedora 38 kinoite and have been searching for a solution for the HP laserjet printer P1102w. If I try to print with out unlocking, I get filtered failed every time. The only solution I have found to get it to work is

sudo rpm-ostree unlock
hp-plugin

I have to re-install each time since this is lost on reboot.

Has anyone encountered this and found a better work around? If I was to install hp-plugin in a distrobox I am not sure how printing would work.

Thank you!

I was trying to solve this too. Thanks for the hack.

The best way I can find systemd service to install every boot.

This service is copying hp-plugin-download file to /usr/local/bin, then modifing this copied file so downloaded file not removed for the next reboot and install process.

This needs to be a system service (/etc/systemd/system/hp-plugin-install.service).

Whenever you power up your printer It starting to install hp-plugin (Or if powered up already while booting). First time is a little bit slow because of the download.

Note: hp-plugin installer is downloaded and staying in the /root/.hplip. It can be changed with another sed command.

[Unit]
Description=HP plugin install
Wants=local-fs.target printer.target network-online.target
After=local-fs.target printer.target network-online.target

[Service]
Type=oneshot
ExecStartPre=/usr/bin/cp /usr/bin/hp-plugin-download /usr/local/bin/hp-plugin-download-mod
ExecStartPre=/bin/sh -c "sed -i 's|/usr/bin/curl|/usr/bin/curl --fail|' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|download $${link}|if [ ! -e ~/.hplip/$${PLUGIN_FILE} ]; then download $${link}; fi|' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|/usr/bin/rm -f ~/.hplip/$${PLUGIN_FILE} &> /dev/null||' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=rpm-ostree usroverlay
ExecStart=/bin/sh -c "yes '' | /usr/local/bin/hp-plugin-download-mod"

[Install]
WantedBy=printer.target

That does not work on Atomic Fedora. Instead use /var/usrlocal/bin

That should also not work, unless you have a root user which you dont need to have.

you can leave the installer somewhere like /var/usrlocal/share or /var/lib

Actually, /usr/local is a symlink to /var/usrlocal so it works in either case.

1 Like

I didnt know you could use the linked location, thanks!

I can change that directory too but default hp-plugin installer asks your sudo password while installing. You need to have root, Installer need root privileges for installing plugins to unlocked /usr directory.

To make things automatic, I make this service as a system service so It start as root. If you try to install manually, installer is using ~/.hplip directory. So if you run as root it is /root/.hplip.

It’s not important where are you going to keep installer binary file if you ask me.

1 Like

I updated systemd service a little bit.

Changelog:

  • Install script is downloading and staying in /usr/local/share/hplip instead /root/.hplip
  • Bypass some complains about No display found & GUI mode not available
  • Avoid service failed because of Deployment is already in unlocked state error
  • Added ExecStartPost so just in case if you want to get rig of modded hp-plugin-download after install. It’s commented out.

/etc/systemd/system/hp-plugin-install.service

[Unit]
Description=HP plugin install
Wants=local-fs.target printer.target network-online.target
After=local-fs.target printer.target network-online.target

[Service]
Type=oneshot
ExecStartPre=/usr/bin/cp /usr/bin/hp-plugin-download /usr/local/bin/hp-plugin-download-mod
ExecStartPre=/bin/sh -c "sed -i 's|/usr/bin/curl|/usr/bin/curl --fail|' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|download $${link}|if [ ! -e ~/.hplip/$${PLUGIN_FILE} ]; then download $${link}; fi|' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|/usr/bin/rm -f ~/.hplip/$${PLUGIN_FILE} &> /dev/null||' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|^/usr/bin/bash.*|/usr/bin/bash ~/.hplip/$${PLUGIN_FILE} --quiet -- --interactive|' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=/bin/sh -c "sed -i 's|~/.hplip|/usr/local/share/hplip|g' /usr/local/bin/hp-plugin-download-mod"
ExecStartPre=-rpm-ostree usroverlay
ExecStart=/bin/sh -c "yes '' | /usr/local/bin/hp-plugin-download-mod"
# ExecStartPost=rm /usr/local/bin/hp-plugin-download-mod
[Install]
WantedBy=printer.target