0

I am writing a simple python script to run and close one flatpak application. I am triggering gedit application using flatpak command but having a hard time to figure out how to quit the application from script itself. Since once the application launches, python scripts waits for the application to terminate and then to exit.

Code:

import os
import sys

def main():
    os.system("flatpak run org.gnome.gedit/x86_64/stable")
    sys.exit()

if __name__ == '__main__':
    main() 

In above code I tried sys.exit(), but it doesn't work as it waits for the application to terminate.

1 Answer 1

2

you can try this

import subprocess
p = subprocess.Popen("flatpak run org.gnome.gedit/x86_64/stable")
p.terminate()

Here you can find more information about this

Sign up to request clarification or add additional context in comments.

2 Comments

throwing error: FileNotFoundError: [Errno 2] No such file or directory: 'flatpak run org.gnome.gedit/x86_64/stable'. Inside " " is the command that needs to be run on terminal in order to run flatpak application.
instead of flatpak assign absloute path for example /bin/flatpak or every path it has.If you don't know where it is you can find it with whereis flatpak

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.