Compare commits

...

3 commits

Author SHA1 Message Date
maximilionus
916055d8bd
Linux proxy control script improvement (#7558)
Some checks failed
release Linux / build (Release) (push) Has been cancelled
release macOS / build (Release) (push) Has been cancelled
release Windows desktop (Avalonia UI) / build (Release) (push) Has been cancelled
release Windows / build (Release) (push) Has been cancelled
* 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.
2025-07-09 20:59:24 +08:00
happytrudy
683ca8af14
add shadowquic (#7554) 2025-07-09 20:41:20 +08:00
2dust
70151db91b Add tray menu to display the main window
https://github.com/2dust/v2rayN/issues/7549
2025-07-09 20:31:37 +08:00
7 changed files with 58 additions and 17 deletions

View file

@ -14,5 +14,6 @@ public enum ECoreType
hysteria2 = 26,
brook = 27,
overtls = 28,
shadowquic = 29,
v2rayN = 99
}

View file

@ -507,6 +507,7 @@ public class Global
{ ECoreType.juicity, "juicity/juicity" },
{ ECoreType.brook, "txthinking/brook" },
{ ECoreType.overtls, "ShadowsocksR-Live/overtls" },
{ ECoreType.shadowquic, "spongebob888/shadowquic" },
{ ECoreType.v2rayN, "2dust/v2rayN" },
};

View file

@ -200,6 +200,15 @@ public sealed class CoreInfoHandler
Arguments = "-r client -c {0}",
Url = GetCoreUrl(ECoreType.overtls),
AbsolutePath = false,
},
new CoreInfo
{
CoreType = ECoreType.shadowquic,
CoreExes = [ "shadowquic", "shadowquic"],
Arguments = "-c {0}",
Url = GetCoreUrl(ECoreType.shadowquic),
AbsolutePath = false,
}
];

View file

@ -7,4 +7,4 @@ X-GNOME-Autostart-enabled=true
Name[en_US]=v2rayN
Name=v2rayN
Comment[en_US]=v2rayN
Comment=v2rayN
Comment=v2rayN

View file

@ -29,9 +29,6 @@ set_gnome_proxy() {
echo "Ignored Hosts: $IGNORE_HOSTS"
elif [ "$MODE" == "none" ]; then
echo "GNOME: Proxy disabled."
else
echo "GNOME: Invalid mode. Use 'none' or 'manual'."
exit 1
fi
}
@ -69,9 +66,6 @@ set_kde_proxy() {
# Disable proxy
$KWRITECONFIG --file kioslaverc --group "Proxy Settings" --key ProxyType 0
echo "KDE: Proxy disabled."
else
echo "KDE: Invalid mode. Use 'none' or 'manual'."
exit 1
fi
# Apply changes by restarting KDE's network settings
@ -84,7 +78,7 @@ detect_desktop_environment() {
echo "gnome"
return
fi
if [[ "$XDG_CURRENT_DESKTOP" == *"XFCE"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"XFCE"* ]]; then
echo "gnome"
return
@ -94,7 +88,7 @@ detect_desktop_environment() {
echo "gnome"
return
fi
if [[ "$XDG_CURRENT_DESKTOP" == *"UKUI"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"ukui"* ]]; then
echo "gnome"
return
@ -117,6 +111,15 @@ detect_desktop_environment() {
return
fi
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"
}
@ -134,6 +137,11 @@ PROXY_IP=$2
PROXY_PORT=$3
IGNORE_HOSTS=$4
if ! [[ "$MODE" =~ ^(manual|none)$ ]]; then
echo "Invalid mode. Use 'none' or 'manual'." >&2
exit 1
fi
# 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_kde_proxy "$MODE" "$PROXY_IP" "$PROXY_PORT" "$IGNORE_HOSTS"
else
echo "Unsupported desktop environment: $DE"
echo "Unsupported desktop environment: $DE" >&2
exit 1
fi
fi

View file

@ -34,6 +34,8 @@ public class StatusBarViewModel : MyReactiveObject
public ReactiveCommand<Unit, Unit> SubUpdateViaProxyCmd { get; }
public ReactiveCommand<Unit, Unit> CopyProxyCmdToClipboardCmd { get; }
public ReactiveCommand<Unit, Unit> NotifyLeftClickCmd { get; }
public ReactiveCommand<Unit, Unit> ShowWindowCmd { get; }
public ReactiveCommand<Unit, Unit> HideWindowCmd { get; }
#region System Proxy
@ -91,6 +93,9 @@ public class StatusBarViewModel : MyReactiveObject
[Reactive]
public bool EnableTun { get; set; }
[Reactive]
public bool BlIsNonWindows { get; set; }
#endregion UI
public StatusBarViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
@ -100,6 +105,7 @@ public class StatusBarViewModel : MyReactiveObject
SelectedServer = new();
RunningServerToolTipText = "-";
BlSystemProxyPacVisible = Utils.IsWindows();
BlIsNonWindows = Utils.IsNonWindows();
if (_config.TunModeItem.EnableTun && AllowEnableTun())
{
@ -143,11 +149,21 @@ public class StatusBarViewModel : MyReactiveObject
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(null);
await Task.CompletedTask;
});
ShowWindowCmd = ReactiveCommand.CreateFromTask(async () =>
{
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(true);
await Task.CompletedTask;
});
HideWindowCmd = ReactiveCommand.CreateFromTask(async () =>
{
Locator.Current.GetService<MainWindowViewModel>()?.ShowHideWindow(false);
await Task.CompletedTask;
});
AddServerViaClipboardCmd = ReactiveCommand.CreateFromTask(async () =>
{
await AddServerViaClipboard();
});
{
await AddServerViaClipboard();
});
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
{
await AddServerViaScan();

View file

@ -32,7 +32,15 @@
ToolTipText="{Binding RunningServerToolTipText}">
<TrayIcon.Menu>
<NativeMenu>
<NativeMenuItem Command="{Binding NotifyLeftClickCmd}" Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}" />
<NativeMenuItem
Command="{Binding ShowWindowCmd}"
Header="{x:Static resx:ResUI.TbDisplayGUI}"
IsVisible="{Binding BlIsNonWindows}" />
<NativeMenuItem
Command="{Binding NotifyLeftClickCmd}"
Header="{x:Static resx:ResUI.menuShowOrHideMainWindow}"
IsVisible="{Binding BlIsNonWindows}" />
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
<NativeMenuItemSeparator />
<NativeMenuItem
Command="{Binding SystemProxyClearCmd}"
@ -60,8 +68,6 @@
<NativeMenuItem Command="{Binding SubUpdateCmd}" Header="{x:Static resx:ResUI.menuSubUpdate}" />
<NativeMenuItem Command="{Binding SubUpdateViaProxyCmd}" Header="{x:Static resx:ResUI.menuSubUpdateViaProxy}" />
<NativeMenuItemSeparator />
<NativeMenuItem Command="{Binding CopyProxyCmdToClipboardCmd}" Header="{x:Static resx:ResUI.menuCopyProxyCmdToClipboard}" />
<NativeMenuItemSeparator />
<NativeMenuItem Click="MenuExit_Click" Header="{x:Static resx:ResUI.menuExit}" />
</NativeMenu>
</TrayIcon.Menu>