Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

275
Visualizações
Get accent color in Windows dark mode

Program-building with electron

The idea:
I want the accent color of my program to be the same as the one from Windows.

The problem:
For the Light Mode of Windows, everything works, the passed color matches the Windows accent color. But when switching to Dark Mode, I still get the accent color of the Light Mode.

Possible solutions:
How does the Windows selection for the Dark Mode accent color work? Is the color always increased by a certain brightness level? Or are there pre-saved patterns?


Here is my current code:

main.js

let color = systemPreferences.getAccentColor()

  mainWindow.on('ready-to-show', function() {
    mainWindow.webContents.send('accColor', {'Color': color});
  })

ipc.js

ipc.on('accColor', (evt, message) => {
    let color = message['Color']
    const hex2rgb = (hex) => {
        const r = parseInt(hex.slice(1, 3), 16)
        const g = parseInt(hex.slice(3, 5), 16)
        const b = parseInt(hex.slice(5, 7), 16)
        return [ r, g, b ]
    }
    let baseRGB = hex2rgb('#' + color)
    document.querySelector('body').style.setProperty('--accent-default-rgb', baseRGB)
})
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Although I couldn't find a function that returned the value of the dark mode accent color, I was able to change the brightness of the color and thus create a somewhat suitable solution.


Here is the code I added:

ipc.js

function adjustDark(color, amount) {
    return '#' + color.replace(/^#/, '').replace(/../g, color => ('0'+Math.min(255, Math.max(0, parseInt(color, 16) + amount)).toString(16)).substr(-2));
}


let darkHEX = adjustDark(color, 96)
let darkRGB = hex2rgb(darkHEX)
document.querySelector('body').style.setProperty('--accent-default-rgb', darkRGB)


Source for adjustDark()

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda