mirror of https://github.com/2dust/v2rayN
Linux proxy control script improvement (#7558)
* Proper Unix files new-line termination * Fallback for proxy configuration on Linux This introduces a special fallback for platform detection that helps with configuring the proxy settings on minimal (DE-less) setups. Also unifies the check for proper $MODE value.pull/7579/head
parent
683ca8af14
commit
916055d8bd
|
@ -7,4 +7,4 @@ X-GNOME-Autostart-enabled=true
|
||||||
Name[en_US]=v2rayN
|
Name[en_US]=v2rayN
|
||||||
Name=v2rayN
|
Name=v2rayN
|
||||||
Comment[en_US]=v2rayN
|
Comment[en_US]=v2rayN
|
||||||
Comment=v2rayN
|
Comment=v2rayN
|
||||||
|
|
|
@ -29,9 +29,6 @@ set_gnome_proxy() {
|
||||||
echo "Ignored Hosts: $IGNORE_HOSTS"
|
echo "Ignored Hosts: $IGNORE_HOSTS"
|
||||||
elif [ "$MODE" == "none" ]; then
|
elif [ "$MODE" == "none" ]; then
|
||||||
echo "GNOME: Proxy disabled."
|
echo "GNOME: Proxy disabled."
|
||||||
else
|
|
||||||
echo "GNOME: Invalid mode. Use 'none' or 'manual'."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,9 +66,6 @@ set_kde_proxy() {
|
||||||
# Disable proxy
|
# Disable proxy
|
||||||
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ProxyType 0
|
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ProxyType 0
|
||||||
echo "KDE: Proxy disabled."
|
echo "KDE: Proxy disabled."
|
||||||
else
|
|
||||||
echo "KDE: Invalid mode. Use 'none' or 'manual'."
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply changes by restarting KDE's network settings
|
# Apply changes by restarting KDE's network settings
|
||||||
|
@ -84,7 +78,7 @@ detect_desktop_environment() {
|
||||||
echo "gnome"
|
echo "gnome"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$XDG_CURRENT_DESKTOP" == *"XFCE"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"XFCE"* ]]; then
|
if [[ "$XDG_CURRENT_DESKTOP" == *"XFCE"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"XFCE"* ]]; then
|
||||||
echo "gnome"
|
echo "gnome"
|
||||||
return
|
return
|
||||||
|
@ -94,7 +88,7 @@ detect_desktop_environment() {
|
||||||
echo "gnome"
|
echo "gnome"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$XDG_CURRENT_DESKTOP" == *"UKUI"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"ukui"* ]]; then
|
if [[ "$XDG_CURRENT_DESKTOP" == *"UKUI"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"ukui"* ]]; then
|
||||||
echo "gnome"
|
echo "gnome"
|
||||||
return
|
return
|
||||||
|
@ -117,6 +111,15 @@ detect_desktop_environment() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Fallback to GNOME method if CLI utility is available. This solves the
|
||||||
|
# proxy configuration issues on minimal installation systems, like setups
|
||||||
|
# with only window managers, that borrow some parts from big DEs.
|
||||||
|
if command -v gsettings >/dev/null 2>&1; then
|
||||||
|
echo "gnome"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
echo "unsupported"
|
echo "unsupported"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +137,11 @@ PROXY_IP=$2
|
||||||
PROXY_PORT=$3
|
PROXY_PORT=$3
|
||||||
IGNORE_HOSTS=$4
|
IGNORE_HOSTS=$4
|
||||||
|
|
||||||
|
if ! [[ "$MODE" =~ ^(manual|none)$ ]]; then
|
||||||
|
echo "Invalid mode. Use 'none' or 'manual'." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Detect desktop environment
|
# Detect desktop environment
|
||||||
DE=$(detect_desktop_environment)
|
DE=$(detect_desktop_environment)
|
||||||
|
|
||||||
|
@ -144,6 +152,6 @@ elif [ "$DE" == "kde" ]; then
|
||||||
set_gnome_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
|
set_gnome_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
|
||||||
set_kde_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
|
set_kde_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
|
||||||
else
|
else
|
||||||
echo "Unsupported desktop environment: $DE"
|
echo "Unsupported desktop environment: $DE" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue