First Release

This commit is contained in:
2026-03-25 16:22:13 +01:00
commit 49814f2280
77 changed files with 8245 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
+3
View File
@@ -0,0 +1,3 @@
{
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
}
+143
View File
@@ -0,0 +1,143 @@
# YubiSwitch
> Basculez votre YubiKey entre Windows et WSL2 en un clic.
YubiSwitch est un petit utilitaire de bureau développé avec [Tauri](https://tauri.app) et Rust, conçu pour les développeurs qui utilisent WSL2 et ont besoin de partager leur YubiKey entre Windows et leur environnement Linux sans passer par la ligne de commande.
<img src="src-tauri/icons/app-icon.png" width="150" alt="YubiSwitch"/>
---
## Prérequis
Avant d'installer YubiSwitch, assurez-vous d'avoir les éléments suivants sur votre machine Windows :
**usbipd-win** — permet de partager des périphériques USB avec WSL2 :
```powershell
winget install usbipd
```
**WSL2 avec Ubuntu** — environnement Linux sous Windows :
```powershell
wsl --install
```
**Côté WSL2**, installez les outils YubiKey :
```bash
sudo apt update && sudo apt install -y yubikey-manager fido2-tools libfido2-dev
```
Ajoutez la règle udev pour accéder à la YubiKey sans sudo :
```bash
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="1050", MODE="0666", GROUP="plugdev"' | sudo tee /etc/udev/rules.d/70-yubikey.rules
sudo udevadm control --reload-rules
sudo usermod -aG plugdev $USER
```
---
## Installation
Téléchargez la dernière version depuis la page [Releases](../../releases) :
```
YubiSwitch_x.x.x_x64-setup.exe
```
Double-cliquez sur le fichier `.exe` et suivez l'installateur. YubiSwitch s'installe pour l'utilisateur courant et crée un raccourci bureau.
---
## Utilisation
### Démarrage
YubiSwitch se lance automatiquement dans la barre des tâches (system tray). Cliquez sur l'icône pour ouvrir la fenêtre principale.
### Basculer la YubiKey
1. Branchez votre YubiKey sur votre PC
2. Ouvrez YubiSwitch depuis le tray
3. Cliquez sur le **toggle** pour basculer entre Windows et WSL2
4. L'état se met à jour automatiquement toutes les 3 secondes
### Démarrage automatique
Activez le toggle **Démarrage auto** en bas de la fenêtre pour que YubiSwitch se lance à chaque démarrage de Windows.
### Fermer l'application
Cliquer sur la croix réduit l'app dans le tray. Pour quitter complètement, faites un clic droit sur l'icône du tray → **Quitter**.
---
## Architecture technique
YubiSwitch est construit avec [Tauri 2](https://tauri.app), qui combine un backend Rust et un frontend web léger.
```
yubiswitch/
├── src/ # Frontend (TypeScript + HTML/CSS)
│ ├── main.ts # Logique UI, polling état YubiKey
│ ├── index.html # Interface principale
│ └── styles.css # Styles aux couleurs Enuxia
└── src-tauri/ # Backend (Rust)
└── src/
├── main.rs # Point d'entrée Tauri
├── lib.rs # Commandes Tauri, system tray, autostart
└── usbipd.rs # Intégration usbipd (list, attach, detach)
```
### Fonctionnement
Le backend Rust appelle `usbipd` en mode silencieux (`CREATE_NO_WINDOW`) pour lister et contrôler les périphériques USB. La YubiKey est identifiée par son VID Yubico (`1050`). Le frontend interroge le backend toutes les 3 secondes pour mettre à jour l'état affiché.
### Stack
| Composant | Technologie |
|---|---|
| Framework desktop | Tauri 2 |
| Backend | Rust |
| Frontend | TypeScript + HTML/CSS vanilla |
| USB sharing | usbipd-win |
| Autostart | tauri-plugin-autostart |
---
## Contribuer
Les contributions sont les bienvenues ! Pour contribuer :
1. Forkez le repo
2. Créez une branche : `git checkout -b feature/ma-feature`
3. Committez vos changements : `git commit -m 'feat: ma feature'`
4. Pushez : `git push origin feature/ma-feature`
5. Ouvrez une Pull Request
### Développement local
```powershell
# Cloner le repo
git clone https://gitea.enuxia.fr/enuxia/yubiswitch
cd yubiswitch
# Installer les dépendances
npm install
# Lancer en mode dev
npm run tauri dev
# Builder
npm run tauri build
```
**Prérequis développement :**
- [Rust](https://rustup.rs/) 1.70+
- [Node.js](https://nodejs.org/) 18+
- [usbipd-win](https://github.com/dorssel/usbipd-win)
---
## Licence
MIT © 2026 [Enuxia](https://enuxia.com)
+51
View File
@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>YubiSwitch</title>
<link rel="stylesheet" href="/src/styles.css" />
</head>
<body>
<div class="container">
<div class="header">
<div class="logo">
<div class="logo-dot">
<img src="/src-tauri/icons/app-icon.png" width="22" height="22" style="border-radius:4px;"/>
</div>
<div>
<div class="logo-name">YubiSwitch</div>
<div class="logo-sub">by Enuxia</div>
</div>
</div>
<span class="version">v0.1.0</span>
</div>
<div class="status-bar">
<div class="status-indicator none" id="statusIndicator"></div>
<span class="status-text" id="statusText">Détection en cours…</span>
<span class="last-refresh" id="lastRefresh"></span>
</div>
<div id="noDevice" class="no-device hidden">
<div class="no-device-icon"></div>
<p>Aucune YubiKey détectée</p>
</div>
<div id="deviceList"></div>
<div class="footer">
<div class="autostart-row">
<span class="autostart-label">Démarrage auto</span>
<div class="toggle-small off" id="autostartToggle">
<div class="toggle-small-thumb"></div>
</div>
</div>
<span class="version" id="autostartStatus"></span>
</div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
+1424
View File
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
{
"name": "yubiswitch",
"private": true,
"version": "0.1.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri"
},
"dependencies": {
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-autostart": "^2.5.1",
"@tauri-apps/plugin-opener": "^2"
},
"devDependencies": {
"@tauri-apps/cli": "^2",
"typescript": "~5.6.2",
"vite": "^6.0.3"
}
}
+7
View File
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
+7
View File
@@ -0,0 +1,7 @@
added 1 package, and audited 21 packages in 2s
7 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
+5610
View File
File diff suppressed because it is too large Load Diff
+29
View File
@@ -0,0 +1,29 @@
[package]
name = "yubiswitch"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "yubiswitch_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri-plugin-opener = "2"
tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-autostart = "2"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
+10
View File
@@ -0,0 +1,10 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": ["main"],
"permissions": [
"core:default",
"opener:default"
]
}
+14
View File
@@ -0,0 +1,14 @@
{
"identifier": "desktop-capability",
"platforms": [
"macOS",
"windows",
"linux"
],
"windows": [
"main"
],
"permissions": [
"autostart:default"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

@@ -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>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#fff</color>
</resources>
Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+182
View File
@@ -0,0 +1,182 @@
mod usbipd;
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, TrayIconBuilder, TrayIconEvent},
AppHandle, Manager, WindowEvent,
};
use tauri_plugin_autostart::ManagerExt;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
#[tauri::command]
fn get_yubikeys() -> Vec<usbipd::UsbDevice> {
usbipd::list_yubikeys()
}
#[tauri::command]
async fn attach_yubikey(busid: String) -> Result<String, String> {
tauri::async_runtime::spawn_blocking(move || {
usbipd::ensure_wsl_running()
.map_err(|e| e.to_string())?;
usbipd::attach_to_wsl(&busid)
.map(|_| format!("YubiKey {} basculée vers WSL2", busid))
.map_err(|e| e.to_string())
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
async fn detach_yubikey(busid: String) -> Result<String, String> {
tauri::async_runtime::spawn_blocking(move || {
usbipd::detach(&busid)
.map(|_| format!("YubiKey {} basculée vers Windows", busid))
.map_err(|e| e.to_string())
})
.await
.map_err(|e| e.to_string())?
}
#[tauri::command]
fn enable_autostart(app: AppHandle) -> Result<(), String> {
app.autolaunch().enable().map_err(|e| e.to_string())
}
#[tauri::command]
fn disable_autostart(app: AppHandle) -> Result<(), String> {
app.autolaunch().disable().map_err(|e| e.to_string())
}
#[tauri::command]
fn is_autostart_enabled(app: AppHandle) -> Result<bool, String> {
app.autolaunch().is_enabled().map_err(|e| e.to_string())
}
#[tauri::command]
fn notify_state_changed(app: AppHandle) {
update_tray_icon(&app);
}
fn toggle_window(app: &AppHandle, last_toggle: &Arc<Mutex<Instant>>) {
let mut last = last_toggle.lock().unwrap();
if last.elapsed() < Duration::from_millis(300) {
return;
}
*last = Instant::now();
if let Some(win) = app.get_webview_window("main") {
if win.is_visible().unwrap_or(false) {
win.hide().unwrap();
} else {
win.show().unwrap();
win.set_focus().unwrap();
}
}
}
fn make_tray_icon(is_wsl: bool) -> tauri::image::Image<'static> {
let color: [u8; 4] = if is_wsl {
[139, 92, 246, 255]
} else {
[30, 144, 255, 255]
};
let size = 32u32;
let mut rgba = Vec::with_capacity((size * size * 4) as usize);
for y in 0..size {
for x in 0..size {
let cx = x as f32 - size as f32 / 2.0;
let cy = y as f32 - size as f32 / 2.0;
let dist = (cx * cx + cy * cy).sqrt();
let radius = size as f32 / 2.0 - 1.0;
if dist <= radius {
rgba.extend_from_slice(&color);
} else {
rgba.extend_from_slice(&[0, 0, 0, 0]);
}
}
}
tauri::image::Image::new_owned(rgba, size, size)
}
fn update_tray_icon(app: &AppHandle) {
let devices = usbipd::list_yubikeys();
let is_wsl = devices.first().map(|d| d.state == "WSL2").unwrap_or(false);
let tooltip = if is_wsl {
"YubiSwitch · WSL2"
} else {
"YubiSwitch · Windows"
};
if let Some(tray) = app.tray_by_id("main") {
let _ = tray.set_icon(Some(make_tray_icon(is_wsl)));
let _ = tray.set_tooltip(Some(tooltip));
}
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_autostart::Builder::new().build())
.plugin(tauri_plugin_opener::init())
.invoke_handler(tauri::generate_handler![
get_yubikeys,
attach_yubikey,
detach_yubikey,
enable_autostart,
disable_autostart,
is_autostart_enabled,
notify_state_changed,
])
.setup(|app| {
let window = app.get_webview_window("main").unwrap();
window.show().unwrap();
window.set_focus().unwrap();
let show = MenuItem::with_id(app, "show", "Ouvrir YubiSwitch", true, None::<&str>)?;
let quit = MenuItem::with_id(app, "quit", "Quitter", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show, &quit])?;
let last_toggle = Arc::new(Mutex::new(Instant::now() - Duration::from_secs(1)));
let last_toggle_clone = last_toggle.clone();
TrayIconBuilder::<tauri::Wry>::with_id("main")
.icon(make_tray_icon(false))
.menu(&menu)
.tooltip("YubiSwitch · Windows")
.on_menu_event(|app: &AppHandle, event| match event.id.as_ref() {
"show" => {
if let Some(win) = app.get_webview_window("main") {
win.show().unwrap();
win.set_focus().unwrap();
}
}
"quit" => app.exit(0),
_ => {}
})
.on_tray_icon_event(move |tray: &tauri::tray::TrayIcon, event| {
if let TrayIconEvent::Click {
button: MouseButton::Left,
..
} = event
{
toggle_window(tray.app_handle(), &last_toggle_clone);
}
})
.build(app)?;
Ok(())
})
.on_window_event(|window, event| {
if let WindowEvent::CloseRequested { api, .. } = event {
window.hide().unwrap();
api.prevent_close();
}
})
.run(tauri::generate_context!())
.expect("Erreur au lancement de Tauri");
}
+5
View File
@@ -0,0 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
fn main() {
yubiswitch_lib::run()
}
+89
View File
@@ -0,0 +1,89 @@
use std::process::Command;
use serde::{Deserialize, Serialize};
use std::os::windows::process::CommandExt;
const CREATE_NO_WINDOW: u32 = 0x08000000;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct UsbDevice {
pub busid: String,
pub vid_pid: String,
pub description: String,
pub state: String,
}
pub fn list_yubikeys() -> Vec<UsbDevice> {
let output = Command::new("usbipd")
.arg("list")
.creation_flags(CREATE_NO_WINDOW)
.output();
match output {
Err(_) => vec![],
Ok(out) => {
let stdout = String::from_utf8_lossy(&out.stdout);
parse_yubikeys(&stdout)
}
}
}
fn parse_yubikeys(output: &str) -> Vec<UsbDevice> {
let mut devices = vec![];
for line in output.lines() {
if !line.contains("1050:") {
continue;
}
let line = line.trim();
let parts: Vec<&str> = line.split_whitespace().collect();
if parts.len() < 3 { continue; }
let busid = parts[0].to_string();
let vid_pid = parts[1].to_string();
let state_raw = parts.last().unwrap_or(&"").to_string();
let state = if state_raw == "Attached" {
"WSL2".to_string()
} else {
"Windows".to_string()
};
devices.push(UsbDevice {
busid,
vid_pid,
description: "YubiKey 5".to_string(),
state,
});
}
devices
}
pub fn attach_to_wsl(busid: &str) -> Result<(), Box<dyn std::error::Error>> {
let status = Command::new("usbipd")
.args(["attach", "--wsl", "--busid", busid])
.creation_flags(CREATE_NO_WINDOW)
.status()?;
if status.success() { Ok(()) }
else { Err("Échec attach usbipd".into()) }
}
pub fn detach(busid: &str) -> Result<(), Box<dyn std::error::Error>> {
let status = Command::new("usbipd")
.args(["detach", "--busid", busid])
.creation_flags(CREATE_NO_WINDOW)
.status()?;
if status.success() { Ok(()) }
else { Err("Échec detach usbipd".into()) }
}
pub fn ensure_wsl_running() -> Result<(), Box<dyn std::error::Error>> {
Command::new("wsl")
.args(["--distribution", "Ubuntu", "echo", "ready"])
.creation_flags(CREATE_NO_WINDOW)
.output()?;
Ok(())
}
+38
View File
@@ -0,0 +1,38 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "YubiSwitch",
"version": "0.1.0",
"identifier": "com.enuxia.yubiswitch",
"build": {
"beforeDevCommand": "npm run dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "npm run build",
"frontendDist": "../dist"
},
"app": {
"withGlobalTauri": true,
"windows": [
{
"title": "YubiSwitch",
"width": 380,
"height": 420,
"resizable": false,
"maximizable": false,
"center": true
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "nsis",
"icon": [
"icons/app-icon.png",
"icons/icon.ico"
],
"publisher": "Enuxia",
"copyright": "© 2026 Enuxia"
}
}
+6
View File
@@ -0,0 +1,6 @@
<svg width="206" height="231" viewBox="0 0 206 231" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M143.143 84C143.143 96.1503 133.293 106 121.143 106C108.992 106 99.1426 96.1503 99.1426 84C99.1426 71.8497 108.992 62 121.143 62C133.293 62 143.143 71.8497 143.143 84Z" fill="#FFC131"/>
<ellipse cx="84.1426" cy="147" rx="22" ry="22" transform="rotate(180 84.1426 147)" fill="#24C8DB"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M166.738 154.548C157.86 160.286 148.023 164.269 137.757 166.341C139.858 160.282 141 153.774 141 147C141 144.543 140.85 142.121 140.558 139.743C144.975 138.204 149.215 136.139 153.183 133.575C162.73 127.404 170.292 118.608 174.961 108.244C179.63 97.8797 181.207 86.3876 179.502 75.1487C177.798 63.9098 172.884 53.4021 165.352 44.8883C157.82 36.3744 147.99 30.2165 137.042 27.1546C126.095 24.0926 114.496 24.2568 103.64 27.6274C92.7839 30.998 83.1319 37.4317 75.8437 46.1553C74.9102 47.2727 74.0206 48.4216 73.176 49.5993C61.9292 50.8488 51.0363 54.0318 40.9629 58.9556C44.2417 48.4586 49.5653 38.6591 56.679 30.1442C67.0505 17.7298 80.7861 8.57426 96.2354 3.77762C111.685 -1.01901 128.19 -1.25267 143.769 3.10474C159.348 7.46215 173.337 16.2252 184.056 28.3411C194.775 40.457 201.767 55.4101 204.193 71.404C206.619 87.3978 204.374 103.752 197.73 118.501C191.086 133.25 180.324 145.767 166.738 154.548ZM41.9631 74.275L62.5557 76.8042C63.0459 72.813 63.9401 68.9018 65.2138 65.1274C57.0465 67.0016 49.2088 70.087 41.9631 74.275Z" fill="#FFC131"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38.4045 76.4519C47.3493 70.6709 57.2677 66.6712 67.6171 64.6132C65.2774 70.9669 64 77.8343 64 85.0001C64 87.1434 64.1143 89.26 64.3371 91.3442C60.0093 92.8732 55.8533 94.9092 51.9599 97.4256C42.4128 103.596 34.8505 112.392 30.1816 122.756C25.5126 133.12 23.9357 144.612 25.6403 155.851C27.3449 167.09 32.2584 177.598 39.7906 186.112C47.3227 194.626 57.153 200.784 68.1003 203.846C79.0476 206.907 90.6462 206.743 101.502 203.373C112.359 200.002 122.011 193.568 129.299 184.845C130.237 183.722 131.131 182.567 131.979 181.383C143.235 180.114 154.132 176.91 164.205 171.962C160.929 182.49 155.596 192.319 148.464 200.856C138.092 213.27 124.357 222.426 108.907 227.222C93.458 232.019 76.9524 232.253 61.3736 227.895C45.7948 223.538 31.8055 214.775 21.0867 202.659C10.3679 190.543 3.37557 175.59 0.949823 159.596C-1.47592 143.602 0.768139 127.248 7.41237 112.499C14.0566 97.7497 24.8183 85.2327 38.4045 76.4519ZM163.062 156.711L163.062 156.711C162.954 156.773 162.846 156.835 162.738 156.897C162.846 156.835 162.954 156.773 163.062 156.711Z" fill="#24C8DB"/>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

+25
View File
@@ -0,0 +1,25 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="512.000000pt" height="512.000000pt" viewBox="0 0 512.000000 512.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0.000000,512.000000) scale(0.100000,-0.100000)"
fill="#2D79C7" stroke="none">
<path d="M430 5109 c-130 -19 -248 -88 -325 -191 -53 -71 -83 -147 -96 -247
-6 -49 -9 -813 -7 -2166 l3 -2090 22 -65 c54 -159 170 -273 328 -323 l70 -22
2140 0 2140 0 66 23 c160 55 272 169 322 327 l22 70 0 2135 0 2135 -22 70
c-49 157 -155 265 -319 327 l-59 23 -2115 1 c-1163 1 -2140 -2 -2170 -7z
m3931 -2383 c48 -9 120 -26 160 -39 l74 -23 3 -237 c1 -130 0 -237 -2 -237 -3
0 -26 14 -53 30 -61 38 -197 84 -310 106 -110 20 -293 15 -368 -12 -111 -39
-175 -110 -175 -193 0 -110 97 -197 335 -300 140 -61 309 -146 375 -189 30
-20 87 -68 126 -107 119 -117 164 -234 164 -426 0 -310 -145 -518 -430 -613
-131 -43 -248 -59 -445 -60 -243 -1 -405 24 -577 90 l-68 26 0 242 c0 175 -3
245 -12 254 -9 9 -9 12 0 12 7 0 12 -4 12 -9 0 -17 139 -102 223 -138 136 -57
233 -77 382 -76 145 0 224 19 295 68 75 52 100 156 59 242 -41 84 -135 148
-374 253 -367 161 -522 300 -581 520 -23 86 -23 253 -1 337 73 275 312 448
682 492 109 13 401 6 506 -13z m-1391 -241 l0 -205 -320 0 -320 0 0 -915 0
-915 -255 0 -255 0 0 915 0 915 -320 0 -320 0 0 205 0 205 895 0 895 0 0 -205z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

+1
View File
@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

+170
View File
@@ -0,0 +1,170 @@
import { invoke } from "@tauri-apps/api/core";
interface UsbDevice {
busid: string;
vid_pid: string;
description: string;
state: string;
}
let isSwitching = false;
let lastKnownDevices: UsbDevice[] = [];
function formatTime(d: Date): string {
return d.toLocaleTimeString("fr-FR", {
hour: "2-digit", minute: "2-digit", second: "2-digit"
});
}
function renderDevices(devices: UsbDevice[]) {
const list = document.getElementById("deviceList")!;
const noDevice = document.getElementById("noDevice")!;
const statusIndicator = document.getElementById("statusIndicator")!;
const statusText = document.getElementById("statusText")!;
const lastRefresh = document.getElementById("lastRefresh")!;
lastRefresh.textContent = formatTime(new Date());
list.innerHTML = "";
if (devices.length === 0) {
noDevice.classList.remove("hidden");
statusIndicator.className = "status-indicator none";
statusText.innerHTML = "Aucune YubiKey détectée";
return;
}
noDevice.classList.add("hidden");
devices.forEach((device) => {
const isWsl = device.state === "WSL2";
statusIndicator.className = `status-indicator ${isWsl ? "wsl" : "windows"}`;
statusText.innerHTML = isSwitching
? "Basculement en cours…"
: `YubiKey active sur <span>${isWsl ? "WSL2" : "Windows"}</span>`;
const card = document.createElement("div");
card.className = "card";
card.innerHTML = `
<div class="card-header">
<div class="yubikey-icon">🔑</div>
<div class="device-info">
<div class="device-name">${device.description}</div>
<div class="device-meta">${device.busid} · ${device.vid_pid}</div>
</div>
</div>
<div class="toggle-row">
<span class="toggle-label ${!isWsl ? "active" : ""}">Windows</span>
<div class="toggle ${isWsl ? "wsl" : "windows"}"
id="toggle-${device.busid}"
data-busid="${device.busid}"
data-state="${device.state}"
style="cursor: ${isSwitching ? "wait" : "pointer"}; opacity: ${isSwitching ? "0.5" : "1"}">
<div class="toggle-thumb"></div>
</div>
<span class="toggle-label ${isWsl ? "active" : ""}">WSL2</span>
</div>
<p class="toggle-hint">${
isSwitching
? "Basculement…"
: isWsl
? "Cliquez pour revenir sur Windows"
: "Cliquez pour basculer vers WSL2"
}</p>
`;
list.appendChild(card);
});
if (!isSwitching) {
document.querySelectorAll(".toggle[data-busid]").forEach((el) => {
el.addEventListener("click", async () => {
const busid = (el as HTMLElement).dataset.busid!;
const state = (el as HTMLElement).dataset.state!;
await switchDevice(busid, state);
});
});
}
}
async function switchDevice(busid: string, currentState: string) {
if (isSwitching) return;
isSwitching = true;
renderDevices(lastKnownDevices);
try {
if (currentState === "WSL2") {
await invoke("detach_yubikey", { busid });
} else {
await invoke("attach_yubikey", { busid });
}
await invoke("notify_state_changed");
} catch (err) {
console.error(err);
}
await new Promise(resolve => setTimeout(resolve, 2000));
isSwitching = false;
await loadDevices();
}
async function loadDevices() {
const devices: UsbDevice[] = await invoke("get_yubikeys");
if (devices.length === 0 && lastKnownDevices.length > 0 && isSwitching) {
return;
}
if (devices.length > 0) {
lastKnownDevices = devices;
renderDevices(devices);
} else if (!isSwitching) {
renderDevices([]);
}
const displayDevices = devices.length > 0
? devices
: !isSwitching ? [] : lastKnownDevices;
renderDevices(displayDevices);
}
async function setupAutostart() {
const toggle = document.getElementById("autostartToggle")!;
const status = document.getElementById("autostartStatus")!;
const updateToggle = async () => {
const enabled = await invoke<boolean>("is_autostart_enabled");
toggle.className = `toggle-small ${enabled ? "on" : "off"}`;
status.textContent = enabled ? "activé" : "";
status.style.color = enabled ? "rgba(30,144,255,0.7)" : "";
};
await updateToggle();
toggle.addEventListener("click", async () => {
const enabled = await invoke<boolean>("is_autostart_enabled");
if (enabled) {
await invoke("disable_autostart");
} else {
await invoke("enable_autostart");
}
await updateToggle();
});
}
const style = document.createElement("style");
style.textContent = `
.toggle-hint {
font-size: 10px;
color: rgba(255,255,255,0.25);
text-align: center;
margin-top: 6px;
letter-spacing: 0.02em;
}
`;
document.head.appendChild(style);
loadDevices();
setupAutostart();
setInterval(loadDevices, 3000);
+320
View File
@@ -0,0 +1,320 @@
@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap");
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Space Grotesk', sans-serif;
background: rgb(26, 26, 26);
color: rgba(255, 255, 255, 0.88);
min-height: 100vh;
padding: 16px;
}
.container {
max-width: 340px;
margin: 0 auto;
}
/* HEADER */
.header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 20px;
padding-bottom: 14px;
border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}
.logo {
display: flex;
align-items: center;
gap: 8px;
flex: 1;
}
.logo-dot {
width: 28px;
height: 28px;
border-radius: 8px;
background: rgba(30, 144, 255, 0.15);
border: 1px solid rgba(30, 144, 255, 0.3);
display: flex;
align-items: center;
justify-content: center;
}
.logo-dot svg {
width: 14px;
height: 14px;
}
.logo-name {
font-size: 14px;
font-weight: 700;
color: rgba(255, 255, 255, 0.97);
letter-spacing: 0.02em;
}
.logo-sub {
font-size: 10px;
color: rgba(255, 255, 255, 0.40);
letter-spacing: 0.05em;
text-transform: uppercase;
}
.version {
font-size: 10px;
color: rgba(255, 255, 255, 0.30);
letter-spacing: 0.05em;
}
/* STATUS BAR */
.status-bar {
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 16px;
padding: 8px 12px;
background: rgba(255, 255, 255, 0.04);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 0.5rem;
}
.status-indicator {
width: 6px;
height: 6px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.20);
flex-shrink: 0;
transition: background 0.3s ease;
}
.status-indicator.windows { background: #1E90FF; box-shadow: 0 0 6px rgba(30, 144, 255, 0.5); }
.status-indicator.wsl { background: #8B5CF6; box-shadow: 0 0 6px rgba(139, 92, 246, 0.5); }
.status-indicator.none { background: rgba(255,255,255,0.2); }
.status-text {
font-size: 11px;
color: rgba(255, 255, 255, 0.50);
flex: 1;
}
.status-text span {
color: rgba(255, 255, 255, 0.80);
font-weight: 600;
}
.last-refresh {
font-size: 10px;
color: rgba(255, 255, 255, 0.25);
}
/* CARD */
.card {
background: rgba(255, 255, 255, 0.06);
border: 1px solid rgba(255, 255, 255, 0.10);
border-radius: 1rem;
padding: 16px;
margin-bottom: 12px;
transition: border-color 0.2s ease;
}
.card:hover {
border-color: rgba(255, 255, 255, 0.14);
}
.card-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 14px;
}
.yubikey-icon {
width: 36px;
height: 36px;
border-radius: 10px;
background: rgba(30, 144, 255, 0.10);
border: 1px solid rgba(30, 144, 255, 0.20);
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
flex-shrink: 0;
}
.device-info { flex: 1; }
.device-name {
font-size: 13px;
font-weight: 700;
color: rgba(255, 255, 255, 0.97);
}
.device-meta {
font-size: 11px;
color: rgba(255, 255, 255, 0.40);
margin-top: 2px;
}
/* TOGGLE ROW */
.toggle-row {
display: flex;
align-items: center;
gap: 12px;
margin-bottom: 14px;
padding: 10px 12px;
background: rgba(0, 0, 0, 0.25);
border-radius: 0.75rem;
border: 1px solid rgba(255, 255, 255, 0.06);
}
.toggle-label {
font-size: 12px;
font-weight: 600;
color: rgba(255, 255, 255, 0.35);
min-width: 52px;
transition: color 0.2s ease;
}
.toggle-label.active {
color: rgba(255, 255, 255, 0.90);
}
.toggle {
width: 44px;
height: 24px;
border-radius: 999px;
position: relative;
cursor: pointer;
transition: background 0.25s ease;
border: 1px solid rgba(255,255,255,0.08);
flex-shrink: 0;
}
.toggle.windows { background: rgba(30, 144, 255, 0.70); }
.toggle.wsl { background: rgba(139, 92, 246, 0.70); }
.toggle-thumb {
width: 18px;
height: 18px;
background: white;
border-radius: 50%;
position: absolute;
top: 2px;
transition: left 0.25s ease;
box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.toggle.windows .toggle-thumb { left: 2px; }
.toggle.wsl .toggle-thumb { left: 22px; }
/* SWITCH BTN */
.switch-btn {
width: 100%;
padding: 10px;
font-family: 'Space Grotesk', sans-serif;
font-size: 12px;
font-weight: 700;
border-radius: 0.5rem;
cursor: pointer;
transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
letter-spacing: 0.02em;
border: 1px solid rgba(255, 255, 255, 0.12);
background: rgba(255, 255, 255, 0.08);
color: rgba(255, 255, 255, 0.90);
}
.switch-btn:hover { background: rgba(255, 255, 255, 0.13); }
.switch-btn:active { transform: translateY(1px); }
.switch-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.switch-btn.to-wsl {
background: rgba(30, 144, 255, 0.12);
border-color: rgba(30, 144, 255, 0.25);
color: rgba(30, 144, 255, 0.95);
}
.switch-btn.to-wsl:hover { background: rgba(30, 144, 255, 0.20); }
.switch-btn.to-windows {
background: rgba(139, 92, 246, 0.12);
border-color: rgba(139, 92, 246, 0.25);
color: rgba(139, 92, 246, 0.95);
}
.switch-btn.to-windows:hover { background: rgba(139, 92, 246, 0.20); }
/* NO DEVICE */
.no-device {
text-align: center;
padding: 32px 16px;
background: rgba(255, 255, 255, 0.03);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: 1rem;
}
.no-device-icon {
font-size: 28px;
margin-bottom: 10px;
opacity: 0.4;
}
.no-device p {
font-size: 13px;
color: rgba(255, 255, 255, 0.40);
}
/* FOOTER */
.footer {
display: flex;
align-items: center;
justify-content: space-between;
margin-top: 8px;
padding-top: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.autostart-row {
display: flex;
align-items: center;
gap: 8px;
}
.autostart-label {
font-size: 11px;
color: rgba(255, 255, 255, 0.40);
}
.toggle-small {
width: 32px;
height: 18px;
border-radius: 999px;
background: rgba(255, 255, 255, 0.12);
position: relative;
cursor: pointer;
transition: background 0.2s ease;
border: 1px solid rgba(255,255,255,0.08);
}
.toggle-small.on { background: rgba(30, 144, 255, 0.60); }
.toggle-small-thumb {
width: 13px;
height: 13px;
background: white;
border-radius: 50%;
position: absolute;
top: 2px;
transition: left 0.2s ease;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.toggle-small.off .toggle-small-thumb { left: 2px; }
.toggle-small.on .toggle-small-thumb { left: 16px; }
.hidden { display: none; }
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}
+30
View File
@@ -0,0 +1,30 @@
import { defineConfig } from "vite";
// @ts-expect-error process is a nodejs global
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent Vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));