Merge pull request #6 from xujie86/master

Update proxy_set_linux_sh
This commit is contained in:
JieXu 2026-04-15 18:21:16 +08:00 committed by GitHub
commit 4fe5269198
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,24 @@
#!/bin/bash #!/bin/bash
trim() {
local -n ref=$1
ref="${ref#"${ref%%[![:space:]]*}"}"
ref="${ref%"${ref##*[![:space:]]}"}"
}
build_gsettings_array() {
[[ -z "$1" ]] && echo "[]" && return
local host joined hosts=()
IFS=',' read -ra parts <<< "$1"
for host in "${parts[@]}"; do
trim host
[[ -n "$host" ]] && hosts+=("$host")
done
[[ ${#hosts[@]} -eq 0 ]] && echo "[]" && return
printf -v joined "'%s'," "${hosts[@]}"
echo "[${joined%,}]"
}
# Function to set proxy for GNOME # Function to set proxy for GNOME
set_gnome_proxy() { set_gnome_proxy() {
local MODE=$1 local MODE=$1
@ -21,7 +40,7 @@ set_gnome_proxy() {
done done
# Set ignored hosts # Set ignored hosts
gsettings set org.gnome.system.proxy ignore-hosts "['$IGNORE_HOSTS']" gsettings set org.gnome.system.proxy ignore-hosts "$(build_gsettings_array "$IGNORE_HOSTS")"
echo "GNOME: Manual proxy settings applied." echo "GNOME: Manual proxy settings applied."
echo "Proxy IP: $PROXY_IP" echo "Proxy IP: $PROXY_IP"