-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Linux] Monitored app crashes application #44
Comments
How did you manage to fix it? What do you mean by 'not working correctly'? This information can help fix the bug... This is impacting some functionalities of my portfolio that depend on this API. |
@yan-pi then let's hope the owner fixes it. |
@zackdavidson I’m talking about you contributing to the solution or providing guidance on how the problem occurs, and not just “I fixed it but it doesn’t work properly”. And I’m not asking you to help me with my portfolio, LOL. |
Unfortunately there is no push access to a new branch - the issue seems to be a lack of access on x-win-rs module on rust that can't access /proc/{}/exe - i tried several permissions to no avail. What i done was the following - created a import { exec } from "child_process";
import fs from "fs";
import path from "path";
import { AppData } from "../../utils/validators";
export async function getInstalledAppsLinux(
directory = "/usr/share/applications",
): Promise<AppData[]> {
const directoryContents = await getDirectoryContents(directory);
const appsFileInfo = getAppsFileInfo(directoryContents);
return (
await Promise.all(
appsFileInfo.map((appFileInfo) => getAppData(appFileInfo)),
)
).filter(Boolean) as AppData[];
}
function getDirectoryContents(directory: string) {
return new Promise<string[]>((resolve, reject) => {
exec(`ls ${directory}`, (error, stdout) => {
if (error) {
reject(error);
} else {
try {
resolve(getAppsSubDirectory(stdout, directory));
} catch (err) {
reject(err);
}
}
});
});
}
function getAppsSubDirectory(stdout: string, directory: string): string[] {
let stdoutArr = stdout.split(/[(\r\n)\r\n]+/);
stdoutArr = stdoutArr
.filter((o) => o.endsWith(".desktop"))
.map((i) => {
return `${directory}/${i}`;
});
return stdoutArr;
}
function getAppsFileInfo(appsFile: readonly string[]) {
// Just return the file paths for desktop files
return appsFile.map((file) => [file]);
}
async function getAppData(singleAppFileInfo: string[]) {
const filePath = singleAppFileInfo[0];
if (!filePath) {
return;
}
const appInfo = parseDesktopFile(filePath);
if (!appInfo || !appInfo.Name) {
return;
}
const name = appInfo.Name;
const execName = appInfo.Exec?.split(" ")[0] || name;
const iconPath = appInfo.Icon ? findIconPath(appInfo.Icon) : null;
const version = null; // Version is not typically found in desktop files
return {
path: filePath,
icon: iconPath ? `file://${iconPath}` : null,
name,
bundleId: filePath,
id: appInfo.Name,
isBrowser: false,
isDefaultEnabled: true,
isElectronApp: false,
version,
execName,
} satisfies AppData;
}
function parseDesktopFile(filePath: string): Record<string, string> {
const content = fs.readFileSync(filePath, { encoding: "utf-8" });
const lines = content.split(/\r?\n/);
const record: Record<string, string> = {};
lines.forEach((line) => {
const [key, ...value] = line.split("=");
if (key && value.length) {
record[key.trim()] = value.join("=").trim();
}
});
return record;
}
function findIconPath(iconName: string): string | null {
// Try to find the icon in common icon directories
const iconDirs = [
"/usr/share/icons",
"/usr/share/pixmaps",
path.join(process.env.HOME || "", ".local/share/icons"),
];
for (const dir of iconDirs) {
const iconPathPng = path.join(dir, `${iconName}.png`);
const iconPathSvg = path.join(dir, `${iconName}.svg`);
if (fs.existsSync(iconPathPng)) {
return iconPathPng;
}
if (fs.existsSync(iconPathSvg)) {
return iconPathSvg;
}
}
return null;
} Which was very similar to the import { AppData } from "../../utils/validators";
import { getInstalledApps as getInstalledAppsMac} from "./mac";
import { getInstalledApps as getInstalledAppsWindows } from "./windows";
import {getInstalledAppsLinux} from "./linux.ts";
export async function getApps(): Promise<AppData[]> {
let apps: AppData[] = [];
if (process.platform === "win32") {
apps = await getInstalledAppsWindows();
} else if (process.platform === "darwin") {
apps = await getInstalledAppsMac();
} else if (process.platform === "linux") {
apps = await getInstalledAppsLinux();
console.log('####### ' + JSON.stringify(apps));
}
return apps;
} The problem lie's with the tracking, whenever i enable an application on the menu, it does nothing. It does not track this properly. |
Same issue here with Ubuntu 22.04, Gnome 42.9, Wayland. |
I'm having the same issue with Pop!_OS 22.04 LTS x86_64. Is there like a config file where we can use to configure the monitored apps? So at least we can try going that route? |
Today downloaded v1.0.0
|
Just updated to |
logs:
The text was updated successfully, but these errors were encountered: