Launch chrome in linux

Launch a Chrome app from command line

I can’t find how to launch a chrome app from a bash ? I’m trying to achieve this with Postman. From google-chrome -h , I tried (unfortunately) those ones :

$ google-chrome --app="Postman" $ google-chrome --extension="postman" 

The result is that a new blank window is opened. My first guess is the app is stored on my machine and I need to open a specific file (the app index) to launch it. Is it possible to achieve this ? And if it’s possible, how to do ?

Probably if you open the corresponding .desktop file in ~/.local/share/applications (drag it over an opened gedit window) you can see the correct command in the Exec= line.

Perfect, thank you @JacobVlijm . The command use the —app-id=[id] I assume this id is permanent so I will create an alias, but do you know a way to launch it by its name ?

@daisy because that’s not the same question. This is about how to launch a chrome application, not chrome itself.

5 Answers 5

Answered thanks to @JacobVlijm .

To run a chrome app from command-line, use the following :

Assuming the path of google-chrome is /opt/google/chrome/google-chrome .

To retrieve the app id, search the first occurrence of the application name in /home/$USER/.local/share/applications .

You can even get the app id from the Chrome Store URL for the particular application. Of course this works only if you have access to the internet 🙂

If you have multiple Chrome profiles, you need to add the profile directory to the command line, too: google-chrome —profile-directory=Default —app-id=[app-id]

After all the stuff I have executed following command, worked for me and open postman

google-chrome --app-id=fhbjgbiflinjbdggehcddcbncdddomop 

Assume default configurations

Pattern: google-chrome —app-id=

  • open chrome://extensions/ in your chrome browser
  • click «Details» button of Postman extension
  • view address on address bar, where url in format of chrome://extensions/?id= Copy extensionID from url and use it in command

In same way you can use any extension of google chrome

Unfortunately, no there is no way provided to call an app at the command line by it’s name. Providing this feature would mean unreliable extra parsing for installed apps and some would consider it a security flaw. You can do the parsing yourself, however, with a script that searches and extracts the name of each extension/app until it finds the name you search for:

/usr/local/bin/chrome-app-by-name: #!/bin/zsh emulate -R zsh -o extendedglob -o nullglob setopt rematchpcre ;# recommended, I'm so used to PCRE, I sometimes forget what doesn't work in Regex Chrome_Profile=Default ;# or "Profile 1" . cd $/google-chrome/$/Extensions foreach app in */* # We have just called the path to each version of each extension/app. # Next we enclose in braces - slightly unnecessary - to ensure that # whatever version of Zsh, "manifest.json" is completely read and # closed before we use the variable. < App_Manifest="$(cat if [[ $App_Manifest =~ '^\s*"name"\s*:\s*"([a-zA-Z 0-9_.-]+)"' ]] then app_name="$match[1]" ;# capture the sub-expression match for "name" if [[ $app_name == $1 ]] then # For my system this is actually exec google-chrome-stable . exec google-chrome --app-id="$" $argv[2,-1] fi fi end echo "App name not found. Please use Exact, case-sensitive spelling." 

Some apps set their names deeper in the scripts - I don't know why! You may have to re-write or add to a script like this one to search ".desktop" files in ~/.local/share/applications for their '^NAME=. ' equivalent to the above, and then get the execution command there.

Читайте также:  Lenovo linux mint wifi

I have not tested this script - I just wrote it on the fly to answer your question. I hope that as an example it works for you, but if the idea is not quite right, we could tweak it a bit. Zsh is simple, strait-forward syntax compared to some other sh-compatible shells. I have tried to leave out any features that require new versions or modules except for PCRE. PCRE is so much easier to use for the exact pattern matching I often need that I neglect regular Regex most of the time. A longer Perl script could work, also most of this syntax will run unmodified in /bin/bash . foreach . end , $match[1] style arrays, setopt rematchpcre , the exact systax of Bash Regex, and emulate are the main exceptions.

Источник

How to open Google Chrome from the Terminal in Ubuntu?

Although most versions of Ubuntu come with Mozilla Firefox installed as the default browser, having Google Chrome installed has its fair advantages. Google Chrome has been the superior choice when it comes to browsing on a desktop, having support for most plugins and a variety of add-ons, the likes of which cannot be found on any other browser.

This makes Google Chrome an ideal browser and a must-have no matter which operating system you are running. This guide will help you install Google Chrome on Ubuntu and instructions to use it with the help of the Terminal.

Although this guide is meant for versions of Ubuntu, it should work the same way for any Linux Distribution.

Installing Google Chrome on Ubuntu

There are two methods to install Google Chrome on Ubuntu. One is using the Graphical User Interface (GUI) and the other by using the Linux Terminal. We will first explain the graphical method and briefly examine how to do it from the Command Line Interface (CLI), i.e., the Terminal.

Читайте также:  Приложения для тв смарт линукс

Open Mozilla Firefox and type “Google Chrome” in the search bar or click here.

You should see a chrome window with a “Download Chrome” button, as shown in the image below. Click on the button to download the browser.

You will be given the option to download .deb or .rpm, which has to do with what Linux Distro you are using. Since this article is concerned with Ubuntu, click on the .deb package and press “Accept and Install.”

A download window should appear. Click on Save File and press OK.

Having done that, double-clicking the file, you downloaded should do. A new window will appear that will prompt you to install Google Chrome on your device. Click on “Install”.

Ubuntu will ask you to authorize the installation by entering your account password.

Alternatively, you can also install Chrome through the Terminal. To do this, we must first use a wget command.

This will download the offline installer for the browser.

Next, we install the package with the following dpkg command.

If you get any errors about missing dependencies, run the following command to forcibly install them.

Having successfully installed the Debian package, you are now ready to use Google Chrome.

Opening Google Chrome using the Terminal

Google Chrome, like any other program, can be accessed through its graphical icon. However, those that are fond of using the command-line Terminal to do things are also in luck. We will now show you a way to operate the Chrome browser through the Terminal.

Working on the Terminal allows you to access the browser using a single command. To open Google Chrome with the help of the command line, follow the steps given below:

Go to Desktop > Applications.

Type Terminal in the search bar and click on the first result.

Or you can skip the lengthy process and open a new Terminal session by pressing Ctrl + Alt + T on your keyboard.

Читайте также:  Zabbix linux мониторинг свободного места

To open Google Chrome, type the following in the Terminal:

This will load up Google Chrome with the default homepage.

Google Chrome does not require you to specify any sort of directories as it is mounted in the binary path.

Let’s look at some more ways to use the Google Chrome browser through the Terminal. Let’s say, for instance, that you wish to visit a specific website. You can do this by entering the URL of the website of your choice, as shown in the command below:

Similar to other Terminal commands, you can enter flags and command parameters with the Google Chrome run command to achieve specific tasks. The general syntax of performing this is given below.

Below is a list of flag options that you can use to achieve daily life tasks through the Terminal.

--incognito Opens the browser in incognito mode
--new-window Opens the path or URL specified in a new window
--version Displays the Version Information
--app=URL Used to run URL in app mode, meaning without toolbars.

If you wish to explore your options even further, run the help command given below:

Additional comments

Keep in mind that to run Google Chrome on your Linux system, the computer architecture must be 64-bit.

Once you install Google Chrome the way we showed you in this guide, you also add Google’s repository, which is responsible for keeping the program up-to-date. So, you do not need to worry about updating the browser yourself.

You can find the path where Google Chrome is located by typing the following command:

You should see the path specified as shown in the image below:

You can also close the browser with the help of the Terminal by typing the following command:

Conclusion

With all the steps followed correctly, you are now ready to use Google Chrome on your laptop or desktop computer. Enjoy one of the fastest and most versatile browsers available to you in the present day and age.

We hope this guide helped you understand how to access Google Chrome with the help of Terminal commands. Apart from that, we also included additional information on how to maneuver through the options and URL shortcuts that come with them.

About the author

Zeeman Memon

Hi there! I'm a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.

Источник

Оцените статью
Adblock
detector