oliverschwendener / ueli

Cross-Platform Keystroke Launcher
https://ueli.app
MIT License
3.56k stars 234 forks source link

[Bug] Autostart option does not work when Ueli is installed via Microsoft Store #1137

Open oliverschwendener opened 1 month ago

oliverschwendener commented 1 month ago

Autostart option does not work when Ueli is installed via Microsoft Store

To Reproduce Steps to reproduce the behavior:

  1. Open settings
  2. Go to "General" settings
  3. Enable "Autostart"
  4. Check if app has been added to autostart apps in Windows Task Manager
  5. The app is not listed

Expected behavior That the app is added/removed to/from the autostart apps when toggling the "Autostart" option

Environment

oliverschwendener commented 1 month ago

Possible workaround:

https://github.com/electron/electron/issues/42016

Dependency: node_modules/create-desktop-shortcuts

setLoginItemSettings(e, settings){
  if(!settings) return;
  if(AppCtrl.getOS() === Constants.os.win32){
    AppCtrl.createWindowsLoginShortcut(settings);
    return;
  }
  app.setLoginItemSettings(settings);
}

// AppCtrl.js
static createWindowsLoginShortcut({openAtLogin = false} = {}){
  const exePath = cuppa.replace(UtilsCtrl.exePath(), '\\\\', '/');
  const homePath = cuppa.replace(app.getPath('home'), '\\\\', '/');
  if(openAtLogin){
    const shortcutDest = `${homePath}/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/`;
    createDesktopShortcut({
      windows: { filePath: exePath, outputPath:shortcutDest},
     });
  }else{
    const fileDesc = cuppa.fileDescription(exePath);
    const shortcutDest = `${homePath}/AppData/Roaming/Microsoft/Windows/Start Menu/Programs/Startup/${fileDesc.name}.lnk`;
    FileCtrl.removeFileSync(shortcutDest);
  }
}

Same for: app.getLoginItemSettings