summaryrefslogtreecommitdiff
path: root/scripts/verify-tridactyl-config.ps1
blob: afa5ccbbf58cd972ee6a721003c1925f942df3b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# Script pour verifier la configuration Tridactyl
# Verifie que les fichiers de configuration sont au bon endroit et accessibles

$ErrorActionPreference = "Continue"

Write-Host "=== Verification de la configuration Tridactyl ===" -ForegroundColor Cyan
Write-Host ""

# 1. Verifier le fichier tridactyl.json pour le native messenger
Write-Host "1. Verification du Native Messenger (tridactyl.json)..." -ForegroundColor Yellow

$nativeMessengerPath = "$env:APPDATA\Mozilla\NativeMessagingHosts\tridactyl.json"
$sourcePath = "$env:USERPROFILE\.tridactyl\tridactyl.json"

if (Test-Path $nativeMessengerPath) {
    Write-Host "   [OK] Fichier trouve: $nativeMessengerPath" -ForegroundColor Green
    
    # Verifier le contenu
    try {
        $content = Get-Content $nativeMessengerPath -Raw | ConvertFrom-Json
        Write-Host "   [OK] Fichier JSON valide" -ForegroundColor Green
        Write-Host "   - Nom: $($content.name)" -ForegroundColor Gray
        Write-Host "   - Type: $($content.type)" -ForegroundColor Gray
        
        # Verifier que le path pointe vers un executable valide
        if ($content.path) {
            $exePath = $content.path
            # Si c'est un chemin relatif, chercher dans le repertoire .tridactyl
            if (-not [System.IO.Path]::IsPathRooted($exePath)) {
                $fullExePath = Join-Path (Split-Path $sourcePath -Parent) $exePath
            } else {
                $fullExePath = $exePath
            }
            
            if (Test-Path $fullExePath) {
                Write-Host "   [OK] Executable trouve: $fullExePath" -ForegroundColor Green
            } else {
                Write-Host "   [ERREUR] Executable introuvable: $fullExePath" -ForegroundColor Red
            }
        }
    } catch {
        Write-Host "   [ERREUR] Erreur lors de la lecture du JSON: $_" -ForegroundColor Red
    }
} else {
    Write-Host "   [ERREUR] Fichier introuvable: $nativeMessengerPath" -ForegroundColor Red
    Write-Host "   -> Le fichier doit etre copie depuis: $sourcePath" -ForegroundColor Yellow
    
    if (Test-Path $sourcePath) {
        Write-Host "   -> Voulez-vous creer le lien maintenant? (O/N)" -ForegroundColor Yellow
        $response = Read-Host
        if ($response -eq 'O' -or $response -eq 'o') {
            $nativeDir = Split-Path $nativeMessengerPath -Parent
            if (-not (Test-Path $nativeDir)) {
                New-Item -ItemType Directory -Path $nativeDir -Force | Out-Null
                Write-Host "   [OK] Repertoire cree: $nativeDir" -ForegroundColor Green
            }
            Copy-Item -Path $sourcePath -Destination $nativeMessengerPath -Force
            Write-Host "   [OK] Fichier copie vers: $nativeMessengerPath" -ForegroundColor Green
        }
    } else {
        Write-Host "   [ERREUR] Fichier source introuvable: $sourcePath" -ForegroundColor Red
    }
}

Write-Host ""

# 2. Verifier le fichier .tridactylrc
Write-Host "2. Verification du fichier de configuration (.tridactylrc)..." -ForegroundColor Yellow

$tridactylrcPath = "$env:USERPROFILE\.tridactylrc"

if (Test-Path $tridactylrcPath) {
    Write-Host "   [OK] Fichier trouve: $tridactylrcPath" -ForegroundColor Green
    
    $lineCount = (Get-Content $tridactylrcPath | Measure-Object -Line).Lines
    Write-Host "   - Nombre de lignes: $lineCount" -ForegroundColor Gray
    
    # Afficher un apercu
    $preview = Get-Content $tridactylrcPath -First 5
    if ($preview) {
        Write-Host "   Apercu (5 premieres lignes):" -ForegroundColor Gray
        foreach ($line in $preview) {
            Write-Host "     $line" -ForegroundColor DarkGray
        }
    }
} else {
    Write-Host "   [ATTENTION] Fichier introuvable: $tridactylrcPath" -ForegroundColor Yellow
    Write-Host "   -> Ce fichier est optionnel mais recommande pour personnaliser Tridactyl" -ForegroundColor Gray
    Write-Host "   -> Vous pouvez le creer avec des commandes comme:" -ForegroundColor Gray
    Write-Host "     set searchengine google" -ForegroundColor DarkGray
    Write-Host "     bind J tabnext" -ForegroundColor DarkGray
    Write-Host "     bind K tabprev" -ForegroundColor DarkGray
}

Write-Host ""

# 3. Instructions pour verifier dans Firefox
Write-Host "3. Instructions pour verifier dans Firefox:" -ForegroundColor Yellow
Write-Host "   a) Ouvrez Firefox" -ForegroundColor Gray
Write-Host "   b) Appuyez sur ':' pour ouvrir la ligne de commande Tridactyl" -ForegroundColor Gray
Write-Host "   c) Tapez ':version' pour voir la version de Tridactyl" -ForegroundColor Gray
Write-Host "   d) Tapez ':native' pour verifier la connexion au native messenger" -ForegroundColor Gray
Write-Host "   e) Tapez ':source' pour recharger la configuration depuis .tridactylrc" -ForegroundColor Gray
Write-Host "   f) Tapez ':get searchengine' pour voir le moteur de recherche configure" -ForegroundColor Gray

Write-Host ""
Write-Host "=== Verification terminee ===" -ForegroundColor Cyan