Linux Install Line by Bottles

Introduction

本篇文章紀錄一下在 Kubuntu 下安裝 Line 的過程。

Installation

安裝 Bottles 的方法可以參考:#安裝Flatpak和Bottles - 如何在Linux安裝電腦版Line,使用Bottles管理Wine容器,整體來說只需要執行以下 command:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
##############################
# Install #
##############################
sudo apt update
sudo apt install flatpak

##############################
# After reboot #
##############################
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flatpak override --user --filesystem=xdg-data/applications com.usebottles.bottles
flatpak override --user --filesystem=xdg-download com.usebottles.bottles
flatpak install flathub com.usebottles.bottles
flatpak override com.usebottles.bottles --user --filesystem=xdg-data/applications
flatpak override com.usebottles.bottles --user --filesystem=xdg-download

在安裝完畢後開啟 Bottles,同樣可以依照前面的文章來 step by step 安裝 Line,只是有幾點需要注意:

  1. Runner(執行器)建議使用 Kron4ek Wine 10.13。

    Runner 安裝方式:

    1. 選擇 Main Menu > Preferences:

      runner-kron4ek-wine-10.13_0

    2. 到 Runner 選單下找到 Kron4ek Wine 10.13 並按下儲存的 icon:

      runner-kron4ek-wine-10.13_1

  2. Bottle 中的 Depentencies(相依行組件)需要:

    • cjkfonts
    • d3dcompiler_47
    • vcredist2005
    • vcredist2022
  3. Line 版本建議使用舊版,使用較新版本程式執行會無限等待(如下圖),因此本次安裝是使用 line-9-2-0-build-3431.exe,這邊連結提供的是第三方下載檔,可以自行評估是否使用。

    line-timeout-issue

  4. 安裝完畢後要作一些操作避免 Line 自動更新:

    1. 將 LineUpdater.exe 移除。

    2. 在相同路徑下移除 old current 資料夾,並建立空白檔案。

    前兩點可以統一執行 command 完成:

    1
    2
    3
    cd $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$USER/AppData/Local/LINE/bin/
    rm -rf LineUpdater.exe old/ current/
    touch LineUpdater.exe old current

    2026-04-07 Update
    經驗證後,oldcurrent 資料夾可以使用唯獨空檔(read-only empty file)卡位,我們只需要使用腳本來實時監測 LineUpdater.exe 以及更新檔案是否被建立,詳細方式請參考LineUpdater-exe - Issue and Solution

Issue and Solution

LineUpdater.exe

由於 LineUpdater.exe 在每次執行 Line 後都會自動被建立,因此可以透過 inotify-tools 以及腳本來自動監測與刪除。

Install inotify-tools

1
2
sudo apt update
sudo apt install -y inotify-tools

Create Script for Auto-Clean

請注意在第五行中的 USERNAME 中填入自己的使用者名稱,可以透過 $ whoami 來確認。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
$ sudo vi /usr/local/bin/line-updater-cleaner.sh
#!/usr/bin/env bash

# Target directory to monitor
USERNAME="FILL—YOUR—USERNAME—HERE"
TARGET_DIR="/home/$USERNAME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$USERNAME/AppData/Local/LINE/bin"

echo "Monitoring started in: $TARGET_DIR"

# Monitor for creation of files or directories
inotifywait -m -e create,moved_to --format '%f' "$TARGET_DIR" | while read NEW_ITEM
do
# 1. Check for LineUpdater.exe
# 2. Check for version-style names (e.g., 9.2.0.3431) using Regex
# Regex explanation: ^[0-9.]+ matches strings containing only digits and dots
if [[ "$NEW_ITEM" == "LineUpdater.exe" ]] || [[ "$NEW_ITEM" =~ ^[0-9.]+$ ]]; then

FULL_PATH="$TARGET_DIR/$NEW_ITEM"

# Determine if it's a directory or a file for proper deletion
if [ -d "$FULL_PATH" ]; then
rm -rf "$FULL_PATH"
echo "Removed directory: $NEW_ITEM"
elif [ -f "$FULL_PATH" ]; then
rm -f "$FULL_PATH"
echo "Removed file: $NEW_ITEM"
fi
fi
done
$ sudo chmod +x /usr/local/bin/line-updater-cleaner.sh

Create Systemd Service for Startup

首先先建立 Systemd Service:

1
2
3
4
5
6
7
8
9
10
11
12
$ sudo vi /etc/systemd/system/line-updater-cleaner.service
[Unit]
Description=Auto Delete LineUpdater.exe For Line (Bottles)
After=network.target

[Service]
ExecStart=/usr/local/bin/line-updater-cleaner.sh
Restart=always
User=root

[Install]
WantedBy=multi-user.target

接著開啟開機自動執行:

1
2
sudo systemctl start line-updater-cleaner
sudo systemctl enable line-updater-cleaner

Chinese Input

安裝完後發現在對話視窗內無法輸入中文,需要在 Bottle 下進入 (Options) Settings > (Compatibility) Environment Variables,新增以下幾個環境變數:

1
2
3
4
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
SDL_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx

Crash After Login

移除 Line 設定檔後重新登入:

1
rm $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini

Change Line Theme

開啟 Line 設定檔,並在 global 中加入 app_theme 來做設定,分別是:

  1. app_theme=0: White
  2. app_theme=1: Black (Dark)
  3. app_theme=2: System Settings
1
2
3
4
5
6
$ vi $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini

[global]
...
app_theme=1
...

Crash Report

開啟 Line 並登入後出現 Crash Report 視窗,並在按下 close 後 Line 會被關閉。

line-crash-report

可以開啟 Line.ini,並將內容中帶有下列幾個關鍵字的內容移除後重開 Line:

  • chat
  • last_selected_main_tab_index
  • last_sending_time_settings

或是透過 command 完成:

1
2
3
sed -i '/chat/d'                         $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini
sed -i '/last_selected_main_tab_index/d' $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini
sed -i '/last_sending_time_settings/d' $HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini

References