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

這節會列出幾個設定,或遇到的問題與解決方法:

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
...

Desktop Entry

可以通過建立 .desktop 檔案來釘選 Line 圖示在應用程式列表(Application Launcher)或工作列(Taskbar)中。

假設 Bottle Name 叫做 Line,可以建立以下設定檔:

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
$ vi /.local/share/application/com.usebottles.bottles.line.desktop
[Desktop Entry]
Actions=Configure;
Categories=Application;
Comment=Launch Line using Bottles.
StartupWMClass=LINE.exe
X-Flatpak=com.usebottles.bottles
Exec=flatpak run --command=bottles-cli com.usebottles.bottles run -p LineLauncher -b Line
GenericName=Internet Messenger
Icon=/your/line/icon/file/path/Line.png
Name=Line
NoDisplay=false
Path=
PrefersNonDefaultGPU=false
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-KDE-SubstituteUID=false
X-KDE-Username=

[Desktop Action Configure]
Exec=flatpak run --command=bottles-cli com.usebottles.bottles -b 'Line'
Icon=/your/line/icon/file/path/Line.png
Name=Configure in Bottles

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
$ 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.]+$ && "$NEW_ITEM" != "$VERSION" ]]; 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 Report

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

line-crash-report

目前有兩種方法可以嘗試:

  1. 直接移除 LINE.ini,暴力有效。
  2. 移除 LINE.ini 相關 key/value,可以透過腳本執行。

建議可以先使用方法 2,若不行再直接移除 LINE.ini

Remove Dependency Key/Value in LINE.ini

建立 line-crash-reset.sh 檔案,並在內容中輸入:

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
$ vi line-crash-reset.sh#!/usr/bin/env bash

# Exit immediately if a command exits with a non-zero status
set -e

# Define color codes
BLUE='\033[0;34m'
GREEN='\033[0;32m'
ORANGE='\033[0;33m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
PURPLE='\033[0;35m'
NC='\033[0m' # No Color (Reset)

# Log function: log <level_color> <level_text> <message>
log() {
local color="$1"
local level="$2"
local message="$3"
echo -e "[${color}${level}${NC}] ${message}"
}
# Wrapper functions for cleaner syntax
info() { log "${BLUE}" " INFO " "$1"; }
ok () { log "${GREEN}" " OK " "$1"; }
warn() { log "${ORANGE}" " WARN " "$1"; }
fail() { log "${RED}" " FAIL " "$1"; }
note() { log "${YELLOW}" " NOTE " "$1"; }

# Preparing to reset LINE by removing specific entries from LINE.ini
info "Resetting LINE by removing specific entries from LINE.ini..."
deep_remove=0
for arg in "$@"; do
if [ "$arg" == "--help" ]; then
echo "Usage: $0 [--deep-remove]"
echo " --deep-remove: Remove all entries without first section of LINE.ini, not just the specified keys."
exit 0
fi
if [ "$arg" == "--deep-remove" ]; then
deep_remove=1
info "Deep remove enabled: All entries without first section of LINE.ini will be removed."
break
fi
done

# Input and output configuration
input_file="$HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE.ini"
output_file="$HOME/.var/app/com.usebottles.bottles/data/bottles/bottles/Line/drive_c/users/$(whoami)/AppData/Local/LINE/Data/LINE_fixed.ini"

# Use awk to filter the second section
awk -v deep="$deep_remove" '
BEGIN {
# Allowed keys list
list = "windowstore_app_dbfile_checked|up|is_main_profile_keep_confirm|app_version|app_install_time|last_notify_updated_version|lockscreen_login|acf|disabled_mobile_alarm_while_using_pc|notification_mention_enabled|allow_call_alarm|privacy_receive_mesages_from_not_friend|recognized_expand_panel_guide"

# Pattern: (Backslash OR Start of line) + (Key) + (Equal sign)
pattern = "(\\\\|^)(" list ")[[:space:]]*="

section_count = 0
}

# Detect section headers
/^\[.*\]/ {
section_count++

# If deep-remove is ON, we only print the first section header
if (deep == 1 && section_count > 1) {
# Skip printing other headers
next
}
print $0
next
}

{
if (section_count == 2) {
# Filtering logic for the second block
if ($0 ~ /=/) {
if ($0 ~ pattern) {
print $0
}
} else {
# Keep empty lines or comments in the second block
print $0
}
} else if (section_count == 0 || section_count == 1) {
# Always keep everything before the first block and inside the first block
print $0
} else {
# For section 3, 4, etc.
# If deep-remove is OFF (0), keep them. If ON (1), they are effectively removed.
if (deep == 0) {
print $0
}
}
}' "$input_file" > "$output_file"

mv "$input_file" "$input_file.bak"
mv "$output_file" "$input_file"
ok "LINE reset complete! You can now launch LINE and it should start fresh without previous chat history or settings."

接著給與腳本執行權限:

1
chmod +w line-crash-reset.sh

腳本會有兩種模式,可以先直接執行後登入 Line 看問題是否已被解決:

1
./line-creash-reset.sh

若重新登入後仍然遇到一樣問題,則可以使用 --deep-remove 模式來完整清除,使用這個模式登入 Line 可能會需要重新輸入 PIN 碼

1
./line-creash-reset.sh --deep-remove

Delete LINE.ini

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

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

References