Skip to content

Commit

Permalink
console.errors instead of log; try-catching
Browse files Browse the repository at this point in the history
  • Loading branch information
kashyab12 committed May 26, 2024
1 parent 6673259 commit b3246aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
18 changes: 10 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,16 @@ ipcMain.handle('dark-mode:system', () => {
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
appWindows.push(createWindow())
appWindows.forEach(window => {
window.hide()
})
appsInfo = await generateInstalledAppsInfo(app)
setupTray()
regGlobKeybinds()
regWindowEvents()
try {
appWindows.push(createWindow())
appWindows.forEach(window => window.hide())
appsInfo = await generateInstalledAppsInfo(app)
setupTray()
regGlobKeybinds()
regWindowEvents()
} catch (installedAppError) {
console.error(installedAppError)
}
});

// Quit when all windows are closed, except on macOS. There, it's common
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/installed-apps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ async function findAppIcon(desktopPath: string, desktopFile: DesktopFile, electr
getAppIconPathCmd = `find ${DesktopFilePaths.IconsFlatpak} -name '${desktopFile.icon}.*' -type f`
} else throw new EvalError('could not find any icon')
const { stdout: getAppIconPathStdout, stderr: getAppIconPathStderr } = await execAsync(getAppIconPathCmd)
if (getAppIconPathStderr) console.log(getAppIconPathStderr)
if (getAppIconPathStderr) console.error(getAppIconPathStderr)
return getAppIconPathStdout.split("\n")[0]
} catch (getAppIconPathError) {
console.log(getAppIconPathError)
console.error(getAppIconPathError)
return ""
}
}
Expand All @@ -92,12 +92,12 @@ async function getInstalledApps(electronAppInfo: App) {
const validPaths = [DesktopFilePaths.AppsUsrShare, `${electronAppInfo.getPath("home")}${DesktopFilePaths.AppsLocalShare}`, DesktopFilePaths.AppsSnap, DesktopFilePaths.AppsFlatpak]
const findDesktopFilesCmd = 'locate "*.desktop"'
const { stdout: findDesktopFilesStdout, stderr: findDesktopFilesStderr } = await execAsync(findDesktopFilesCmd)
if (findDesktopFilesStderr) console.log(findDesktopFilesStderr)
if (findDesktopFilesStderr) console.error(findDesktopFilesStderr)
return findDesktopFilesStdout.split("\n").filter(desktopPath => {
return validPaths.some(validPath => desktopPath.includes(validPath))
})
} catch (findDesktopFilesError) {
console.log(findDesktopFilesError)
console.error(findDesktopFilesError)
return []
}
}
Expand Down Expand Up @@ -145,7 +145,7 @@ export async function generateInstalledAppsInfo(electronAppInfo: App) {
// todo: make concurrent via worker threads
for (const desktopPath of installedApps) {
const desktopFile = await desktopFileParser(desktopPath)
if (desktopFile.noDisplay || desktopFile.type.toLowerCase() != 'application') continue
if (desktopFile.noDisplay || desktopFile.type.toLowerCase() != 'application' || !desktopFile.name) continue
const iconPath = await findAppIcon(desktopPath, desktopFile, electronAppInfo)
const b64Icon = await imgToB64(iconPath)
appInfo[desktopFile.name] = {
Expand Down

0 comments on commit b3246aa

Please sign in to comment.