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 ${XDG_CONFIG_HOME:-$HOME/.config}/google-chrome/${Chrome_Profile}/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 <$app/manifest.json)"
}
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="${app%%/*}" $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.
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.
.desktop
file in~/.local/share/applications
(drag it over an opened gedit window) you can see the correct command in theExec=
line.--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 ?