The first simple answer to the Linux equivalent killall(ProgramName)
The program is to be a toggle program. I can launch Firefox/program. def tolaunch(program): os.system("firefox")
When launched I wish to save the name of program launched, in array(simple to do), then launch the program(Firefox)/program.
Here the idea off the toggle come’s in, when Launched and I have finished my browsing, I wish to call the same program(mine), check the array for said program and exit Firefox/program, by running a simple command like killall(“Firefox”) but in Python code. I don’t want to write a long winded command/script, that first has to workout the ‘pid’.
I seem very close to the answer but cant find it.
Edit: people asked for code example | here is my code
# Toggler for macro key -|- many keys = one toggler program
import os
import sys
def startp(program):
# hard-coded
os.system("firefox")
def exitp(program):
# os.close(program)
sys.exit(program)
# Begin
# hard-coded : program start
startp("Firefox")
# loop while program/s active
# exitp("Firefox")
# exit(program) or program end
I tried to include some explanations in way off comments