By Fredrik Brattstig @virtualbrat
Until now, there is no implemented solution from Microsoft in the Windows Virtual Desktop client SDK for Linux. This hinders users from being able to print. Well, that’s a bummer if your users actually do have a need for it, right. Here you will get a interim solution until there is a functional implementation of printing subsystem in WVD.
Before you start reading: this writeup is just a example, it is not the intended way of printing, it is just a way for me to provide you a workaround on how to enable printing for your WVD sessions. Built in solutions will come, but it is not here yet.
The scripts might need to be adjusted to fit your needs! This is not a solution that IGEL the company provides support for at this stage.
Thanx to Jeff Kalberg and Sebastian Kurpiela @IGEL for discussions to get here!
Lets start by looking at what i have:
1. IGEL OS endpoint
2. Brother DCP-L3550VDW Color Laser printer, network connected in my home office
3. WVD session
There is no connection between the Windows Virtual Desktop session running in Azure east United States and my home office in Sweden aka the WVD machine cannot reach my printer, and as said before there are no printing possibilities in the WVD client. – Impossible to get printing to happen!?
– Well, NO! I will use the file redirection implementation in the WVD client.
– Let me explain. enabled by default there is a function to map the local storage on the IGEL OS endpoint to the WVD session. the physical location on the IGEL endpoint is /userhome/media in the WVD session this will be seen as \\tsclient\media
– Well, how could that possibly help me? I need that paper output!
– Sure, lets go on. The idea came up by looking at the HTML5 implementation of the WVD client. There you can print to the local endpoints print subsystem by using the browser printing functionality. The WVD session sends the print job as a PDF to the browser on the endpoint and allows the endpoint to print. But honestly, the HTML5 client, as good as it is, in my opinion, this is nothing that i would like to use on a daily basis.
– What if I could print in the WVD session – as a file, and have that file saved to the \\tsclient\media folder, then have a routine monitoring this folder on the local client and print any file appearing in that folder?
– IT WORKS!!
Here is how I did it:
- I added my printer using CUPS to my IGEL OS endpoint
As my printer doesn’t have the correct drivers in the IGEL OS, I have 2 options here:
1.1 Use custom PPD printer definition -> kb.igel.com – PPD
1.2 Find a generic driver that works for your printer
In my case I went for setting “Manufacturer” to Generic and “Printer Name” to Post Script Printer. (This is a trial and error exercise, to find whats working for your printer)
- I created a shell script, to distribute to my IGEL endpoints: wvdprint.sh
#bin/bash! mkdir /userhome/media/print chown user:users /userhome/media/print inotifywait -r -m /userhome/media/print -e close_write | while read a b file; do [[ $b == *CLOSE_WRITE* ]] && lpr /userhome/media/print/"$file" && sleep 2 && rm /userhome/media/print/"$file" done
The script will create a folder called print in /userhome/media, it will set the user as owner of that directory (the session is ran in the user context, so user needs access to the folder to allow writing) and inotifywait will monitor the directory for close_write operations of files in the /userhome/media/print folder. This makes sure that the system doesn’t try to print the document before it arrived complete to the IGEL endpoint, then prints the file using the lpr command to the default printer. And in my example I do some housekeeping and remove the print-file after the lpr command are supposed to be finished ( i have seen that large files might have to have the sleep value increased, or maybe use inotifywait to notify on closed_read when printing is done) , this to make sure that the drive doesn’t fill up… BTW, the /userhome/media directory is emptied on device reboot.
You can copy the text and put it into a unformatted (I use notepad++) text file named wvdprint.sh
2.1 Add the wvdprint.sh as a “file” object in your UMS, where you set the file to be placed in /wfs/wvdprint.sh with the user rights to access and execute the file
2.2 Assign this file to your endpoints where you want to enable printing.
Here you have the immediate benefit of using the IGEL ICG to control your users endpoints, like the UD Pocket, if they are remote located in home office. assign, and go back to sleep 🙂 .
3. Now we need to call that script when launching Windows Virtual Desktop!
Open your Windows Virtual Desktop profile, Goto system ->Registry->Sessions->wvd0->init_action and put the code:
/bin/bash /wfs/wvdprint.sh &
making it look like:
3.1 If you want the script to stop when you shut down your Windows Virtual Desktop session, Goto system ->Registry->Sessions->wvd0->final_action and put the code:
This is actually all you need to do on the IGEL side to get printing working in WVD sessions. Now lets see what we need to to on server (WVD host) side:
When you have the IGEL OS endpoints set up according to above, all you need to do on the WVD side is to put a .pdf file in the \\tsclient\media\print folder, which you can find through Windows Explorer -> Network-> tsclient -> media -> print. As soon as you copy a file to this folder, it will be printed on the endpoints default printer. But how do we make this usable for a user that wants to print from word?
I googled for a pdf printer where you administratively can set to print the PDF without user intervention, directly to a folder in your WVD desktop. I stubled across the BullZip pdf printer https://www.bullzip.com/products/pdf/download.php .
BullZip PDF printer can du just that, prespecify a output folder and filename for a .pdf printer according to below settings:
Probably there are other solutions out there that can do the same thing. This was the first functional example that I stumbled across. The whole idea is as always to make it as simple as possible for your users, what can be easier than set the pdf printer of choice as the only one and default printer.
Side note: The files to be printed doesn’t have to be .pdf format. All formats that lpr can interpret will print just fine.
Below you have a video of how it could look for a end-user printing in WVD from a IGEL OS Endpoint. Enjoy and stay safe!