brezerk / q4wine

Q4Wine is a Qt GUI for W.I.N.E. It will help you manage wine prefixes and installed applications.
http://q4wine.brezblock.org.ua/
GNU General Public License v3.0
208 stars 40 forks source link

q4wine-cli does not accept extra app arguments #78

Open brezerk opened 8 years ago

brezerk commented 8 years ago

Original message from @Svadkos at https://github.com/brezerk/q4wine/issues/69

Hello, is there any way to open file in wine program, not just open program? For example, if i want to open document with MSO Word from file manager dialog.

Well, actually i mean start file through icon that q4wine create. /usr/bin/q4wine-cli -p "office" -i "Word" and than it just start new empty document, skipping all arguments that follow.

brezerk commented 8 years ago

Hi @Svadkos this commit https://github.com/brezerk/q4wine/commit/96e70931ec745a0f50c73636b59101477625bd36 fixes the issue, when all extra arguments passed to q4wine-cli was ignored.

Now they are by passed to the app correctly:

[ himera ] brezerk@pts/4:18  ~ $
> 07/08/16 00:37:35 EEST > /tmp/build-q4wine/src/q4wine-cli/q4wine-cli -p "Default" -d "system" -i "wordpad" "/home/brezerk/normalize.sh"
[ii] corelib::runWineBinary:  "/tmp/build-q4wine/src/q4wine-helper/q4wine-helper" ("--prefix", "Default", "--nice", "0", "--program-args", " /home/brezerk/normalize.sh", "--program-bin", "wordpad.exe", "--wrkdir", "/home/brezerk")  at:  "/home/brezerk"
Done

I have fixed *.desktop files export as well, now %f tag will be added at the end of Exec entity.

Just in case, if you need to fix any existing *desktop file manually, just add %f tag at the end of Exec entity.

Here you are the example:

[Desktop Entry]
Exec=/usr/local/bin/q4wine-cli -p "Default"  -d "system"  -i "wordpad"  %f
Icon=/usr/local/share/q4wine/icons/wordpad.svg
Type=Application
StartupNotify=true
GenericName=wordpad
Comment=Wine wordpad text editor
Name=wordpad
Path=

It will be nice if you play around latest git build to test it. Let me know if you have any questions.

ghost commented 8 years ago

Seems like he trying to open document from working directory, but this document is located in ~/Documents. screenshot_20160708 Maybe then create some file associations as wine does, because as far as i remember, they worked? But the only ones i might create or choose myself, not all of them.

I have fixed *.desktop files export as well

And to me now it is stopped working, lol. Q4wine create file in ~/.config/menus/applications-merged/, but ~/.local/share/applications/ stays empty.

ghost commented 8 years ago

And to me now it is stopped working, lol. Q4wine create file in ~/.config/menus/applications-merged/, but ~/.local/share/applications/ stays empty.

Test one more time on stable q4wine and still ~/.local/share/applications/ stays empty, hm.

brezerk commented 8 years ago

Hi @Svadkos,

Seems like he trying to open document from working directory, but this document is located in ~/Documents.

not sure if it related to q4wine.

both: /tmp/build-q4wine/src/q4wine-cli/q4wine-cli -p "Default" -d "system" -i "wordpad" "/home/brezerk/Documents/normalize.sh and /tmp/build-q4wine/src/q4wine-cli/q4wine-cli -p "Default" -d "system" -i "wordpad" "~/Documents/normalize.sh

works fine for build in wordpad app for me.

and still ~/.local/share/applications/ stays empty

Yes, q4wine does not populate ~/.local/share/applications/

ghost commented 8 years ago

not sure if it related to q4wine.

You right, in new prefix it began to work.

Yes, q4wine does not populate ~/.local/share/applications/

Well, i'm pretty sure that it did before. And if i'm wrong why q4wine create file in ~/.config/menus/applications-merged/ with structure of icons?

brezerk commented 8 years ago

Hi @Svadkos

why q4wine create file in ~/.config/menus/applications-merged/ with structure of icons?

It allows your DM to build q4wine's app menu structure:

screenshot_20160712_220453 screenshot_20160712_220510 screenshot_20160712_220528 screenshot_20160712_220551 screenshot_20160712_220741

brezerk commented 8 years ago

Well, i'm pretty sure that it did before.

Nope :) afik wine itself is responsible for creating files associations:

[ himera ] brezerk@pts/0:1  ~ $
> 07/12/16 22:09:07 EEST > ls ~/.local/share/applications 
drwxr-xr-x  4 brezerk brezerk 4096 Jul  8 00:47 .
drwxr-xr-x 30 brezerk brezerk 4096 Jul 10 13:07 ..
-rw-------  1 brezerk brezerk  153 May 14 12:51 mimeapps.list
-rw-r--r--  1 brezerk brezerk  719 May  2 19:30 mimeinfo.cache
-rw-r--r--  1 brezerk brezerk  205 May  1 22:25 wine-extension-chm.desktop
-rw-r--r--  1 brezerk brezerk  212 May  1 22:25 wine-extension-gif.desktop
-rw-r--r--  1 brezerk brezerk  207 May  1 22:25 wine-extension-hlp.desktop
-rw-r--r--  1 brezerk brezerk  205 May  1 22:25 wine-extension-htm.desktop
-rw-r--r--  1 brezerk brezerk  219 May  1 22:26 wine-extension-ini.desktop
-rw-r--r--  1 brezerk brezerk  215 May  1 22:26 wine-extension-jfif.desktop
-rw-r--r--  1 brezerk brezerk  214 May  1 22:26 wine-extension-jpe.desktop
-rw-r--r--  1 brezerk brezerk  228 May  1 22:26 wine-extension-msp.desktop
-rw-r--r--  1 brezerk brezerk  212 May  1 22:26 wine-extension-png.desktop
-rw-r--r--  1 brezerk brezerk  213 May  2 19:30 wine-extension-rtf.desktop
-rw-r--r--  1 brezerk brezerk  197 May  1 22:26 wine-extension-txt.desktop
-rw-r--r--  1 brezerk brezerk  220 May  1 22:26 wine-extension-url.desktop
-rw-r--r--  1 brezerk brezerk  210 May  1 22:26 wine-extension-vbs.desktop
-rw-r--r--  1 brezerk brezerk  208 May  1 22:26 wine-extension-wri.desktop
-rw-r--r--  1 brezerk brezerk  210 May  1 22:26 wine-extension-xml.desktop

but q4wine is not really aware of any of them.

brezerk commented 8 years ago

hi @Svadkos anything else needs to be fixed in this scope? can we close this issue?

ghost commented 8 years ago

Sorry, couldn't answer before.

It allows your DM to build q4wine's app menu structure:

I see, maybe i broke something, or it's kde bug. Before i have exactly the same menu. Now it's just empty structure in menu editor. screenshot_20160721_155938

Nope :) afik wine itself is responsible for creating files associations:

I know, and don't like it, too much unnecessary trash, so i turn it off, or remove.

anything else needs to be fixed in this scope? can we close this issue?

In this scope, i think nothing, beside associations. But if you think that's a bad idea, so be it, i still can create them myself through DM.

brezerk commented 8 years ago

ic. Well. It is up to you: if you think it will be good idea to have ability to create files association via q4wine's menu: feel free to create an separate ticket to discuss this feature.

I will close this ticket.

Thanks for the bug report, re open if needed.

mg979 commented 6 years ago

Hello, I still have issues with this.

First: this is a desktop entry for MS Word

[Desktop Entry]
Exec=/usr/bin/q4wine-cli -p "Office"  -d "system"  -i "MS Word"  %f
Icon=/home/xxx/.PlayOnLinux/icones/full_size/WINWORD
Type=Application
StartupNotify=true
GenericName=MS Word
Name=MS Word
Path=/home/xxx/.PlayOnLinux/wineprefix/Office/drive_c/Program Files/Microsoft Office/OFFICE11/

If I try to open a .doc file with it (with direct file association), the file isn't loaded. That is, Word is started with an empty file. It works with wine desktop file, that is:

[Desktop Entry]
Type=Application
Name=Microsoft Office Word
MimeType=application/msword;
Exec=env WINEPREFIX="/home/xxx/.PlayOnLinux/wineprefix/Office" wine start /ProgIDOpen Word.Document.8 %f
NoDisplay=true
StartupNotify=true

Second, if the filename has spaces in it, not only it isn't loaded, but MS Word throws an error that it couldn't load the file. It doesn't if I add quotes to %f. but the file still isn't loaded:

Exec=/usr/bin/q4wine-cli -p "Office"  -d "system"  -i "MS Word"  "%f"
brezerk commented 6 years ago

hi @mg979

Thanks for feedback. I'll take a look on it tomorrow.

But just to confirm: which one q4wine version are you using?

mg979 commented 6 years ago

It's version v1.3.3 using Qt 5.7.1, on latest MX Linux(Debian stable). I solved it by using wine start /ProgIDOpen command for now, even if it forces me to use default wine version.

Also, I have some other problems but I don't know if they depend on the q4wine version, if it's not the latest.

mg979 commented 6 years ago

I could run them through q4wine (and a different wine version) with this custom command line:

%CONSOLE_BIN% %CONSOLE_ARGS% %ENV_BIN% %ENV_ARGS% /bin/sh -c "%WORK_DIR% %SET_NICE% %WINE_BIN% start %PROGRAM_ARGS%"

this .desktop file Exec fields (example for Excel):

Exec=/usr/bin/q4wine-cli -p "Office"  -d "system"  -i "MS Excel"  "%f"

and these arguments in the icon setup: /ProgIDOpen Excel.Sheet.8

But this only works when opening a file from the file manager, to launch the apps with no file loaded, I had to make other icons(with the EXE filename as argument, since it's not passed by the custom command line). So, it works but it must be configured manually.

brezerk commented 6 years ago

hi @mg979

Can you try some other app like embedded wordpad? Are you able to open documents via it?

This seems to be working for me:

q4wine-cli -p "Default" -d "system" -i "wordpad" ~/minicom.log

However, the issue with spaces confirmed:

q4wine-cli -p "Default" -d "system" -i "wordpad" ~/my\ inicom.log

Not sure if the two issues are related. But this one needs to be fixed :)

brezerk commented 6 years ago

never mind. I had a typo in my command. Spaces are working for me fine too:

./q4wine-cli -p "Default" -d "system" -i "wordpad" ~/my\ minicom.log

and

./q4wine-cli -p "Default" -d "system" -i "wordpad" /home/brezerk/my minicom.log
mg979 commented 6 years ago

Wordpad works, with Office 2003 it doesn't, but it works with wine start /ProgIDOpen.

This works (if I change the icons/command line as described above):

q4wine-cli -p "Office" -d "system" -i "MS Word" "~/my\ minicom.log"

These do not:

q4wine-cli -p "Office" -d "system" -i "MS Word" "~/my minicom.log"
q4wine-cli -p "Office" -d "system" -i "MS Word" ~/my\ minicom.log

Maybe it's also an old Office version (2003)? Anyway I got it working in one way or another. It would be nice if it were possible to adjust the command line also per app, not only per prefix. Thanks.

brezerk commented 6 years ago

ic. well, adjusting command line per app will be possible in 2.x aka q4wine-next as 1.x code base is pretty old and not flexible.

however: did you had any luck with raw wine command like this:

env WINEPREFIX="/home/xxx/.PlayOnLinux/wineprefix/Office" wine <path_to_ms_word_binary.exe> <document>

?

mg979 commented 6 years ago

Yes that works(but it uses the default wine version). It's not a trouble since I can launch it one way or another (either with default wine, or through q4wine with edited command line).

The only issue I have for now is that, since the command line that doesn't execute an EXE, but calls wine start /ProgIDOpen, I can't change the prefix configuration after I modify the command line, I get this message: Istantanea.png

Not really important though. Maybe you could support custom command line per app and wine start /ProgIDOpen in .desktop files(for example, a q4wine-cli argument that automatically replaces %WINE_BIN% %PROGRAM_BIN% %PROGRAM_ARGS% with %WINE_BIN% start /ProgIDOpen %PROGRAM_ARGS%)

brezerk commented 6 years ago

Interesting.

@mg979 would it be possible for you to build q4wine-git with -DDEBUG=ON option set? q4wine-cli \ q4wine-helper will provide a lot of debug info in this case, including the exact commands.

mg979 commented 6 years ago

Can I install a debug-enabled version in another directory, without uninstalling the default one? I cloned q4wine in ~/Apps/q4wine/, then I tried this from ~/Apps/q4wine/build

$ cmake -DCMAKE_INSTALL_PREFIX=/home/gianmaria/Apps/q4wine-debug -DDEBUG=ON ..

but I get this error:

CMake Error at src/CMakeLists.txt:38 (find_package):
  By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any
  of the following names:

    Qt5CoreConfig.cmake
    qt5core-config.cmake

  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
  "Qt5Core_DIR" to a directory containing one of the above files.  If
  "Qt5Core" provides a separate development package or SDK, be sure it has
  been installed.
brezerk commented 6 years ago

hi @mg979 yes, you can have both at the same time. Just set -DCMAKE_INSTALL_PREFIX to different directory (just as you did).

It seems like you are missing the qt5-devel packages.

mg979 commented 6 years ago

Ok I could install it, now the error window is this one: Istantanea-2.png

Should I look for some error logs somewhere else? Also, are there changes in 1.3.6 that I should be aware of(compared to 1.3.3)?

brezerk commented 6 years ago

No. This are fine. Try to bypass the regedit.exe.

It' this should be: wine start regedit.exe C:/temp/7996.reg

ghost commented 6 years ago

I'm hitting the same issue after I added wine start EXCEL.exe to prefix template. /usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" /home/user/Documents/abc.xls doesn't work.

cd /home/user/Documents/ && /usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" abc.xls works. Unfortunately opening file from file manager always executes the former command.

brezerk commented 6 years ago

@FedericoYundt just wonder: will it work with full path specified in Windows notation?

i.e. something like this:

/usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" C:\users\<username>\My Documents\abc.xls
brezerk commented 6 years ago

also, assuming all other applications seems to be working as expected, this is really something to do with the way how MSO is handling the arguments.

There is an article: https://support.microsoft.com/en-us/help/210565/how-to-use-startup-command-line-switches-to-start-word-2010-word-2007

Maybe you can play around with the arguments i.e. something like:

/usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" \f /home/user/Documents/abc.xls

will work

ghost commented 6 years ago

Thanks for the reply. None of the above works. C:\users\<username>\My Documents\abc.xls is treated as wrong unix path.

/usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" \f /home/user/Documents/abc.xls Above should be: /usr/bin/q4wine-cli -p office -d office -i "Microsoft Excel 2010" /t /home/user/Documents/abc.xls but it treats /t (or \f) as a filepath.

wine 'C:\\\\windows\\\\command\\\\start.exe' /Unix %U - this command works when I run wine directly without q4wine.

mobedoor commented 3 years ago

EDIT Found a fix. Go the desktop file and enclose %f in the Exec column with double quotes. I notice this is mentioned above so I probably should should have paid more attention to the thread.

Any workarounds for the problems with spaces in filenames? I'm also having issues with brackets. "(" and ")" in filenames throw a /bin/sh: 1: Syntax error: "(" unexpected