I am attempting to open a terminal instance using subprocess, but I can't find how to add the & parameter for the bash command
In bash, the following command works as required
konsole --workdir /home/jeff/projects &
but when I run the following command the system opens the new Konsole window, but the window that I use to run the command is still busy - the process is not released
konsole --workdir /home/jeff/projects
In my python program I have the following code
import subprocess
subprocess.run(['konsole',
'--workdir',
'',
'/home/jeff/projects',
])
print('finished')
When I run the code, the program hangs and the never reached the print('finished') command
How do I get the & into python subprocess command?
If I run the analogous command for Gnome terminal I do not need the & on the command line
gnome-terminal --working-directory=/home/jeff/projects
and the python code works and releases the calling terminal
subprocess.run(['gnome-terminal',
'--working-directory=/home/jeff/projects',
])
print('finished')
You can achieve what you want by using
Popen
: