1. API
  2. app.dock

API

Functions

Function Description
bounce(kind) Bounce this app icon in the dock.
cancelBounce(id) Cancel the bounce action with identifier id.
getBadge() Get the currently set badge for this app in the dock.
getMenu() Gets the menu associated with this dock icon.
hide() Hides the dock icon.
setBadge(label) Set this app's badge in the dock.
setIcon(args) Sets the image associated with this dock icon.
setMenu(menu) Sets the menu associated with this dock icon.
show() Shows the dock icon.

bounce()

Bounce this app icon in the dock.

Signature:

        import { app } from "@todesktop/client-core"
app.bounce(kind: "informational" | "critical"): Promise<number>;

      
Parameters
Parameter Type Description
kind "informational" | "critical"

Returns:

Promise<number>

An identifier representing the bounce executed.

cancelBounce()

Cancel the bounce action with identifier id.

Signature:

        import { app } from "@todesktop/client-core"
app.cancelBounce(id: number): Promise<void>;

      
Parameters
Parameter Type Description
id number

Returns:

Promise<void>

getBadge()

Get the currently set badge for this app in the dock.

Signature:

        import { app } from "@todesktop/client-core"
app.getBadge(): Promise<string>;

      

Returns:

Promise<string>

getMenu()

Gets the menu associated with this dock icon.

Signature:

        import { app } from "@todesktop/client-core"
app.getMenu(): Promise<InstanceRefObject>;

      

Returns:

Promise<InstanceRefObject>

hide()

Hides the dock icon.

Signature:

        import { app } from "@todesktop/client-core"
app.hide(): Promise<void>;

      

Returns:

Promise<void>

setBadge()

Set this app's badge in the dock.

Signature:

        import { app } from "@todesktop/client-core"
app.setBadge(label: string): Promise<void>;

      
Parameters
Parameter Type Description
label string

Returns:

Promise<void>

setIcon()

Sets the image associated with this dock icon.

Signature:

        import { app } from "@todesktop/client-core"
app.setIcon(...args: [InstanceRefObject]): Promise<void>;

      
Parameters
Parameter Type Description
args [InstanceRefObject]

Returns:

Promise<void>

Example

        import {
  app,
  nativeWindow,
  nativeImage,
  platform,
} from '@todesktop/client-core';

// You can convert canvas to a data URL (using `toDataURL`)
const dataURL = "data:image/png;base64,iVBORw0KGgo…";

const imgRef = await nativeImage.createFromDataURL(dataURL);

if (platform.os.getOSPlatform() === "darwin") {
  await app.dock.setIcon(imgRef);
} else {
  // Windows and Linux
  await nativeWindow.setIcon({}, imgRef);
}


      

setMenu()

Sets the menu associated with this dock icon.

Signature:

        import { app } from "@todesktop/client-core"
app.setMenu(menu: Ref): Promise<void>;

      
Parameters
Parameter Type Description
menu Ref

Returns:

Promise<void>

show()

Shows the dock icon.

Signature:

        import { app } from "@todesktop/client-core"
app.show(): Promise<void>;

      

Returns:

Promise<void>


Previous <- app