Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable proxy via reading envrionment variables #488

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,18 @@ This is a community-maintained [Flatpak](https://flatpak.org/) distribution of [
## User-specified config.json

Element Desktop's [instructions](https://github.com/vector-im/element-desktop/#user-specified-configjson) to use user-specified configuration settings do not apply. Instead, `config.json` must be created at `~/.var/app/im.riot.Riot/config/$NAME/config.json`, where `$NAME` is typically `Element`. The contents of the file are otherwise the same.

## Networking proxy

Overriding enviroment variables such as `all_proxy`, `http_proxy`, `https_proxy` can toggle proxy for Element Desktop. For example:

```bash
# enable proxy
flatpak override --env=all_proxy=http://127.0.0.1:7890 im.riot.Riot

# disable proxy overriding and use proxy settings from system (if current-shell env have related variables)
flatpak override --unset-env=all_proxy im.riot.Riot

# disable all proxy settings (Flatpak shell will inherit env from host shell sometimes)
flatpak override --env=all_proxy="" --env=http_proxy="" --env=https_proxy="" im.riot.Riot
```
9 changes: 9 additions & 0 deletions element.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ else
FLAGS="$FLAGS --enable-features=WebRTCPipeWireCapturer"
fi

# to apply proxy from environment variable
if [[ $all_proxy ]]; then
FLAGS="$FLAGS --proxy-server=$all_proxy"
elif [[ $http_proxy ]]; then
FLAGS="$FLAGS --proxy-server=$http_proxy"
elif [[ $https_proxy ]]; then
FLAGS="$FLAGS --proxy-server=$https_proxy"
fi

env TMPDIR="$XDG_RUNTIME_DIR/app/${FLATPAK_ID:-im.riot.Riot}" zypak-wrapper /app/Element/element-desktop $FLAGS "$@"