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

Support KDE Konsole in run_in_new_terminal function #2023

Merged
merged 2 commits into from
Jan 25, 2022

Conversation

TomasGlgg
Copy link

If KDE Konsole is detected (by the presence of the $KONSOLE_VERSION environment variable), a terminal will be split.

@Arusekk
Copy link
Member

Arusekk commented Jan 25, 2022

I am honestly a big fan of this as I use Konsole all the time; could you please rewrite .stdout.read() to .communicate()[0] so we can merge it

@TomasGlgg
Copy link
Author

@Arusekk done

@Arusekk
Copy link
Member

Arusekk commented Jan 25, 2022

This might not work with py2 potentially, but merging, since it is a huge feature for me.

@Arusekk Arusekk merged commit 04f401c into Gallopsled:dev Jan 25, 2022
@TomasGlgg
Copy link
Author

TomasGlgg commented Jan 26, 2022

@Arusekk I found that I was incorrectly defining the MainWindow number, it is not equal to the Window number (from the environment variables), so the split may occur in the wrong terminal. The only solution I have found is checking each MainWindow for activity (org.qtproject.Qt.QWidget.isActiveWindow). If you agree to such a solution, I can try to implement it.

@Arusekk
Copy link
Member

Arusekk commented Jan 27, 2022

I see the problem; the MainWindow instances are numbered first-gap, while Window are numbered unique increasing. This should not result in splitting the wrong terminal, though. The only case that this can go wrong is if you close one of many in-process konsole windows, and then open a new konsole window in the same process. And the new window won't be able to split, but the incorrect number will be higher than any window's number, resulting in qdbus saying No such object path '/konsole/MainWindow_3' (because the number will be at least 3 in that case; if it is 1 or 2 we can be sure the window is right 😉) and exitting with exit code 2.

@TomasGlgg
Copy link
Author

In the process of using pwndbg together with pwntools, I had an incorrect terminal split. I had /Window/1 in the window /konsole/MainWindow_2, and /Window/2 in the window /konsole/MainWindow_1. I do not know how it happened. I will continue to look for a solution to the problem.

@TomasGlgg
Copy link
Author

TomasGlgg commented Jan 27, 2022

@Arusekk I found a solution. We can check the Window ID of each MainWindow (org.kde.KMainWindow.winId) with Window ID from environment variables ($WINDOWID). I wrote a demo. This solution to the problem should be guaranteed to work. What do you think about it?

gogo2464 pushed a commit to gogo2464/pwntools that referenced this pull request Sep 10, 2023
* Support KDE Konsole in run_in_new_terminal function

* Rewrite '.stdout.read()' to '.communicate()[0]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants