I know of a couple of threads devoted to installing Chrome on CL, but they are all pretty old, hence quite possibly obsolete. Anyway, I’ve looked into running Brave or some other browser, but I am much too deeply invested in Chrome at this point, and breaking away from it would call for major sacrifice. To make a long story short, I’ve identified two installation “methods” (aside from the Flatpak, that is):
curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
rpm2cpio google-chrome*.rpm | ( cd /; cpio -idv)
f=/etc/environment; s='export FONTCONFIG_PATH=/usr/share/defaults/fonts'; touch $f; if ! grep -q "$s" $f; then echo $s >> $f; fi
What worked for me so far was a combination of the two:
curl -LO https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
rpm2cpio google-chrome*.rpm | ( cd /; cpio -idv)
sed -i 's\/usr/bin/google-chrome-stable\env FONTCONFIG_PATH=/usr/share/defaults/fonts /usr/bin/google-chrome-stable\g' /usr/share/applications/google-chrome.desktop
The only thing that I cannot get in this manner is the Chrome icon. The .desktop file points to a google-chrome, which doesn’t exist, and changing that to google-chrome-stable or /opt/google/chrome/google-chrome still gives you nothing.
The “google-chrome” icon is installed via postinstall RPM scriptlet. On Clear Linux, one typically extracts the RPM contents and moves files into place. I check also the postinstall section, included in the RPM.
rpm -qp --scripts google-chrome-stable-117.0.5938.149-1.x86_64.rpm | more
Assuming you have Google Chrome installed, the following snippet installs the google-chrome icon in various sizes. Be sure to revert the icon change in your desktop file back to google-chrome.
# Add icons to the system icons; installs to /usr/share/icons/hicolor/.
for icon in \
product_logo_32.png product_logo_48.png product_logo_256.png product_logo_128.png \
product_logo_16.png product_logo_64.png product_logo_24.png
do
size=$(echo "$icon" | sed 's/[^0-9]//g')
sudo xdg-icon-resource install --size "$size" /opt/google/chrome/${icon} "google-chrome"
done
Some time ago, I stopped sharing scripts due to time constraints maintaining them. This one installs Google Chrome the first time, otherwise updates on subsequent use. I run it periodically. At this moment, Google Chrome is current on my system.
$ ~/bin/upd-chrome-stable
Google Chrome stable 117.0.5938.149 (current)
upd-chrome-stable - Installer/updater combo
#!/bin/bash
#-------------------------------------------------------------------------------
# Install and update script for Google Chrome stable.
# https://pkgs.org/search/?q=google%20chrome
#-------------------------------------------------------------------------------
# shellcheck disable=SC2001,SC2143,SC2164
URL1='https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable'
URL2='https://dl.google.com/linux/chrome/rpm/stable/x86_64/google-chrome-stable'
NEW_VER=$(curl -s "$URL1" | awk -F'>' '/Version:/ { print $NF; exit }')
BROWSER_EXE="/opt/google/chrome/google-chrome"
if [[ -x "$BROWSER_EXE" ]]; then
CUR_VER=$($BROWSER_EXE --version 2>/dev/null | awk '{ print $NF }')
else
CUR_VER="not-installed"
fi
if [[ "$NEW_VER" =~ ^$CUR_VER ]]; then
echo "Google Chrome stable $CUR_VER (current)"
exit
elif [[ "$USER" == "root" ]]; then
echo "Please run the script as a normal user, exiting..."
exit 1
fi
# Test sudo, exit if wrong password or terminated.
sudo true >/dev/null || exit 2
# Install dependencies.
if [[ ! -x "/usr/bin/curl" || ! -x "/usr/bin/rpm2cpio" ]]; then
echo "Installing dependencies."
sudo swupd bundle-add curl package-utils --quiet
fi
#-------------------------------------------------------------------------------
if [[ ! -x "$BROWSER_EXE" ]]; then
echo "Installing Google Chrome stable ${NEW_VER%%-*}"
else
echo "Updating Google Chrome stable ${NEW_VER%%-*}"
# remove older installation via rpm
sudo rpm -e google-chrome-stable 2>/dev/null
fi
FILE="google-chrome-stable-${NEW_VER}.x86_64.rpm"
cd ~/Downloads
if [[ ! -f "$FILE" ]]; then
curl -LO "${URL2}-${NEW_VER}.x86_64.rpm"
if [[ ! -f "$FILE" || -n $(grep "Error 404 (Not Found)" "$FILE") ]]; then
rm -f "$FILE"
echo "ERROR: $FILE (No such file at download URL)"
echo "https://dl.google.com/linux/chrome/rpm/stable/x86_64/"
exit 1
fi
fi
mkdir -p /tmp/update.$$ && pushd /tmp/update.$$ >/dev/null
rpm2cpio ~/Downloads/"$FILE" | cpio -idm 2>/dev/null
sudo mkdir -p /opt/google
sudo rm -rf /opt/google/chrome
sudo cp -a usr/share/* /usr/share/.
sudo mv opt/google/chrome /opt/google/.
sudo sed -i 's!/usr/bin/google-chrome-stable!/opt/google/chrome/google-chrome!g' \
/usr/share/applications/google-chrome.desktop
sudo sed -i 's!^\(Exec=\)\(.*\)!\1env FONTCONFIG_PATH=/usr/share/defaults/fonts \2!g' \
/usr/share/applications/google-chrome.desktop
popd >/dev/null
rm -fr /tmp/update.$$
# Add icons to the system icons; installs to /usr/share/icons/hicolor/.
for icon in \
product_logo_32.png product_logo_48.png product_logo_256.png product_logo_128.png \
product_logo_16.png product_logo_64.png product_logo_24.png
do
size=$(echo "$icon" | sed 's/[^0-9]//g')
sudo xdg-icon-resource install --size "$size" /opt/google/chrome/${icon} "google-chrome"
done
sync
echo "OK"
The script is awesome! Many thanks! I take it it doesn’t handle the fonts issue, right? Do you happen to have a solution that is more elegant than patching all the chrome-related .desktop files with this below?
sed -i 's\/opt/google/chrome/google-chrome\env FONTCONFIG_PATH=/usr/share/defaults/fonts /opt/google/chrome/google-chrome\g' $file
One can choose to set FONTCONFIG_PATH system-wide or inside the desktop file. I added an additional sed statement above, to upd-chrome-stable and upd-brave-stable. Here, for Google Chrome.
sudo sed -i 's!^\(Exec=\)\(.*\)!\1env FONTCONFIG_PATH=/usr/share/defaults/fonts \2!g' \
/usr/share/applications/google-chrome.desktop
Likewise, for Brave Browser.
sudo sed -i 's!^\(Exec=\)\(.*\)!\1env FONTCONFIG_PATH=/usr/share/defaults/fonts \2!g' \
/usr/share/applications/brave-browser.desktop
At the time, I made also a combo installer/updater script for Vivaldi Browser. It has been a while since I ran the updater script. This is what it looks like.
$ ./upd-vivaldi-stable
Password:
Updating Vivaldi stable 6.2.3105.58
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 96.3M 100 96.3M 0 0 78.8M 0 0:00:01 0:00:01 --:--:-- 79.0M
OK
upd-vivaldi-stable - Installer/updater combo
#!/bin/bash
#-------------------------------------------------------------------------------
# Install and update script for Vivaldi stable.
# https://vivaldi.com/download/
#-------------------------------------------------------------------------------
# shellcheck disable=SC2001,SC2143,SC2164
URL=$(
curl -s 'https://vivaldi.com/download/' |\
awk 'BEGIN { RS = "href=" } /vivaldi-stable-.*\.x86_64\.rpm/ { print $1; exit }' |\
cut -d'"' -f2
)
FILE="${URL##*/}"
if [[ -z "$FILE" ]]; then
echo "ERROR: vivaldi-stable-*.rpm (No such file at download URL)"
echo "https://vivaldi.com/download/"
exit 1
fi
NEW_VER=$(echo "$FILE" | cut -d- -f3)
BROWSER_EXE="/opt/vivaldi/vivaldi"
if [[ -x "$BROWSER_EXE" ]]; then
CUR_VER=$($BROWSER_EXE --version 2>/dev/null | awk '{ print $2 }')
else
CUR_VER="not-installed"
fi
if [[ "$NEW_VER" == "$CUR_VER" ]]; then
echo "Vivaldi stable $CUR_VER (current)"
exit 0
elif [[ "$USER" == "root" ]]; then
echo "Please run the script as a normal user, exiting..."
exit 1
fi
# Test sudo, exit if wrong password or terminated.
sudo true >/dev/null || exit 2
# Install dependencies.
if [[ ! -x "/usr/bin/curl" || ! -x "/usr/bin/rpm2cpio" ]]; then
echo "Installing dependencies."
sudo swupd bundle-add curl package-utils --quiet
fi
#-------------------------------------------------------------------------------
if [[ ! -x "$BROWSER_EXE" ]]; then
echo "Installing Vivaldi stable $NEW_VER"
else
echo "Updating Vivaldi stable $NEW_VER"
# remove older installation via rpm
sudo rpm -e vivaldi-stable 2>/dev/null
fi
cd ~/Downloads
if [[ ! -f "$FILE" ]]; then
curl -LO "$URL"
if [[ ! -f "$FILE" || -n $(grep "404 Not Found" "$FILE") ]]; then
rm -f "$FILE"
echo "ERROR: $FILE (No such file at download URL)"
echo "https://vivaldi.com/download/"
exit 1
fi
fi
mkdir -p /tmp/update.$$ && pushd /tmp/update.$$ >/dev/null
rpm2cpio ~/Downloads/"$FILE" | cpio -idm 2>/dev/null
sudo mkdir -p /opt
sudo rm -rf /opt/vivaldi
sudo cp -a usr/share/* /usr/share/.
sudo mv opt/vivaldi /opt/.
sudo sed -i 's!/usr/bin/vivaldi-stable!/opt/vivaldi/vivaldi!g' \
/usr/share/applications/vivaldi-stable.desktop
sudo sed -i 's!^\(Exec=\)\(.*\)!\1env FONTCONFIG_PATH=/usr/share/defaults/fonts \2!g' \
/usr/share/applications/vivaldi-stable.desktop
popd >/dev/null
rm -fr /tmp/update.$$
# Add icons to the system icons; installs to /usr/share/icons/hicolor/.
for icon in \
product_logo_16.png product_logo_256.png product_logo_24.png product_logo_64.png \
product_logo_32.png product_logo_128.png product_logo_22.png product_logo_48.png
do
size=$(echo "$icon" | sed 's/[^0-9]//g')
sudo xdg-icon-resource install --size "$size" /opt/vivaldi/${icon} --novendor "vivaldi"
done
sync
echo "OK"
Many thanks! Interestingly, this does not fix the fonts on Chrome-based PWAs, which means that all of those will have to be handled separately:
#!/bin/bash
# Do NOT run as root!
if [ $(id -u) == 0 ]
then
echo "This script should NOT be run as root! Exiting ..."
exit
fi
echo "Fixing PWA fonts ... "
for file in /home/$USER/.local/share/applications/chrome-*.desktop; do
if [[ $(grep -c "env FONTCONFIG_PATH=/usr/share/defaults/fonts" $file) -eq 0 ]]
then
sed -i 's\/opt/google/chrome/google-chrome\env FONTCONFIG_PATH=/usr/share/defaults/fonts /opt/google/chrome/google-chrome\g' $file
fi
done
echo "Done!"
I did run the flatpak for a while, and it wasn’t all that bad, though I recall running into some issues with PWA icons, and it also seemed to have some lag when using many windows open etc. (which I now notice happening with the non-flatpak version as well). Anyway, at the time I sorta figured that running the native Linux non-Flatpak version might suit me better and all, though I do not exclude going back to the Flatpak package again in the future.