Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-01-01 21:32:38

pavloskiv
Member
Registered: 2019-12-19
Posts: 27

Thunar custom actions to print a PDF file from DOC file.

Good evening,
I'd like to set a custom action in Thunar File Manager doing this: convert a doc/docx file using lowriter --convert-to pdf , then send the output (pdf) to print with lpr command. I know I can print doc/docx files directly using lowriter -p command, but I'd like to try this option.
Thanks, vladi
OS: Xubuntu 16.04.6

Offline

#2 2020-01-02 16:20:05

CwF
Member
Registered: 2018-01-28
Posts: 305

Re: Thunar custom actions to print a PDF file from DOC file.

I don't know the exact commands, work that out in a terminal and then stick them together into the custom action. '&&' would allow the two to complete independently

So one step is covert a doc to pdf.
&&
The last step is printing the doc file.
   
lowriter --convert-to pdf %f && lowriter -p %f

Offline

#3 2020-01-02 20:05:39

pavloskiv
Member
Registered: 2019-12-19
Posts: 27

Re: Thunar custom actions to print a PDF file from DOC file.

@CwF I know , I tried several times, the last step I want is print the PDF file (result of lowriter --convert-to pdf) and not the doc file. So
some thing like this: lowriter --convert-to pdf %f && lpr (new pdf created file)
I don't know how to get this new pdf file and print it with lpr.

OK! I found a way to do that, a small script : for file in "$@"; do (lowriter --convert-to pdf $file); lpr "${file%.*}.pdf"; done 
then add the script to Thunar custom actions. I don't know if it's the right way but works.

Last edited by pavloskiv (2020-01-03 13:40:39)

Offline

#4 2020-01-05 14:20:46

CwF
Member
Registered: 2018-01-28
Posts: 305

Re: Thunar custom actions to print a PDF file from DOC file.

very good pavloskiv. I didn't catch it was better to print the pdf than the doc.

Is there a good index somewhere of what is legal and possible within the command line of the custom action?

I'd like to make many I don't know how to yet, and calling a script is the easier way, but packaging the script into a single line within the command line seems to break the command, and my thinking.  IE. declaring variables, incrementing filenames and the like requires a script? I suppose there is only thunar's variable handling and not general bash possibilities without calling an external script?

Similar to creating a launcher and fitting it all on one long line instead of calling a script, it seems the 'run in terminal' option saves the day while thunar has no such option?

Offline

#5 2020-01-05 19:44:56

pavloskiv
Member
Registered: 2019-12-19
Posts: 27

Re: Thunar custom actions to print a PDF file from DOC file.

@Member I'll try to be more didactic: If you write the command above directly to Thunar custom actions it won't work, so you need to create a new file with mousepad or any other txt editor and paste this: #!/bin/bash
for file in "$@"; do (lowriter --convert-to pdf $file); lpr "${file%.*}.pdf";done
save the file and give any name but with .sh extension, make this new file executable (you can save this file in any directory you want), in my case I have this script in ~/Scripts/newfile.sh. After that open Thunar and add the custom action, for command click on the right icon to find the script you just create (navigate to the folder where the script is) then for appearance conditions choose other files and patterns *.doc;*.docx . That's it, thanks for reply.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.007 seconds, 7 queries executed - Memory usage: 544.44 KiB (Peak: 545.06 KiB) ]