Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { AppInfo } from "../reducers/app";
import { debug, debugPath, init } from "./actions";
import { store } from "./store";
import { setReporter, setUpdater } from "./utils";
import DebugronIcon from "../../assets/icon.png";

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require("electron-squirrel-startup")) {
Expand All @@ -19,7 +20,7 @@ const createWindow = () => {
titleBarStyle: "hidden",
trafficLightPosition: { x: 14, y: 14 },
icon: process.platform === "linux"
? nativeImage.createFromDataURL(require("../../assets/icon.png"))
? nativeImage.createFromDataURL(DebugronIcon)
: undefined,
webPreferences: {
nodeIntegration: true,
Expand Down
15 changes: 12 additions & 3 deletions src/main/platforms/linux/find-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function parseSize(name: string): number {
if (name === "symbolic") return 0.8;
if (!sizeReg.test(name)) return -1;
let [pixel, scala] = name.split("@");
let size = Number(pixel.replace(pixelIgnoreReg, ""));
let size = Number(pixel?.replace(pixelIgnoreReg, ""));
let wight = Number(scala?.replace(scalaIgnoreReg, ""));
return (isNaN(size) ? 0 : size) + (isNaN(wight) ? 0 : wight) / 100;
}
Expand All @@ -83,7 +83,7 @@ function findAllIconDirs(base: string, parent = base): SizeDir[] {
const files = fs.readdirSync(parent);
const dirs = files
.map((name) => path.join(parent, name))
.filter((path) => fs.statSync(path).isDirectory());
.filter((path) => accessSync(path) && isDirectory(path));
if (dirs.length) {
return dirs.map(findAllIconDirs.bind(void 0, base)).flat();
}
Expand All @@ -94,7 +94,7 @@ function findAllIconDirs(base: string, parent = base): SizeDir[] {
if (!pathNames.includes("apps")) return [];
// remove that path with 'apps' compatible theme/size/apps and theme/apps/size
const [_theme, size] = relative.split("/").filter((name) => name !== "apps");
return [{ path: parent, size: parseSize(size) }];
return [{ path: parent, size: parseSize(size || '0') }];
}

function findThemeIconDirs(theme: string) {
Expand All @@ -106,6 +106,15 @@ function iconDirSortBySize(dirs: SizeDir[]): SizeDir[] {
return dirs.sort((a, b) => b.size - a.size);
}

function isDirectory(path: string): boolean {
try {
return fs.statSync(path).isDirectory();
} catch(e) {
console.error("can't read " + path);
}
return false;
}

function accessSync(path: string): boolean {
try {
fs.accessSync(path);
Expand Down