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

Fix opening pdf with okular in linux (#5253) #5855

Merged
merged 3 commits into from
Jan 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#

### Fixed

- We fixed and issue where pdf files will not open under some KDE linux distributions when using okular. [#5253](https://github.com/JabRef/jabref/issues/5253)
- We fixed an issue where the Medline fetcher was only working when JabRef was running from source. [#5645](https://github.com/JabRef/jabref/issues/5645)
- We fixed some visual issues in the dark theme. [#5764](https://github.com/JabRef/jabref/pull/5764) [#5753](https://github.com/JabRef/jabref/issues/5753)
- We fixed an issue where non-default previews didn't handle unicode characters. [#5779](https://github.com/JabRef/jabref/issues/5779)
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/jabref/gui/desktop/os/Linux.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ public void openFile(String filePath, String fileType) throws IOException {
viewer = "xdg-open";
}
String[] cmdArray = { viewer, filePath };
Runtime.getRuntime().exec(cmdArray);
Process p;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In java you don't need to declare and assign variables separately. So the following works (and is slightly preferred):

Suggested change
Process p;
Process p = Runtime.getRuntime().exec(cmdArray);

p = Runtime.getRuntime().exec(cmdArray);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
line = in.readLine();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @calixtus said, it would be nice if you could add a logging statement here:
Add private static final Logger LOGGER = LoggerFactory.getLogger(Linux.class); at the top of the class and then here LOGGER.debug("Received output: " + line).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I have done the modifications. I had to add also the lines
import org.slf4j.Logger; import org.slf4j.LoggerFactory;
But I am not sure how I shall proceed now? How do I modify the fix I sent? A new pull request?
Thank your for your help

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just commit the changes on your branch and then push them to your fork.
the PR will be updated automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. That is done. Thank you for your help!

}

@Override
Expand All @@ -46,7 +50,11 @@ public void openFileWithApplication(String filePath, String application) throws
String[] cmdArray = new String[openWith.length + 1];
System.arraycopy(openWith, 0, cmdArray, 0, openWith.length);
cmdArray[cmdArray.length - 1] = filePath;
Runtime.getRuntime().exec(cmdArray);
Process p;
p = Runtime.getRuntime().exec(cmdArray);
BufferedReader in = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
line = in.readLine();
}

@Override
Expand Down