Accessing Local Files Perfectly with WeChat on Linux

Accessing Local Files Perfectly with WeChat on Linux

Due to personal preference, I have been using Fedora as my desktop system. Although I am not fond of WeChat, it is unavoidable in my work. Currently, the Flatpak version of WeChat for Linux is significantly better than the previous web version. However, I have found that when using it, the Flatpak version does not allow users to view local files when selecting files to send; it only displays a very limited set of directories and files, showing content from just two folders by default.

Accessing Local Files Perfectly with WeChat on Linux

Previously, when I needed to send files, I would temporarily switch to the web version of WeChat for convenience, send the files, and then switch back. However, this felt unsatisfactory since the web version of WeChat is a stripped-down version that does not support features like Moments, Video Accounts, or Favorites. So, taking advantage of some free time today, I decided to investigate this issue.

The root cause of this problem is that Flatpak runs in a sandboxed mode. For security reasons, Flatpak restricts applications to operate within an isolated environment by default:

  • Only able to access its own data directory: ~/.var/app/$APPID (read and write).

  • Prohibits access to the host file system (except for runtime files), network, device nodes, or external processes.

  • Restricted system calls (such as disabling unconventional network sockets).

If access to files outside the isolated environment is needed, authorization can be granted in two ways:

  • Application declaration: Developers declare the required permissions (such as file system, network) through a manifest file. Since WeChat is not developed by us, this method is not applicable.

  • User authorization: Users can modify application permissions to gain access to local file directories. This can be adjusted using the Flatpak tool.

For the WeChat issue, we have the following solutions:

1

Adjusting via the Flatseal tool:

Install the Flatseal tool:

$ flatpak search flatseal

Accessing Local Files Perfectly with WeChat on Linux

The first result is the tool we need; simply install it using the command below:

$ flatpak install com.github.tchx84.Flatseal

If you have both Fedora and Flathub repositories configured, you will be prompted to choose which repository to install from. I chose Flathub. After installation, run it in the graphical terminal:

$ flatpak run com.github.tchx84.Flatseal

Alternatively, you can find Flatseal in your desktop’s start menu and run it. This tool can only modify the rules for the current user:

Accessing Local Files Perfectly with WeChat on Linux

Then click on WeChat, scroll down to Filesystem, and select all user files as shown in the image below. Of course, you can also open all system files or add specific directories in other files; just enter the absolute path, for example: ~/Desktop, ~/Documents, or as I did below, set /mnt/d as an access directory, etc.:

Accessing Local Files Perfectly with WeChat on Linux

After that, restart the Flatpak version of WeChat, and you will be able to access local files smoothly:

Accessing Local Files Perfectly with WeChat on Linux

2

Modifying via the command line

The second method is to authorize via the command line to resolve this issue. This tool modifies the system’s global settings, affecting all local users. The format is:

$ flatpak override <Application ID> –filesystem=home

Valid directories include host, host-os, host-etc, home, xdg-*[/…], ~/dir, /dir. For WeChat, if you want to share the entire user’s home directory with WeChat, execute:$ sudo flatpak override com.tencent.WeChat –filesystem=home

To share /mnt/d with WeChat:

$ sudo flatpak override com.tencent.WeChat –filesystem=/mnt/d

Each execution does not overwrite previous settings but adds a new rule. Therefore, if you want to cancel the corresponding setting, please execute:

$ sudo flatpak override com.tencent.WeChat –nofilesystem=/mnt/d

This command will cancel the sharing of /mnt/d.

Please note that after each modification, you need to restart WeChat for the changes to take effect.

That’s how to resolve local file permission issues with the Flatpak packaged WeChat on Linux. If this helps you, please follow or leave a comment.

Author: Chen Lifeng

Formatting: Z Bao

Accessing Local Files Perfectly with WeChat on Linux

Leave a Comment