dannagle / PacketSender

Network utility for sending / receiving TCP, UDP, SSL, HTTP
https://packetsender.com
GNU General Public License v2.0
2.38k stars 371 forks source link

[BUG] Cannot open GUI in Linux #245

Closed VuiMuich closed 1 year ago

VuiMuich commented 3 years ago

What OS?

Description of issue

When I try to launch PacketSender I get the following error-message:

Cannot open display. Try --help to access console app.

I am aware of issue #178 and also tried to run it as root and tried all three of the following: installed via AUR package, cloned the git repo and compiled manually and downloaded the AppImage (btw: why is the AppImage version 7.2.4, where all others are 7.2.3?), with no success. Are there any runtime dependencies I am possibly missing? If so it would be helpful to get an according error-message. I read you comment in the fix for #178 that there is an underlying issue with qt5, do you have any further info on this specific issue?

Also I'd like to suggest even though with the fix for #178 you are exiting gracefully you should return the exit code 1 as it actually still is an exiting with an error, right?

Update: Just looked up on what exit code xrandr is exiting and I get this (note: I use fish as interactive shell):

>>> xrandr
xrandr: output eDP1 cannot use rotation "normal" reflection "none"
>>> echo $status
1

So possibly I have an odd xrandr configuration so it is trying to do something to a second display which currently isn't connected.

dannagle commented 3 years ago

Try removing the check and see if works anyway for you: https://github.com/dannagle/PacketSender/blob/master/src/main.cpp#L734

Remove these lines.

        if (!isGuiApp()) {
            printf("\nCannot open display. Try --help to access console app.\n");
            return -1;
        }
VuiMuich commented 3 years ago

Yes, without the check it launches fine.

Maybe the check for xrandr could test only if the exit-code is bigger then 126? Will have a look at this later..

dannagle commented 3 years ago

Not sure what the complete answer is. At least on my end, I could add an easy way to bypass the check.

VuiMuich commented 3 years ago

Ooops, later apearently became days later, sorry.

Now I tried this, and it works so far:

diff --git a/src/main.cpp b/src/main.cpp
index 127c1dd..c66a7b8 100755
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -32,7 +32,7 @@ bool isGuiApp()
     int exitcode = process->exitCode();
     QDEBUGVAR(exitcode);
     free(process);
-    if (exitcode > 0) {
+    if (exitcode > 125) {
         // This means xrandr exists, but it couldn't connect.
         return false;
     }

I have to admit though I haven't tested what happens if xrandr isn't installed as I am not sure if it is safe to uninstall it on a running X11 session.

dannagle commented 3 years ago

I'll need to run some tests on my end, but I think I may ultimately add a bypass method. Leaving this bug open until I have time to do that.

eZioPan commented 1 year ago

in Fedora 37, if there is no xrandr installed, exitcode is 255.

dannagle commented 1 year ago

Thanks for bumping this to the top. I think a bypass (with instructions in the output) is the best workaround for now. I'll try to get that into the next release.

dannagle commented 1 year ago

This fix is now in the development branch. The option to bypass is --gui

dannagle commented 1 year ago

This fix will be in the next release.