Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to print from a flatpak app? #90

Closed
SuffolkPunch opened this issue Jun 17, 2019 · 34 comments
Closed

How to print from a flatpak app? #90

SuffolkPunch opened this issue Jun 17, 2019 · 34 comments

Comments

@SuffolkPunch
Copy link

I'm running flatpak (v 1.4.0-1~xenial) in LinuxMint 18.3 on my home PC.
I use CUPS to print from my home pc to a usb printer attached to my home server - both run LM 18.3.

I have installed the following flatpak apps:

net.scribus.Scribus/x86_64/stable
org.libreoffice.LibreOffice/x86_64/stable

My issue: Neither of these 2 apps sees my system printer. Instead, they just list a 'Generic Printer'. See pasted png image:
printer-setup
The drop-down list doesn't reveal any other printers.

My work-around - first export the file to pdf and then print from a non-flatpak pdf viewer!

So, does anyone know how you get a flatpak app to see printers that all the non-flatpak apps see?

@stbergmann
Copy link
Collaborator

(Works fine for me with the recent LO 6.2.4.2 flatpak on Fedora 30 GNOME/Wayland. In e.g. Writer, "File - Printer Settings..." dialog lists the correct printer, not "Generic Printer".)

@SuffolkPunch
Copy link
Author

@stbergmann: That's interesting - is your printer on the same PC or (as in my case) on the same LAN accessed via CUPS?

@SuffolkPunch
Copy link
Author

Didn't mean to close this issue - hit the wrong icon, sorry. I am still seeking a fix.

@SuffolkPunch
Copy link
Author

Please re-open this issue.

@SuffolkPunch SuffolkPunch reopened this Jun 17, 2019
@stbergmann
Copy link
Collaborator

@stbergmann: That's interesting - is your printer on the same PC or (as in my case) on the same LAN accessed via CUPS?

The latter, LAN via CUPS.

@eszlari
Copy link

eszlari commented Apr 13, 2020

Works here with my HP printer via USB:
Kubuntu 19.10
KDE Plasma 5.16.5
CUPS 2.2.12
flatpak 1.4.3

@Gwerlas
Copy link

Gwerlas commented Apr 23, 2020

Doesn't work with LAN printers
Fedora Silverblue 31
Cups 2.2.12
Flatpak 1.4.4

@Madko
Copy link

Madko commented May 14, 2020

Same here on Fedora 32 Silverblue
Flatpak 1.6.3
Cups 2.3.1

I tried to give cups access to the LO flatpak thanks to flatseal, but no luck. Same with dbus acces. Is that a "green" tech to prevent waste of paper ? Pretty neat

@Erick555
Copy link
Contributor

Erick555 commented Aug 14, 2020

For me adding --socket=cups was enough to fix the issue.

Printer via LAN
Flatpak 1.8.1
Arch Linux
KDE Plasma 5.19

@geodro
Copy link

geodro commented Jan 4, 2022

hey there, any updates on this?

@Erick555
Copy link
Contributor

Erick555 commented Jan 4, 2022

@geodro does solution from #90 (comment) works for you?

ppd pushed a commit to qelectrotech/qelectrotech-source-mirror that referenced this issue Jan 5, 2022
@geodro
Copy link

geodro commented Jan 5, 2022

@geodro does solution from #90 (comment) works for you?

Sadly no. I have a network printer

@scorpio810
Copy link

--share=network - access the network?

@scorpio810
Copy link

@geodro
Copy link

geodro commented Jan 5, 2022

--share=network - access the network?

not working also, I am using Fedora Silverblue 35 with the most recent updates.

Screenshot from 2022-01-05 11-05-26

@geodro
Copy link

geodro commented Jan 5, 2022

Like? sudo snap connect musescore:cups-control

I am using flatpak version of LibreOffice

@SuffolkPunch
Copy link
Author

I had completely forgotten I started this issue 2½ years ago. Thanks for everyone's ideas. But, I no longer use flatpak versions of LibreOffice or Scribus, so lost interest. Happy if this issue is closed.

@fedelibre
Copy link

not working also, I am using Fedora Silverblue 35 with the most recent updates.

@geodro I'm also using Silverblue and printing on LibreOffice has worked fine for a long time.

It seems you've not selected the right printer. In the LibreOffice dialog I see a Generic Printer, while in your printer settings the printer is called HP Laserjet. Can't you find it in the dropdown list of LibreOffice?

@geodro
Copy link

geodro commented Jan 5, 2022

@geodro I'm also using Silverblue and printing on LibreOffice has worked fine for a long time.

It seems you've not selected the right printer. In the LibreOffice dialog I see a Generic Printer, while in your printer settings the printer is called HP Laserjet. Can't you find it in the dropdown list of LibreOffice?

The dialog in the screenshot is selected. The only options are Print to file and Generic Printer.

@fedelibre
Copy link

Weird... try undoing permission changes in Flatseal so you're sure you're using the same as me. For example, I don't have socket=cupsenabled.

@geodro
Copy link

geodro commented Jan 5, 2022

Weird... try undoing permission changes in Flatseal so you're sure you're using the same as me. For example, I don't have socket=cupsenabled.

I've undo the permissions and the behavior is the same. No printer seen.

scorpio810 added a commit to flathub/org.qelectrotech.QElectroTech that referenced this issue Jan 6, 2022
@fedelibre
Copy link

Then @geodro I suggest you ask for help on https://ask.fedoraproject.org/

ppd pushed a commit to qelectrotech/qelectrotech-source-mirror that referenced this issue Jan 14, 2022
* master:
  BugFix : default element collection path is wrong
  snap: Remove framework snap prompt
  Update translation and add cn chinese ts files
  Danish translation updated
  Danish translation
  Danish translation
  Add new thumbnail element
  Flatpak add --share=network
Flatpak : add --socket=cups see :
flathub/org.libreoffice.LibreOffice#90
  Graphics item handler is bigger when overred
  Add toolbar widget for edit size of handler in diagram editor.
  Fix Multiple translation in elements
  Fix Multiple translation in elements
  Fix segfault.
  new Analog-In - Module
  cleanup and upgraded elements
  modified:   lang/qet_nl.qm 	modified:   lang/qet_nl.ts
  Add Russian translation, thanks "А.Разживин"
  little modification in hungarian language
  Fixed typo
@ahsodex
Copy link

ahsodex commented Mar 29, 2022

I got my Epson network printer to show up in LibreOffice installed via Fedora Linux Flatpak repo on Fedora Silverblue 35 by adding "D-Bus system bus" permission in Flatseal.

@garrett
Copy link

garrett commented Mar 29, 2022

I printed over the network today using LibreOffice in a flatpak with the default settings. At first, I assumed it might not work and I might need to save to a PDF and print that with Evince, as before. But printing from LibreOffice worked without issues here.

image

This is on Fedora Silverblue 36 beta on GNOME 42 in Wayland with the automatic default driverless setting for my Brother printer. D-Bus is not enabled for either user or system.

image

To be clear: This is on the Flathub Libreoffice, not the Fedora Flatpak or the Fedora RPM (as an overlay). I just checked to be certain.

I did follow this bug because I had printing issues on Fedora at least a release or two ago. It's probably worth considering having "D-Bus system bus" enabled by default if that's what's necessary to fix printing for people using LibreOffice on various distro + desktop combinations.

So it's possible that something in Fedora itself (including GNOME) changed in the 36 beta, or I just got lucky here with the defaults. If not, I wonder why it's working for me without the D-Bus settings and it only works for @ahsodex with system D-Bus access enabled.

@Erick555
Copy link
Contributor

It would be nice to check actual dbus address needed with --log-system-bus option. Allowing whole system bus access may be not acceptable solution.

@garrett
Copy link

garrett commented Mar 29, 2022

@Erick555: I'm assuming that means @ahsodex should run the following at a terminal prompt and attempt to print, right? Would he need to reset settings first or just go with the D-Bus system bus enabled when running it?

flatpak run --log-system-bus org.libreoffice.LibreOffice

I just tried it here and it printed fine and there was no output, but things were working correctly for me with default settings, so I guess his printer needs some D-Bus call (I suppose) while mine doesn't?

@Erick555
Copy link
Contributor

Yes this is how I would test this (including removal of session-bus permission).

I realized the report comes from Fedora flaptak though not flathub so this is like apples & oranges comparison that may lead us nowhere.

@ahsodex
Copy link

ahsodex commented Mar 29, 2022

Where is it supposed to log to? man flatpak-run doesn't say. I tried "flatpak run --log-system-bus org.libreoffice.LibreOffice" without the D-Bus permission, verified only the generic printer shows, then tried it again with D-Bus permission and verified my Epson printer shows and prints. I checked journalctl and only got this:

systemd[1633]: Started app-flatpak-org.libreoffice.LibreOffice-34909.scope.
systemd[1633]: app-flatpak-org.libreoffice.LibreOffice-34909.scope: Consumed 7.193s CPU time.
systemd[1633]: Started app-flatpak-org.libreoffice.LibreOffice-35066.scope.
systemd[1633]: app-flatpak-org.libreoffice.LibreOffice-35066.scope: Consumed 7.550s CPU time.

and this from the terminal:

(soffice:32): GLib-GObject-WARNING **: invalid cast from 'OOoAtkObjCompSel' to 'GtkWidgetAccessible'
(soffice:32): GLib-GObject-WARNING **: invalid cast from 'OOoAtkObjCompSel' to 'GtkWidgetAccessible'
(soffice:32): GLib-GObject-WARNING **: invalid cast from 'OOoAtkObjCompSel' to 'GtkWidgetAccessible'
(soffice:32): GLib-GObject-WARNING **: invalid cast from 'OOoAtkObjCompSel' to 'GtkWidgetAccessible'
(soffice:32): GLib-GObject-WARNING **: invalid cast from 'GtkBox' to 'GtkMenuShell'
(soffice:32): GLib-GObject-WARNING **: invalid cast from 'GtkBox' to 'GtkMenuShell'

@garrett
Copy link

garrett commented Mar 30, 2022

I realized the report comes from Fedora flaptak though not flathub so this is like apples & oranges comparison that may lead us nowhere.

Yeah, agreed. I've specifically chosen to use the Flathub version instead of the Fedora version of LibreOffice. It's nice to get the new releases ASAP. (Huge thanks to everyone who works on making LibreOffice on Flathub a reality! 🥳)

@ahsodex: If it's the Fedora Flatpak of LibreOffice, then that's definitely a bug that should be reported (at https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=libreoffice). You might also want to try the Flathub version instead, to see if printing works for you out of the box. (If it is the Flathub version, then you're at the right place.)

You can check the version like this:

flatpak list | grep libreoffice

And if it's from Flathub, results will look like this:

LibreOffice	org.libreoffice.LibreOffice	7.3.1.3	stable	flathub	system

@ahsodex
Copy link

ahsodex commented Mar 30, 2022

$ flatpak info org.libreoffice.LibreOffice
LibreOffice - The LibreOffice productivity suite
          ID: org.libreoffice.LibreOffice
         Ref: app/org.libreoffice.LibreOffice/x86_64/stable
        Arch: x86_64
      Branch: stable
     License: MPL-2.0
      Origin: fedora
  Collection:
Installation: system
   Installed: 2.8 GB
     Runtime: org.fedoraproject.Platform/x86_64/f35
         Sdk: org.fedoraproject.Sdk/x86_64/f35
      Commit: 82c0ed86a303e4e3286252b13b80077e4a4c558d2cbc066162cffe2342a3f4eb
     Subject: Export org.libreoffice.LibreOffice
        Date: 2022-02-09 15:50:55 +0000
      Alt-id: 57f6555cf1c60829964049ac12b5c0f80dc28a45d3a4263ba96763a49d437d1d

My flatpak command doesn't show version info but here's a copy from about:

Version: 7.2.5.2.0+
Build ID: 20(Build:2)
CPU threads: 4; OS: Linux 5.16; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

So it's an older version of LibreOffice too. I uninstalled that and installed the newer version from Flathub repo but now it doesn't show my printer, whether I enable D-Bus session or system, or Printing system permissions or just default. I went back to the Fedora flathub repo version and it's back to showing my printer with just D-Bus system bus permission enabled. I don't really care that much about it, it was a minor annoyance even having to print to PDF and then to my printer since I print so rarely, so I'm good. Thanks!

@lightweight
Copy link

I'm running KDE Neon 20.04, with Thunderbird and Firefox installed via Flatpak. I was seeing the issue of no system printers visible in the print dialogue of either Flatpak app. I installed the Flatseal app (sudo plasma-discover and then searched on Flatseal and installed it) so I could do as this report says - enable "Printing System" with socket=cups. Turns out it was already enabled. I disabled it, restarted FF and T-bird.. and voila, the system printers are now visible when printing. So it seems that for some apps in recent times, the opposite measure achieves the desired result. Hope that helps someone.

@ssokolow
Copy link

My best guess is that, with socket=cups, it uses direct CUPS access in a broken way while, without socket=cups, it's deferring to org.freedesktop.portal.Print and that doesn't have said bug.

(Perhaps it's using a mix of the two and doing something akin to getting a sandboxed file path from the File Chooser portal and then attempting to write a sibling file into the containing folder.)

@binary-adam
Copy link

Using flatseal to give access to DBus seemed to work for me - print dialog went from only having 'to pdf' to having my actual printer in it.

@De-Clan-C
Copy link

For me I found out that my printer wasn't defined in /etc/cups/printers.conf. It would come up in Gnome settings, but never my browser nor LibreOffice. I assumed it was some flatpak quirk and I found ways around it. Even when I set the socket=cups permission I still didn't get any different options besides "generic printer". Then I learned how to configure my printer in the CUPS GUI in the browser and it works now.

For anyone who doesn't know how this works. Open your browser and go to localhost:631If cups is running on your system, it will pull up the page.

Go to administration at the top, and it will prompt for a username and password, just give it your local credentials.

Then click "find printer" or "add printer", (they seem to do very similar things, though find printer gave me a more concise list) and find the model you have in the list.

You can then define the friendly name for the printer and it's location.

The next step is selecting the driver. You might need to select the brand and model, but after that try to find a driver that's named after your printer. I had to try a couple of different drivers before my printer worked correctly.

Once you find the driver you can click "set default options" and it will take you to a page to do so. Once you're done click "set default options" again and it will generate the changes into the /etc/cups/printers.conf file.

Once this is set any app with the socket=cups permission will be able to access the printer. This should be a more secure option than giving access to the whole system bus.

Hope this helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests