Skip to content

Commit

Permalink
Add funding, and fix help to say KDE also.
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanaelA committed Sep 21, 2021
1 parent 110c23b commit 9454645
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions menuitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ if (options.exec == null || options.exec.length === 0) {
const info = loadFile(desktopFile);
if (options.edit && !info._created) {
spawnEditor(info._pathToDesktopFile);
spawnUpdateDB(info._pathToDesktopFile.replace(path.basename(info._pathToDesktopFile), ''));
process.exit(0);
}

Expand All @@ -138,6 +139,7 @@ if (configureDesktopEntry(info)) {
} else {
console.log("Saved:", fileName);
}
spawnUpdateDB(fileName.replace(path.basename(fileName), ''));
} else {
console.log("No Changes");
}
Expand All @@ -146,6 +148,24 @@ if (configureDesktopEntry(info)) {
// Support Functions
// -------------------------------------------------------------------------------------------------

/**
* Spawns the Update desktop database for Mime-types*
* @param path
*/
function spawnUpdateDB(path) {
console.log(path);
const updater = ['/usr/bin/update-desktop-database'];
for (let i=0;i<updater.length;i++) {
if (fs.existsSync(updater[i])) {
child.spawnSync(updater[i], ["-q", path], {
stdio: 'inherit'
});
return;
}
}
}


/**
* Attempts to figure out the editor, defaults to ubuntu's "editor" command if env vars aren't set
*/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@master.technology/desktopmenuitem",
"version": "0.0.2",
"version": "0.0.3",
"main": "menuitem.js",
"bin": {
"desktopmenuitem": "menuitem.js"
Expand Down

0 comments on commit 9454645

Please sign in to comment.