Skip to content

Close google chrome open in app mode via command line

In my python script I am opening chrome in app mode by this command:

google-chrome –app=

Now I want to be able to close only this running chrome application (I mean if there is another chrome windows with diffrent tabs I don’t want to close that, only this that i run). Is this possible and how?

I am using linux.

EDIT: As far i manage to do something like this:

import subprocess

proc = subprocess.Popen(['google-chrome',  
           '--user-data-dir=/home/chrome-user', ''])

# do something


And when I call this python script from command line everything is ok. My problem starts when I am running this as a linux service (under /etc/init). I logged and everything is ok except that google chrome seems to not be able to create window or something? I mean there is no error but google chrome window doesn’t shows at all.

EDIT 2: Definitely it is a problem with startup. When i run this on startup:

mate-terminal -e “python3 /path/to/script/”

Everything works fine except that terminal windows is shown. So this somehow solves my problem but if anyone will have got any sugestion what can i do i would highly apreciate it.



Ok so after a long time I come with answer. In linux mint you need to add this to startup programs:

mate-terminal -e “python3 /path/to/script/”

and if you want to run script as root user, this is solution for it (it’s very ugly, but works):

mate-terminal -e “bash -c ‘echo pass | sudo -S python3 /path/to/script/;$SHELL'”

User contributions licensed under: CC BY-SA
10 People found this is helpful