3
1

More than 3 years have passed since last update.

Linux の Google Chrome / Chromium を快適にする

Last updated at Posted at 2021-03-08

0. ねらい

  • いつでもダークモードを有効にする.
  • Linux でもHWデコードをさせる.
  • (2021/3/19 new!) 自動で設定を書き換える

1. 環境

OS: Arch Linux
CPU: Intel Core i5 10210u
GPU: Intel UHD Graphics
Google Chrome 89.0.4389.82
Chromium 89.0.4389.82 ※Google のサーバとの同期機能がなくなった
で実施した.

2. Google Chrome の場合

2.1. Google Chrome の導入

Google Chrome の導入前に起動オプションの追記を行う hooks ファイルを作成する.
(2021/3/19 追記)
山田ハヤオ氏の記事を参考にしてPacman hooks を作成した.
https://qiita.com/Hayao0819/items/3f563d357d2e41606ea9

Pacman の hooks は /usr/share/libalpm/hooks 下に作成する.
今回は Google Chrome の hooks なので名前は google-chrome.hook にする.

/usr/share/libalpm/hooks/google-chrome.hook
[Trigger]
Operation = Install
Operation = Upgrade
Type = Path
Target = opt/google/chrome/google-chrome

[Action]
Description = Add startup option
When = PostTransaction
Exec = /usr/bin/sed -i -re 's/exec -a "\$0" "\$HERE\/chrome" "\$\@"/exec -a "\$0" "\$HERE\/chrome" "\$\@" --force-dark-mode --enable-features=WebUIDarkMode --use-gl=desktop/g' /opt/google/chrome/google-chrome

※注意: Target トランザクションの頭にルートを示す '/' は含めず, /opt/google/chrome/google-chrome といった形で指定すること.

the installation root should not be included in the path.
https://man.archlinux.org/man/alpm-hooks.5 より

続いて Google Chrome のパッケージを導入する.

yay -Syu google-chrome

# yay をインストールしていない場合
sudo pacman -S base-devel git
cd /tmp/ && git clone https://aur.archlinux.org/yay-bin && cd yay-bin && makepkg -si && rm -rf /tmp/yay-bin
# をして yay をインストールしてから google-chrome のインストールを行う.

2.2. 起動オプションの追記 ※上で hooks を作成した場合は不要

過去の内容

/opt/google/chrome/google-chrome を書き換えて起動オプションを追記する.
/opt/google/chrome/google-chrome の最終行にある

exec -a "$0" "$HERE/chrome" "$@"

の最後に
--force-dark-mode --enable-features=WebUIDarkMode --use-gl=desktop
を追記して,

exec -a "$0" "$HERE/chrome" "$@" --force-dark-mode --enable-features=WebUIDarkMode --use-gl=desktop

とする.

オプションの意味

  • --force-dark-mode:ダークモードを有効にする.
  • --enable-features=WebUIDarkMode:Google Chrome の設定画面などでもダークモードを有効にする.
  • use-gl=desktop:レンダリング API を OpenGL にする.

2.3. Google Chrome の試験運用機能を有効にする

Google Chrome を起動し,アドレスバーに chrome://flags と入力する.すると,以下のような画面が現れる.
image.png
ここで設定を変更できる.

変更する設定

GPU が対応していればこれで動画再生支援が有効になるはずです.

3. Chromium の場合

3.1. Chromium の導入

sudo pacman -Syu chromium

3.2. 起動オプションの追記

~/.local/share/applications/chromium.desktop ← Google Chrome と方法が違う!
を書き換えて起動オプションを追記する.
~/.local/share/applications/chromium.desktop 内にある 全ての

Exec=・・・

行の末尾に
--force-dark-mode --enable-features=WebUIDarkMode --use-gl=desktop
を追記する.

以下 Google Chrome の場合と同じなので 2.3 を参照すること.

3
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1