I recently moved to a new Linux based daily driver on my personal laptop, which is also my development environment (I’ll post a full review of Fedora 25 later, in brief: I love it) and I wanted to share a quick tip on working with Chrome Apps in Linux.

I’m particularly a huge fan of keyboard shortcuts, so I wanted to map keyboard shortcuts for my most commonly used Chrome Apps to launch them even quicker.

In Fedora 25, which features Gnome 3.22 out of the box, you can hit the super key and start typing the name of whatever app you need to use. Usually I don’t need to type more than one or two characters to get what I need and Chrome apps are actually included in the search results, which makes launching them quite easy.

Still, there’s nothing like the gold standard of a global dedicated keyboard shortcut combination to really optimize my workflow. But enough with the intro, how to we do it?

In Gnome Settings > Keyboard, you can view and edit existing keyboard shortcut mappings easily enough. In order to add a new command you need to scroll all the way to the bottom and hit the plus sign “+”. (I know, I too whould prefer it to be at the top.)

Gnome Settings > Keyboard shortcuts mapping list

Gnome Settings > Keyboard shortcuts mapping list

A menu will appear with the “Add Custom Shortcut” form. Setting the Name and the shortcut key combination is easy, but what about the actual command? How do we know what command to use to launch a Chrome app? This is a bit trickier.

Gnome > Add new Keyboard Shortcut

Gnome > Add new Keyboard Shortcut

When you configure a Chrome app to create a Desktop Shortcut it will create a file in the directory: /home/<username>/.local/share/applications

(At least on redhat-based distros. You may need to poke around in your distro to find out where chrome saves these on your machine.)

Each Chrome app file will have a name something like: `chrome-aohghmighlieiainnegkcijnfilokake-Default.desktop“which uses a unique guid in the file name that maps to the Chrome app id.

List of Chrome App Desktop Shortcut files

List of Chrome App Desktop Shortcut files

Each app file has a list of details for it, like the name, version, icon, and most importantly the Exec command

The user-friendly name of the app is in the text file, but if we have more than a few installed we don’t want to have to search through each one to find what we’re looking for. Enter grep to the rescue!

Let’s say I want to find the exec command for the Google Keep Chrome App. Here’s the command I used for this:

grep “Exec” $(grep “Keep” chrome-* | awk -F’:’ ‘{print $1}’)

Let’s unpack this in detail.

We are grepping for the word “Exec” in a file, but the name of the file is found by the command substitution phrase inside of the  $( … ) clause.

Inside of this embedded command, we are grepping for the word “Keep” in all of the chrome desktop shortcut files, piping the result to awk where we can split the result delimited by the colon (:) which will result in just the filename we need.

Back to the first grep command, once we have the filename and grep for the term “Exec”, the results should look like this:

Exec=/opt/google/chrome/google-chrome --profile-directory=Default --app-id=hmjkmjkepdijhoojdojkdfohbdgmmhki

finding the exec command of a Chrome App

finding the exec command of a Chrome App

We can copy the whole command after the equals sign (=) and use this in the “Command” field of our Keyboard shortcut mapping definition.

Custom keyboard shortcut for Google Keep

Custom keyboard shortcut for Google Keep

You’ll notice the root of the command is simply the exec to launch chrome but the key thing to note here is the command flag --app-id. 

When supplied with the correct app-id the Chrome exec command opens the desired chrome app rather than the main browser window.

If you use multiple profiles (i.e. personal and work), you can even map separate commands to use specific google profiles using the --profile-directory flag.

For the brave of heart, here’s a link I found to Peter Beverloo’s list of Chrome command line switches.

Stay tuned for my full 30-day review of Fedora 25!

-Spaceman