Skip to content

armgit / WacOS

Public Imported from GitHub
0

A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.

Rust

English by default; English README, release notes and updater messages

Eternity070628b2f73957156a
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index bf8f93f..4b3eacd 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -1,6 +1,7 @@
-# A cada commit na main: compila o WacOS (build.cmd + a barra das janelas de 32/64 bits), grava a versão em
-# bin\versao.txt e publica o pacote de atualização como a versão "latest" do GitHub. O botão "Atualizar Agora"
-# do Ajustes (tools\atualizar-github.ps1) compara essa versão com a instalada e baixa só quando há novidade.
+# On every commit to main: build WacOS (build.cmd plus the 32/64-bit title bar DLLs), write the version to
+# bin\versao.txt and publish the update package as the "latest" GitHub release. The "Update Now" button in
+# System Settings (tools\atualizar-github.ps1) compares that version with the installed one and downloads it
+# only when there is something new.
name: build
on:
@@ -23,8 +24,8 @@ jobs:
with:
fetch-depth: 0
- - name: Versão
- id: versao
+ - name: Version
+ id: version
shell: pwsh
run: |
$tag = "build-${{ github.run_number }}"
@@ -32,26 +33,26 @@ jobs:
Set-Content -Encoding utf8 bin\versao.txt @($tag, "${{ github.sha }}", (Get-Date -Format 'yyyy-MM-dd HH:mm'))
"tag=$tag" >> $env:GITHUB_OUTPUT
- - name: Compilar
+ - name: Build
shell: cmd
run: |
call build.cmd || exit /b 1
call build.cmd janelas || exit /b 1
- - name: Empacotar
+ - name: Package
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
powershell -NoProfile -ExecutionPolicy Bypass -File tools\empacotar.ps1 -SemSistema -Atualizacao -Zip "$PWD\dist\WacOS.zip"
- if (-not (Test-Path dist\WacOS.zip)) { throw 'o pacote não foi gerado' }
+ if (-not (Test-Path dist\WacOS.zip)) { throw 'the package was not created' }
- - name: Publicar
+ - name: Publish
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
- $tag = "${{ steps.versao.outputs.tag }}"
- $antes = git describe --tags --abbrev=0 HEAD~1 2>$null
- $notas = if ($antes) { git log --pretty=format:'- %s' "$antes..HEAD" } else { git log -20 --pretty=format:'- %s' }
- Set-Content -Encoding utf8 notas.md $notas
- gh release create $tag dist\WacOS.zip --title "WacOS $tag" --notes-file notas.md --latest
+ $tag = "${{ steps.version.outputs.tag }}"
+ $prev = git describe --tags --abbrev=0 HEAD~1 2>$null
+ $notes = if ($prev) { git log --pretty=format:'- %s' "$prev..HEAD" } else { git log -20 --pretty=format:'- %s' }
+ Set-Content -Encoding utf8 notes.md $notes
+ gh release create $tag dist\WacOS.zip --title "WacOS $tag" --notes-file notes.md --latest
diff --git a/.gitignore b/.gitignore
index c094ace..3642dc3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,16 +4,16 @@ bin/
*.ilk
*.log
-# sons do macOS (Apple, uso pessoal: não distribuir)
+# macOS sounds (Apple, personal use: do not distribute)
sons/mac/
arquivo-morto/
dist/
-# arquivo vazio criado por engano
+# empty file created by mistake, and the release notes written by the build
função)
-notas.md
+notes.md
-# fora do GitHub: outro projeto (áudios) e binários de terceiros guardados para estudo
+# kept out of GitHub: another project (audio files) and third-party binaries kept for study
vocal-test/
docs/vm-barra/
docs/**/*.dll
diff --git a/README.md b/README.md
index 97a46a9..28846d2 100644
--- a/README.md
+++ b/README.md
@@ -1,56 +1,71 @@
-# shell-proprio
+# WacOS
-Shell próprio para Windows com comportamento e visual inspirados no macOS, rodando por cima
-do Windows (kernel, drivers e apps continuam os mesmos). Nada aqui altera o registro nem
-substitui o Explorer: tudo roda como app comum ao lado dele.
+A macOS-style desktop shell for Windows 11. WacOS runs on top of Windows (same kernel, drivers and apps) and
+replaces what you see and touch: the menu bar, the Dock, Finder, Spotlight, Control Center, Notification Center,
+Mission Control, Launchpad, window title bars and a set of built-in apps. It supports the macOS Sequoia look and
+the macOS Tahoe look with Liquid Glass.
-## Programas
-- `bin\Arquivos.exe [pasta]`: gerenciador de arquivos no estilo do Finder (visão de ícones).
-- `bin\MenuTeste.exe [pasta]`: bancada do menu de contexto (`--dump <caminho> [--bg]` grava a árvore do menu no log).
+Everything is native C++ (Win32, Direct2D, DirectComposition). No Electron, no web views.
-## Compilar
-Precisa do Visual Studio Build Tools 2022 com C++.
+## Features
-```
-build.cmd (tudo)
-build.cmd finder (só Arquivos.exe)
-build.cmd menu (só MenuTeste.exe)
-```
+- **Menu bar** with the active app's real menus, the Apple menu, status icons and the system tray.
+- **Dock** with magnification, running indicators, stacks (Downloads), minimized windows and the Trash.
+- **Finder** (file manager), **Spotlight** (search with Applications, Files, Actions and Clipboard modes),
+ **Control Center**, **Notification Center**, **Mission Control**, **Launchpad / Apps**, **Quick Look**,
+ **Stage Manager** and **Hot Corners**.
+- **Mac title bars** (traffic lights, rounded corners, shadows) on other apps' windows.
+- **macOS alerts** in place of Windows message boxes, and the Mac Open/Save panel through Finder.
+- **Built-in apps**: System Settings, Activity Monitor (with memory pressure), Terminal, Calculator, Notes,
+ Reminders, Calendar, TextEdit, Preview, Photos, Music, QuickTime Player, Clock, Weather, Contacts,
+ Time Machine, Screenshot and Force Quit.
+- **Memory management like macOS**: memory pressure, App Nap and purgeable memory.
+- **Icon styles** (Default, Dark, Clear, Tinted), accent colors, light and dark appearance.
+- **English and Portuguese** interface (English is the default; System Settings > General > Language).
+
+## Install
+
+1. Download `WacOS.zip` from the [latest release](../../releases/latest).
+2. Extract it anywhere and run `instalar.cmd`.
+
+WacOS installs for your user only (no administrator rights) in `%LOCALAPPDATA%\Programs\WacOS`.
+Everything it changes is logged in `instalacao.log` there, and `desinstalar.cmd` undoes it.
+
+- Quit WacOS: `Ctrl+Alt+Shift+F12`. Emergency exit (brings Explorer back): `Ctrl+Alt+Shift+F11`.
+
+## Updates
+
+Every commit to `main` is built by GitHub Actions and published as the latest release, with its build number
+in `bin\versao.txt`. In **System Settings > General > Software Update**, WacOS checks GitHub on its own, shows the
+installed version, the latest one and the commits you don't have yet, and **Update Now** downloads and installs it
+(only programs, icons and sounds are replaced; your settings stay).
+
+While the repository is private, each PC needs a GitHub token with read access saved in
+`%APPDATA%\Shell\github-token.txt`.
+
+## Build
+
+Requires Visual Studio 2022 (or Build Tools 2022) with the C++ workload.
-## Estrutura
-- `src/menu`: menu de contexto próprio sobre as extensões reais do Windows (IContextMenu).
-- `src/finder`: Arquivos (Direct2D sobre DirectComposition, acrílico do DWM).
-- `src/tools`: bancadas de teste.
-- `docs/problemas-conhecidos.md`: o que ainda falta ou é limitação do Windows.
-
-## Atalhos do Arquivos
-| Ação | Tecla |
-|---|---|
-| Abrir | duplo clique, Ctrl+O, Ctrl+↓ |
-| Pasta de cima | Ctrl+↑ |
-| Voltar / avançar | Alt+← / Alt+→, Ctrl+[ / Ctrl+], Backspace, botões laterais do mouse |
-| Renomear | Enter ou F2 |
-| Nova pasta | Ctrl+Shift+N |
-| Copiar / recortar / colar | Ctrl+C / Ctrl+X / Ctrl+V |
-| Mover para a Lixeira | Delete ou Ctrl+Backspace |
-| Propriedades | Ctrl+I ou Alt+Enter |
-| Buscar (no computador todo ou na pasta, pela barra "Buscar:") | Ctrl+F; Esc ou Voltar sai da busca |
-| Nova janela | Ctrl+N |
-| Nova aba / fechar aba / próxima aba | Ctrl+T / Ctrl+W / Ctrl+Tab; Ctrl+duplo clique abre a pasta em nova aba; botão do meio fecha |
-| Quick Look | Espaço |
-| Opções de Visualização | Ctrl+J |
-| Menu com itens extras | Alt+clique direito; todas as opções: Shift+clique direito |
-| Visões: ícones / lista / colunas / galeria | Ctrl+1 / Ctrl+2 / Ctrl+3 / Ctrl+4 |
-| Tamanho dos ícones | Ctrl+ / Ctrl− |
-| Adicionar pasta à barra lateral | Ctrl+Alt+T, ou arrastar a pasta para entre dois favoritos |
-| Mover / remover favorito | arrastar na barra lateral / clique direito → Remover da Barra Lateral |
-| Etiquetar | botão de etiqueta, ou arrastar os itens para uma etiqueta da barra lateral |
-
-## Arquivos como padrão para abrir pastas (opcional, reversível)
-Grava só em HKCU (verbo `arquivos` em `Directory` e `Drive`, e o comando de nova janela do Explorador, usado pelo Win+E); o valor anterior fica em `%APPDATA%\Arquivos\padrao-backup.txt`.
```
-bin\Arquivos.exe --padrao status
-bin\Arquivos.exe --padrao on
-bin\Arquivos.exe --padrao off
+build.cmd everything
+build.cmd shell the shell only (WacOSShell.exe: menu bar, Dock, Spotlight...)
+build.cmd finder Finder only
+build.cmd janelas Mac title bars for other apps (WacOSWindow.dll, 32 and 64 bit)
+tools\empacotar.ps1 the installer package (dist\WacOS-<date>.zip)
```
-"Este Computador" e `shell:Downloads` e afins abrem no Arquivos. Lixeira, Painel de Controle e outras pastas virtuais ainda abrem no Explorador.
+
+## Layout
+
+- `src/shell`: the shell (menu bar, Dock, Spotlight, Control Center, Mission Control, Liquid Glass...).
+- `src/finder`, `src/ajustes` (System Settings), `src/monitor` (Activity Monitor) and the other apps in `src/*`.
+- `src/janelas`: Mac title bars injected into other apps' windows.
+- `src/menu`: context menus on top of the real Windows shell extensions.
+- `src/comum`: shared code (names, language, glass, shadows).
+- `instalador`: install, update and uninstall scripts. `tools`: build and packaging tools.
+- `icones`: icon packs (Sequoia, Tahoe) and SF Symbols.
+
+## Note
+
+Apple, macOS, Finder and related names and icons belong to Apple Inc. This is a personal, non-commercial project
+and is not affiliated with Apple. The bundled icons, fonts and sounds are for personal use only.
diff --git a/docs/registro-mudancas.txt b/docs/registro-mudancas.txt
index 805c8eb..6e7b57f 100644
--- a/docs/registro-mudancas.txt
+++ b/docs/registro-mudancas.txt
@@ -539,3 +539,5 @@ Compilado (tudo), instalado, Shell e reserva do Finder reiniciados às 23:07 sem
[2026-11-16 23:15 PC] (1) Borda dos vidros/menus (comum\vidro.h Borda): reflexo dos cantos de 0,95/0,50 para 0,42/0,20 e o fio em volta de 0,07 para 0,16 (escuro): fio fino quase uniforme como no macOS 26. (2) Dock no escuro (dock.cpp PaintBack): tinta de cinza 0,28 a 39% para preto 0,02 a 39%; sobre fundo preto o Dock mede 14/255 (o do Mac no print do usuário: 12; antes ~30). (3) Transparente escuro: Lixeira e pasta do Dock em tons de cinza (dock.cpp PackBitmap), como no print do Mac. Conferido numa foto com janela preta atrás do Dock (estilo trocado para transparente e devolvido para padrao, conferido). Build completo + janelas, instalado, Shell reiniciado. Desfazer: voltar os números em Borda, tirar a linha "TAHOE_DOCK && dark" e o bloco gray em PackBitmap.
[2026-11-16 23:24 PC] DOCK COMPARADO COM O DO MAC SOBRE PRETO (print do usuário medido pixel a pixel): (1) brilho da borda do vidro real (backdrop.cpp SpecFor): luz vindo de cima (antes da diagonal: acendia o lado esquerdo), embaixo um pouco mais forte, brilho suave de até 6 px, ganho 0,80 no escuro. Medido: topo 74 (Mac 78), embaixo 80 (Mac 91), lados 21 (Mac 13). (2) Transparente escuro (ui.cpp GlassIcon): peça do ícone quase preta (0,05 a 50%); medido 15 (Mac 16; antes 30). Instalado, Shell reiniciado; estilo devolvido para padrao (conferido).
+
+[2026-11-16 23:45 PC] NOME NOVO: WacOS (antes Sequoia Shell), a pedido do usuário ("o nome de tudo, até dos .exe e das dlls"). (1) Programas: SequoiaX.exe/.dll viraram WacOSX.exe/.dll (nomes.h, build.cmd, recursos.ps1, instalador, empacotar; zip dist\WacOS-data.zip; pasta de instalação %LOCALAPPDATA%\Programs\WacOS; tarefa do login "WacOS"; atalho "WacOS.lnk"). Ficaram com o nome velho, de propósito: o tema Sequoia (é o nome do macOS), os ProgIDs SequoiaMusic.Audio/SequoiaQuickTime.Video e a chave HKCU\Software\SequoiaShell (trocar desfaria as associações de arquivo), classes de janela e mensagens internas. (2) src\shell\migrar.cpp: WacOSShell rodando como SequoiaShell.exe passa para o WacOSShell.exe ao lado; ao abrir, corrige no registro (HKCU) os caminhos com o nome velho quando o arquivo novo existe (Winlogon Shell, Run, .zip e Win+E do Finder, Música, QuickTime, diálogos) e troca a tarefa SequoiaShell por WacOS (uma vez, ajuste wacos_tarefa). Neste PC: 11 caminhos corrigidos (log), Winlogon Shell = ...in\WacOSShell.exe (conferido), tarefa WacOS -> Programs\WacOSin\WacOSShell.exe. Instalação nova em Programs\WacOS; da Programs\SequoiaShell só saíram os Sequoia*.exe/dll (para SequoiaBinariosAntigos): cursor\ e o resto ficam lá porque o cursor do Mac no registro aponta para eles. Atalho Sequoia Shell.lnk trocado por WacOS.lnk. instalar.ps1 faz o mesmo nos outros PCs. (3) GITHUB: repositório PRIVADO github.com/renzyxx/WacOS (branch main, commit c57218e; fora: bin, dist, sons/mac, vocal-test, docs/vm-barra e .dll/.exe de docs). .github\workflowsuild.yml: a cada commit na main compila (build.cmd achando o VS pelo vswhere), grava bin ersao.txt (build-N, commit, data) e publica dist\WacOS.zip como versão latest (empacotar.ps1 -Atualizacao). (4) Ajustes > Geral > Atualização de Software: confere sozinho ao abrir (versão instalada, a mais nova, os commits que faltam) e mostra "Atualizar Agora" só quando há novidade; toolstualizar-github.ps1 baixa, extrai e roda instalar.ps1 -Atualizar -Silencioso (novo: sem perguntas). Repositório privado: precisa de token em %APPDATA%\Shell\github-token.txt em cada PC (ou tornar o repositório público). Desfazer o nome: migrar.cpp tem os mapeamentos; os valores antigos estão no shell.log de 23:35.
diff --git a/src/ajustes/paginas.cpp b/src/ajustes/paginas.cpp
index a9a3f8c..35edfe0 100644
--- a/src/ajustes/paginas.cpp
+++ b/src/ajustes/paginas.cpp
@@ -555,7 +555,7 @@ Page Geral() {
Link(L"Itens de Início", [] { Push(L"Itens de Início", Inicio); }, 0xE8FD, C_GRAY) }));
// Idioma do WacOS (idioma=pt|en no ajustes.txt): o Shell troca na hora; este app também;
// os outros apps abertos leem o idioma ao abrir.
- Row lang = Popup(L"Idioma", { L"Português", L"English" }, [] { return Setting(L"idioma", L"pt") == L"en" ? 1 : 0; },
+ Row lang = Popup(L"Idioma", { L"Português", L"English" }, [] { return Setting(L"idioma", L"en") == L"en" ? 1 : 0; },
[](int i) {
SetSetting(L"idioma", i == 1 ? L"en" : L"pt");
idioma::Set(i == 1);
diff --git a/src/comum/idioma.h b/src/comum/idioma.h
index 655566d..4b848aa 100644
--- a/src/comum/idioma.h
+++ b/src/comum/idioma.h
@@ -1,5 +1,5 @@
#pragma once
-// Idioma da interface (Ajustes do Sistema > Geral > Idioma): `idioma=pt` (padrão) ou `idioma=en` em
+// Idioma da interface (Ajustes do Sistema > Geral > Idioma): `idioma=en` (padrão desde 16/11/2026) ou `idioma=pt` em
// %APPDATA%\Shell\ajustes.txt. O texto fica escrito em português no código e passa por Tr():
// Tr(L"Abrir") -> L"Open" com idioma=en, L"Abrir" com idioma=pt
// swprintf(buf, Tr(L"%d itens"), n) -> o formato traduzido tem os mesmos %d/%ls, na mesma ordem
@@ -20,10 +20,10 @@ inline int g_en = -1; // -1 = ainda não leu o ajustes.txt
inline bool ReadFile() {
wchar_t ad[MAX_PATH];
DWORD n = GetEnvironmentVariableW(L"APPDATA", ad, MAX_PATH);
- if (!n || n >= MAX_PATH) return false;
+ if (!n || n >= MAX_PATH) return true; // inglês é o padrão
FILE* f = nullptr;
- if (_wfopen_s(&f, (std::wstring(ad) + L"\\Shell\\ajustes.txt").c_str(), L"r, ccs=UTF-8") || !f) return false;
- bool en = false;
+ if (_wfopen_s(&f, (std::wstring(ad) + L"\\Shell\\ajustes.txt").c_str(), L"r, ccs=UTF-8") || !f) return true;
+ bool en = true; // sem a linha idioma=: inglês
wchar_t line[512];
while (fgetws(line, 512, f)) {
if (wcsncmp(line, L"idioma=", 7) == 0) en = line[7] == L'e' && line[8] == L'n';
diff --git a/src/shell/apps.cpp b/src/shell/apps.cpp
index 5093432..4906691 100644
--- a/src/shell/apps.cpp
+++ b/src/shell/apps.cpp
@@ -84,7 +84,7 @@ static std::wstring AumidOfWindow(HWND h) {
// Vazio: não é um dos nossos.
static std::wstring OurName(const std::wstring& exe) {
std::wstring f = Lower(exe.substr(exe.find_last_of(L'\\') + 1));
- bool en = shell::Setting(L"idioma", L"pt") == L"en";
+ bool en = shell::Setting(L"idioma", L"en") == L"en";
struct N { const wchar_t* exe; const wchar_t* pt; const wchar_t* en; };
static const N names[] = {
{ L"wacosfinder.exe", L"Finder", L"Finder" },
diff --git a/src/shell/main.cpp b/src/shell/main.cpp
index 255130c..286c5cc 100644
--- a/src/shell/main.cpp
+++ b/src/shell/main.cpp
@@ -712,7 +712,7 @@ static LRESULT CALLBACK MsgProc(HWND h, UINT m, WPARAM w, LPARAM l) {
LoadSettings();
static int lastEn = -1;
if (lastEn < 0) lastEn = idioma::En();
- if (bool en = shell::Setting(L"idioma", L"pt") == L"en"; (int)en != lastEn) { // Ajustes > Geral > Idioma
+ if (bool en = shell::Setting(L"idioma", L"en") == L"en"; (int)en != lastEn) { // Ajustes > Geral > Idioma
lastEn = en;
idioma::Set(en);
apps::Relabel();
diff --git a/tools/atualizar-github.ps1 b/tools/atualizar-github.ps1
index ebd5d57..3cf12f6 100644
--- a/tools/atualizar-github.ps1
+++ b/tools/atualizar-github.ps1
@@ -1,74 +1,74 @@
-# Atualiza o WacOS pelo GitHub (Ajustes > Geral > Atualização de Software).
-# Cada commit no GitHub gera um pacote novo (GitHub Actions, .github\workflows\build.yml) publicado como a versão
-# "latest", com bin\versao.txt dentro (1ª linha: a versão, ex. build-12; 2ª: o commit; 3ª: a data).
-# -Verificar -Saida <arquivo>: só confere (o Ajustes chama ao abrir a página) e grava no arquivo, uma por linha:
-# atual=<versão instalada> novo=<versão mais nova> data=<data dela> erro=<motivo> commit=<mensagem> (o que falta)
-# sem -Verificar: baixa o .zip, extrai numa pasta temporária e roda o instalar.ps1 -Atualizar -Silencioso de dentro
-# dele (troca só programas, ícones, sons e ferramentas; os ajustes ficam)
-# Repositório privado: o token do GitHub vai em %APPDATA%\Shell\github-token.txt (só leitura basta).
-param([switch]$Verificar, [string]$Saida = '', [string]$Bin = '')
-$ErrorActionPreference = 'Stop'
-$repo = 'renzyxx/WacOS'
-if (-not $Bin) { $Bin = Join-Path $env:LOCALAPPDATA 'Programs\WacOS\bin' }
-$out = New-Object System.Collections.Generic.List[string]
-
-function Grava { if ($Saida) { Set-Content -Encoding utf8 $Saida $out } }
-function Fim($msg, $espera = 4) { if ($Verificar) { Grava; exit }; Write-Host $msg; Start-Sleep $espera; exit }
-function Erro($msg) { $out.Add("erro=$msg"); Fim $msg 8 }
-
-if (-not $Verificar) { $host.UI.RawUI.WindowTitle = 'WacOS - Atualização' }
-$atual = ''; $atualSha = ''
-$vf = Join-Path $Bin 'versao.txt'
-if (Test-Path $vf) { $v = @(Get-Content $vf); if ($v.Count -ge 1) { $atual = $v[0].Trim() }; if ($v.Count -ge 2) { $atualSha = $v[1].Trim() } }
-$out.Add("atual=$atual")
-if (-not $Verificar) { Write-Host "WacOS instalado: $(if ($atual) { $atual } else { 'versão desconhecida' })" }
-
-$h = @{ 'User-Agent' = 'WacOS-atualizador'; 'Accept' = 'application/vnd.github+json' }
-$tf = Join-Path $env:APPDATA 'Shell\github-token.txt'
-if (Test-Path $tf) { $h['Authorization'] = 'Bearer ' + (Get-Content $tf -TotalCount 1).Trim() }
-[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
-if (-not $Verificar) { Write-Host 'Procurando a versão mais nova no GitHub...' }
-try { $rel = Invoke-RestMethod -Headers $h -Uri "https://api.github.com/repos/$repo/releases/latest" }
-catch {
- $code = 0; try { $code = $_.Exception.Response.StatusCode.value__ } catch {}
- if ($code -eq 404) { Erro "nenhuma versão publicada em github.com/$repo (repositório privado? token em $tf)" }
- Erro "sem conexão com o GitHub ($($_.Exception.Message))"
-}
-$novo = $rel.tag_name
-$out.Add("novo=$novo")
-$out.Add("data=$(([datetime]$rel.published_at).ToLocalTime().ToString('dd/MM/yyyy HH:mm'))")
-if ($atual -and $atual -eq $novo) { Fim 'O WacOS já está atualizado.' }
-
-# o que falta: os commits entre a versão instalada e a nova (sem o commit instalado, os do texto da versão)
-$msgs = @()
-if ($atualSha) {
- try {
- $cmp = Invoke-RestMethod -Headers $h -Uri "https://api.github.com/repos/$repo/compare/$atualSha...$novo"
- $msgs = @($cmp.commits | ForEach-Object { ($_.commit.message -split "`n")[0] })
- [array]::Reverse($msgs) # o mais novo primeiro
- } catch {}
-}
-if (-not $msgs -and $rel.body) { $msgs = @($rel.body -split "`n" | ForEach-Object { $_.Trim().TrimStart('-', '*', ' ') } | Where-Object { $_ }) }
-foreach ($m in ($msgs | Select-Object -First 40)) { $out.Add("commit=$m") }
-if ($Verificar) { Fim '' }
-
-Write-Host "Versão mais nova: $novo"
-if ($msgs) { Write-Host 'O que muda:'; $msgs | Select-Object -First 20 | ForEach-Object { Write-Host " - $_" } }
-$asset = $rel.assets | Where-Object { $_.name -like '*.zip' } | Select-Object -First 1
-if (-not $asset) { Fim 'A versão mais nova não tem o pacote .zip.' 8 }
-$tmp = Join-Path $env:TEMP ('wacos-atualizar-' + [Guid]::NewGuid().ToString('N').Substring(0, 8))
-New-Item -ItemType Directory -Force $tmp | Out-Null
-$zip = Join-Path $tmp $asset.name
-Write-Host "Baixando $($asset.name) ($([math]::Round($asset.size / 1MB)) MB)..."
-$dh = $h.Clone(); $dh['Accept'] = 'application/octet-stream'
-$ProgressPreference = 'SilentlyContinue' # a barra de progresso do PowerShell deixa o download muito lento
-Invoke-WebRequest -UseBasicParsing -Headers $dh -Uri $asset.url -OutFile $zip
-Write-Host 'Extraindo...'
-Expand-Archive $zip (Join-Path $tmp 'pacote') -Force
-$script = Get-ChildItem (Join-Path $tmp 'pacote') -Recurse -Filter instalar.ps1 | Select-Object -First 1
-if (-not $script) { Fim 'O pacote não tem o instalar.ps1.' 8 }
-Write-Host 'Instalando (só os arquivos que mudaram; o WacOS fecha e abre de novo sozinho)...'
-& powershell -NoProfile -ExecutionPolicy Bypass -File $script.FullName -Atualizar -Silencioso
-Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
-Fim "Pronto: WacOS $novo instalado."
+# Updates WacOS from GitHub (System Settings > General > Software Update).
+# Every commit on GitHub builds a new package (GitHub Actions, .github\workflows\build.yml) published as the
+# "latest" release, with bin\versao.txt inside (line 1: the version, e.g. build-12; line 2: the commit; line 3: the date).
+# -Verificar -Saida <file>: only checks (System Settings calls it when the page opens) and writes one item per line:
+# atual=<installed version> novo=<latest version> data=<its date> erro=<reason> commit=<message> (what is missing)
+# without -Verificar: downloads the .zip, extracts it to a temp folder and runs its instalar.ps1 -Atualizar -Silencioso
+# (replaces only programs, icons, sounds and tools; settings stay)
+# Private repository: the GitHub token goes in %APPDATA%\Shell\github-token.txt (read-only is enough).
+param([switch]$Verificar, [string]$Saida = '', [string]$Bin = '')
+$ErrorActionPreference = 'Stop'
+$repo = 'renzyxx/WacOS'
+if (-not $Bin) { $Bin = Join-Path $env:LOCALAPPDATA 'Programs\WacOS\bin' }
+$out = New-Object System.Collections.Generic.List[string]
+
+function Grava { if ($Saida) { Set-Content -Encoding utf8 $Saida $out } }
+function Fim($msg, $espera = 4) { if ($Verificar) { Grava; exit }; Write-Host $msg; Start-Sleep $espera; exit }
+function Erro($msg) { $out.Add("erro=$msg"); Fim $msg 8 }
+
+if (-not $Verificar) { $host.UI.RawUI.WindowTitle = 'WacOS - Update' }
+$atual = ''; $atualSha = ''
+$vf = Join-Path $Bin 'versao.txt'
+if (Test-Path $vf) { $v = @(Get-Content $vf); if ($v.Count -ge 1) { $atual = $v[0].Trim() }; if ($v.Count -ge 2) { $atualSha = $v[1].Trim() } }
+$out.Add("atual=$atual")
+if (-not $Verificar) { Write-Host "Installed WacOS: $(if ($atual) { $atual } else { 'unknown version' })" }
+
+$h = @{ 'User-Agent' = 'WacOS-atualizador'; 'Accept' = 'application/vnd.github+json' }
+$tf = Join-Path $env:APPDATA 'Shell\github-token.txt'
+if (Test-Path $tf) { $h['Authorization'] = 'Bearer ' + (Get-Content $tf -TotalCount 1).Trim() }
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+
+if (-not $Verificar) { Write-Host 'Looking for the latest version on GitHub...' }
+try { $rel = Invoke-RestMethod -Headers $h -Uri "https://api.github.com/repos/$repo/releases/latest" }
+catch {
+ $code = 0; try { $code = $_.Exception.Response.StatusCode.value__ } catch {}
+ if ($code -eq 404) { Erro "no release found at github.com/$repo (private repository? put a token in $tf)" }
+ Erro "could not reach GitHub ($($_.Exception.Message))"
+}
+$novo = $rel.tag_name
+$out.Add("novo=$novo")
+$out.Add("data=$(([datetime]$rel.published_at).ToLocalTime().ToString('dd/MM/yyyy HH:mm'))")
+if ($atual -and $atual -eq $novo) { Fim 'WacOS is up to date.' }
+
+# what is missing: the commits between the installed version and the new one (else the release notes)
+$msgs = @()
+if ($atualSha) {
+ try {
+ $cmp = Invoke-RestMethod -Headers $h -Uri "https://api.github.com/repos/$repo/compare/$atualSha...$novo"
+ $msgs = @($cmp.commits | ForEach-Object { ($_.commit.message -split "`n")[0] })
+ [array]::Reverse($msgs) # newest first
+ } catch {}
+}
+if (-not $msgs -and $rel.body) { $msgs = @($rel.body -split "`n" | ForEach-Object { $_.Trim().TrimStart('-', '*', ' ') } | Where-Object { $_ }) }
+foreach ($m in ($msgs | Select-Object -First 40)) { $out.Add("commit=$m") }
+if ($Verificar) { Fim '' }
+
+Write-Host "Latest version: $novo"
+if ($msgs) { Write-Host 'What changes:'; $msgs | Select-Object -First 20 | ForEach-Object { Write-Host " - $_" } }
+$asset = $rel.assets | Where-Object { $_.name -like '*.zip' } | Select-Object -First 1
+if (-not $asset) { Fim 'The latest release has no .zip package.' 8 }
+$tmp = Join-Path $env:TEMP ('wacos-atualizar-' + [Guid]::NewGuid().ToString('N').Substring(0, 8))
+New-Item -ItemType Directory -Force $tmp | Out-Null
+$zip = Join-Path $tmp $asset.name
+Write-Host "Downloading $($asset.name) ($([math]::Round($asset.size / 1MB)) MB)..."
+$dh = $h.Clone(); $dh['Accept'] = 'application/octet-stream'
+$ProgressPreference = 'SilentlyContinue' # the PowerShell progress bar makes downloads very slow
+Invoke-WebRequest -UseBasicParsing -Headers $dh -Uri $asset.url -OutFile $zip
+Write-Host 'Extracting...'
+Expand-Archive $zip (Join-Path $tmp 'pacote') -Force
+$script = Get-ChildItem (Join-Path $tmp 'pacote') -Recurse -Filter instalar.ps1 | Select-Object -First 1
+if (-not $script) { Fim 'The package has no instalar.ps1.' 8 }
+Write-Host 'Installing (only the files that changed; WacOS closes and reopens by itself)...'
+& powershell -NoProfile -ExecutionPolicy Bypass -File $script.FullName -Atualizar -Silencioso
+Remove-Item $tmp -Recurse -Force -ErrorAction SilentlyContinue
+Fim "Done: WacOS $novo installed."