Skip to content
Open
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
20 changes: 4 additions & 16 deletions resources-linux/defguard-client.spec
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,8 @@ Desktop client for managing WireGuard VPN connections
%{__mkdir} -p %{buildroot}/%{_datadir}/icons/hicolor/32x32/apps
%{__install} -m 755 src-tauri/target/release/defguard-client %{buildroot}/%{_bindir}/
%{__install} -m 755 src-tauri/target/release/defguard-service %{buildroot}/%{_sbindir}/
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-black.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-black.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-black-active.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-black-active.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-color.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-color.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-color-active.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-color-active.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-gray.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-gray.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-gray-active.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-gray-active.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-white.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-white.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-white-active.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-white-active.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32.png
%{__install} -m 644 src-tauri/target/release/resources/icons/tray-32x32-active.png %{buildroot}/%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-active.png
%{__install} -m 644 resources-linux/defguard-service.service %{buildroot}/%{_prefix}/lib/systemd/system/
%{__install} -m 644 resources-linux/defguard-client.desktop %{buildroot}/%{_datadir}/applications/defguard-client.desktop
%{__install} -m 644 src-tauri/icons/128x128.png %{buildroot}/%{_datadir}/icons/hicolor/128x128/apps/defguard-client.png
Expand Down Expand Up @@ -57,14 +51,8 @@ systemctl daemon-reload
%files
%{_bindir}/defguard-client
%{_sbindir}/defguard-service
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-black.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-black-active.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-color.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-color-active.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-gray.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-gray-active.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-white.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-white-active.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32.png
%{_prefix}/lib/defguard-client/resources/icons/tray-32x32-active.png
%{_prefix}/lib/systemd/system/defguard-service.service
%{_datadir}/applications/defguard-client.desktop
%{_datadir}/icons/hicolor/128x128/apps/defguard-client.png
Expand Down
Binary file modified src-tauri/icons/128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/128x128@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src-tauri/icons/64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square107x107Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square142x142Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square150x150Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square284x284Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square30x30Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square310x310Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square44x44Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square71x71Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/Square89x89Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src-tauri/icons/StoreLogo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src-tauri/icons/android/mipmap-anydpi-v26/ic_launcher.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<foreground android:drawable="@mipmap/ic_launcher_foreground"/>
<background android:drawable="@color/ic_launcher_background"/>
</adaptive-icon>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src-tauri/icons/android/values/ic_launcher_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file modified src-tauri/icons/icon.icns
Binary file not shown.
Binary file modified src-tauri/icons/icon.ico
Binary file not shown.
Binary file modified src-tauri/icons/icon.png
Binary file added src-tauri/icons/ios/AppIcon-20x20@1x.png
Binary file added src-tauri/icons/ios/AppIcon-20x20@2x-1.png
Binary file added src-tauri/icons/ios/AppIcon-20x20@2x.png
Binary file added src-tauri/icons/ios/AppIcon-20x20@3x.png
Binary file added src-tauri/icons/ios/AppIcon-29x29@1x.png
Binary file added src-tauri/icons/ios/AppIcon-29x29@2x-1.png
Binary file added src-tauri/icons/ios/AppIcon-29x29@2x.png
Binary file added src-tauri/icons/ios/AppIcon-29x29@3x.png
Binary file added src-tauri/icons/ios/AppIcon-40x40@1x.png
Binary file added src-tauri/icons/ios/AppIcon-40x40@2x-1.png
Binary file added src-tauri/icons/ios/AppIcon-40x40@2x.png
Binary file added src-tauri/icons/ios/AppIcon-40x40@3x.png
Binary file added src-tauri/icons/ios/AppIcon-512@2x.png
Binary file added src-tauri/icons/ios/AppIcon-60x60@2x.png
Binary file added src-tauri/icons/ios/AppIcon-60x60@3x.png
Binary file added src-tauri/icons/ios/AppIcon-76x76@1x.png
Binary file added src-tauri/icons/ios/AppIcon-76x76@2x.png
Binary file added src-tauri/icons/ios/AppIcon-83.5x83.5@2x.png
Binary file added src-tauri/resources/icons/tray-32x32-active.png
Binary file removed src-tauri/resources/icons/tray-32x32-black-active.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-black.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-color-active.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-color.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-gray-active.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-gray.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-white-active.png
Diff not rendered.
Binary file removed src-tauri/resources/icons/tray-32x32-white.png
Diff not rendered.
Binary file added src-tauri/resources/icons/tray-32x32.png
13 changes: 0 additions & 13 deletions src-tauri/src/app_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{
use log::LevelFilter;
use serde::{Deserialize, Serialize};
use struct_patch::Patch;
use strum::{AsRefStr, EnumString};
use tauri::{AppHandle, Manager};

#[cfg(unix)]
Expand Down Expand Up @@ -48,24 +47,13 @@ pub enum AppTheme {
Dark,
}

#[derive(AsRefStr, Clone, Copy, Debug, Deserialize, EnumString, PartialEq, Serialize)]
#[strum(serialize_all = "lowercase")]
#[serde(rename_all = "lowercase")]
pub enum AppTrayTheme {
Color,
White,
Black,
Gray,
}

// config stored in config.json in app data
// config is loaded once at startup and saved when modified to the app data file
// information's needed at startup of the application.
#[derive(Clone, Debug, Deserialize, Patch, Serialize)]
#[patch(attribute(derive(Debug, Deserialize, Serialize)))]
pub struct AppConfig {
pub theme: AppTheme,
pub tray_theme: AppTrayTheme,
pub check_for_updates: bool,
pub log_level: LevelFilter,
/// In seconds. How much time after last network activity the connection is automatically dropped.
Expand All @@ -80,7 +68,6 @@ impl Default for AppConfig {
Self {
theme: AppTheme::Light,
check_for_updates: true,
tray_theme: AppTrayTheme::Color,
log_level: LevelFilter::Info,
peer_alive_period: 300,
mtu: 0,
Expand Down
8 changes: 0 additions & 8 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1527,21 +1527,13 @@ pub async fn command_set_app_config(
let app_state = app_handle.state::<AppState>();
debug!("Command set app config received.");
trace!("Command payload: {config_patch:?}");
let tray_changed = config_patch.tray_theme.is_some();
let res = {
let mut app_config = app_state.app_config.lock().unwrap();
app_config.apply(config_patch);
app_config.save(&app_handle);
app_config.clone()
};
info!("Config changed successfully");
if tray_changed {
debug!("Tray theme included in config change, tray will be updated.");
match configure_tray_icon(&app_handle).await {
Ok(()) => debug!("Tray updated upon config change"),
Err(err) => error!("Tray change failed. Reason: {err}"),
}
}
if emit_event {
match app_handle.emit(EventKey::ApplicationConfigChanged.into(), ()) {
Ok(()) => debug!("Config changed event emitted successfully"),
Expand Down
6 changes: 1 addition & 5 deletions src-tauri/src/tray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,16 +280,12 @@ pub fn handle_tray_menu_event(app: &AppHandle, event: MenuEvent) {

/// Show correct system tray icon, depending on the theme and connection status.
pub async fn configure_tray_icon(app_handle: &AppHandle) -> Result<(), Error> {
let state = app_handle.state::<AppState>();
let theme = state.app_config.lock().unwrap().tray_theme;

let Some(tray_icon) = app_handle.tray_by_id(TRAY_ICON_ID) else {
error!("System tray menu not initialized.");
return Ok(());
};

let mut resource_str = String::from("resources/icons/tray-32x32-");
resource_str.push_str(theme.as_ref());
let mut resource_str = String::from("resources/icons/tray-32x32");
let active_connections = ACTIVE_CONNECTIONS.lock().await;
if !active_connections.is_empty() {
resource_str.push_str("-active");
Expand Down
5 changes: 0 additions & 5 deletions src/pages/client/clientAPI/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export type SaveTunnelRequest = {
response: CreateDeviceResponse;
};

export type TrayIconTheme = 'color' | 'white' | 'black' | 'gray';

export const availableTrayThemes: TrayIconTheme[] = ['color', 'white', 'gray', 'black'];

export type LogLevel = 'ERROR' | 'INFO' | 'DEBUG' | 'TRACE' | 'WARN';

export const availableLogLevels: LogLevel[] = ['ERROR', 'WARN', 'INFO', 'DEBUG', 'TRACE'];
Expand Down Expand Up @@ -77,7 +73,6 @@ export type InterfaceLogsRequest = {
export type AppConfig = {
theme: ThemeKey;
log_level: LogLevel;
tray_theme: TrayIconTheme;
check_for_updates: boolean;
peer_alive_period: number;
mtu: number;
Expand Down
1 change: 0 additions & 1 deletion src/pages/client/hooks/useClientStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const defaultValues: StoreValues = {
appConfig: {
log_level: 'INFO',
theme: 'light',
tray_theme: 'color',
check_for_updates: true,
peer_alive_period: 300,
mtu: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ import {
import {
type AppConfig,
availableLogLevels,
availableTrayThemes,
type LogLevel,
type TrayIconTheme,
} from '../../../../clientAPI/types';
import { useClientStore } from '../../../../hooks/useClientStore';

Expand Down Expand Up @@ -70,10 +68,6 @@ export const GlobalSettingsTab = () => {
.string()
.min(1, LL.form.errors.required())
.refine((v) => availableLogLevels.includes(v as LogLevel)),
tray_theme: z
.string()
.min(1, LL.form.errors.required())
.refine((v) => availableTrayThemes.includes(v as TrayIconTheme)),
check_for_updates: z.boolean(),
peer_alive_period: z
.number({
Expand Down Expand Up @@ -122,10 +116,6 @@ export const GlobalSettingsTab = () => {
<h2>{localLL.versionUpdate.title()}</h2>
<CheckForUpdatesOption controller={{ control, name: 'check_for_updates' }} />
</section>
<section>
<h2>{localLL.tray.title()}</h2>
<TrayIconThemeSelect controller={{ control, name: 'tray_theme' }} />
</section>
<section>
<h2>{localLL.logging.title()}</h2>
<LoggingLevelSelect controller={{ control, name: 'log_level' }} />
Expand Down Expand Up @@ -275,64 +265,6 @@ const LoggingLevelSelect = ({ controller }: FormMemberProps) => {
);
};

const TrayIconThemeSelect = ({ controller }: FormMemberProps) => {
const { LL } = useI18nContext();
const localLL = LL.pages.client.pages.settingsPage.tabs.global;

const trayThemeSelectOptions = useMemo((): SelectOption<TrayIconTheme>[] => {
const res: SelectOption<TrayIconTheme>[] = [
{
label: localLL.tray.options.color(),
value: 'color',
key: 0,
},
{
value: 'gray',
key: 1,
label: localLL.tray.options.gray(),
},
{
value: 'white',
key: 2,
label: localLL.tray.options.white(),
},
{
value: 'black',
key: 3,
label: localLL.tray.options.black(),
},
];
return res;
}, [localLL.tray.options]);

const renderSelectedTrayTheme = useCallback(
(theme: TrayIconTheme): SelectSelectedValue => {
const option = trayThemeSelectOptions.find((t) => t.value === theme);
if (option) {
return {
key: option.key,
displayValue: option.label,
};
}
return {
key: 'color',
displayValue: 'color',
};
},
[trayThemeSelectOptions],
);

return (
<FormSelect
sizeVariant={SelectSizeVariant.STANDARD}
options={trayThemeSelectOptions}
label={localLL.tray.label()}
renderSelected={renderSelectedTrayTheme}
controller={controller}
/>
);
};

const CheckForUpdatesOption = ({ controller }: FormMemberProps) => {
const { LL } = useI18nContext();
const localLL = LL.pages.client.pages.settingsPage.tabs.global;
Expand Down
Loading