app
The app object provides methods to control the Novadesk application: reloading scripts, exiting, managing the system tray, and querying version info.
app is exported from the novadesk module.
import { app } from 'novadesk';Note
Available only in the Main script.
Table of Contents
Lifecycle
app.reload()/app.refresh()
Reloads all active widget scripts.
Example
app.reload();
app.refresh();app.exit()
Exits the Novadesk application.
Example
app.exit();app.isFirstRun()
Description: Returns true on the first launch when the settings file is missing or empty. Returns false on normal subsequent launches.
Example
// Check whether this is the first run
const isFirstRun = app.isFirstRun();
console.log("Is First Run: " + isFirstRun);Tray
app.setTrayMenu(items)
Sets the context menu for the system tray icon. Replaces any previously set menu.
Parameters
items(Array<object>): Menu item definitions. Each object can include:text(string): Label shown in the menu.action(function): Callback invoked when the item is clicked.type(string): Set to"separator"to insert a divider.checked(boolean): Whether the item appears checked.items(Array<object>): Nested sub-menu items.
Example
app.setTrayMenu([
{ text: "Reload", action: () => app.reload() },
{ type: "separator" },
{
text: "Tools",
items: [
{ text: "Debug Mode", checked: false, action: () => console.log("toggle") }
]
},
{ type: "separator" },
{ text: "Exit", action: () => app.exit() }
]);app.clearTrayMenu()
Removes all custom tray menu items.
app.showDefaultTrayItems(show)
Controls visibility of the built-in default tray entries (e.g. "Exit").
Parameters
show(boolean):trueto show default items,falseto hide them.
Example
app.showDefaultTrayItems(true);app.hideTrayIcon(hide)
Shows or hides the Novadesk system tray icon. The setting is persisted.
Parameters
hide(boolean):trueto hide the icon,falseto show it.
Example
app.hideTrayIcon(false);Settings
app.saveLogToFile(bool)
Enables or disables logging to a file (logs.log) in the application's AppData directory.
Parameters
bool- Type:
boolean - Description:
trueto enable file logging,falseto disable.
- Type:
Example
// Enable logging to file
app.saveLogToFile(true);app.enableDebugging(bool)
Sets the global log level. When enabled, debug-level messages will be visible in the console and log file.
Parameters
bool- Type:
boolean - Description:
trueto enable debug logging,falseto use standard informational logging.
- Type:
Example
app.enableDebugging(true);
console.debug("Detailed diagnostic information");app.disableLogging(bool)
Completely disables or enables all logging output (both console and file).
Parameters
bool- Type:
boolean - Description:
trueto silence all logs,falseto resume logging based on other settings.
- Type:
Example
// Silence all output for production
app.disableLogging(true);app.hideTrayIcon(bool)
Dynamically shows or hides the Novadesk icon in the system tray.
Parameters
bool- Type:
boolean - Description:
trueto hide the icon,falseto show it.
- Type:
Example
// Run in "stealth" mode
app.hideTrayIcon(true);app.useHardwareAcceleration(bool)
Enables or disables Direct2D hardware acceleration.
Parameters
bool- Type:
boolean - Description:
trueto use hardware-accelerated rendering (Default),falseto use software rendering.
- Type:
Note
Changing this setting requires an application restart to take effect.
Example
// Enable hardware acceleration
app.useHardwareAcceleration(true);Utils
app.isPortable()
Description: Returns true when Novadesk is running in portable mode, otherwise false.
Note
Portable mode is detected at runtime based on the executable location and whether Novadesk can write in that directory.
Example
// Check whether Novadesk is running in portable mode
const isPortable = app.isPortable();
console.log("Is Portable: " + isPortable);app.getProductVersion()
Returns the product version from the executable metadata.
Return Value
- Type:
string
Note
Standalone widget applications built with nwm report the version from meta.json.
Example
console.log("Product version:", app.getProductVersion());app.getFileVersion()
Returns the file version from the executable metadata.
Return Value
- Type:
string
Note
Standalone widget applications built with nwm report the value from meta.json.
Example
console.log("File version:", app.getFileVersion());app.getNovadeskVersion()
Returns the hardcoded Novadesk engine version. This value is constant regardless of nwm packaging.
Return Value
- Type:
string
Example
console.log("Novadesk version:", app.getNovadeskVersion());app.getAppDataPath()
Description: Returns the absolute path to the Novadesk AppData directory (%APPDATA%\Novadesk\). This directory is used for storing persistent settings, logs, and configuration.
Example
// Get the path to Novadesk AppData
const appData = app.getAppDataPath();
console.log("AppData Path: " + appData);app.getSettingsFilePath()
Description: Returns the absolute path to the settings.json file.
Example
// Get the settings file path
const settingsPath = app.getSettingsFilePath();
console.log("Settings Path: " + settingsPath);app.getLogPath()
Description: Returns the absolute path to the current log file (logs.log).
Example
// Get the log file path
const logPath = app.getLogPath();
console.log("Log Path: " + logPath);