Giter Site home page Giter Site logo

deno-systray's Introduction

deno-systray

nest.land CI Status Tags License

A cross-platform systray library for Deno using the go systray library.

Usage

import SysTray from "https://deno.land/x/systray/mod.ts";

const Item1 = {
  title: 'Item 1',
  tooltip: 'The first item',
  // checked is implemented by plain text in linux
  checked: true,
  enabled: true,
  // click is not a standard property but a custom value
  click: () => {
    Item1.checked = !Item1.checked
    systray.sendAction({
      type: 'update-item',
      item: Item1,
    })
  }
}

const Item2 = {
  title: 'Item 2',
  tooltip: 'The second item',
  checked: false,
  enabled: true,
  // add a submenu item
  items: [{
    title: 'Submenu',
    tooltip: 'this is a submenu item',
    checked: false,
    enabled: true,
    click: () => {
      // open the url
      console.log('open the url')
    }
  }]
}

const ItemExit = {
  title: 'Exit',
  tooltip: 'Exit the menu',
  checked: false,
  enabled: true,
  click: () => {
    systray.kill()
  }
}

const systray = new SysTray({
  menu: {
    // Use .png icon in macOS/Linux and .ico format in windows
    icon: Deno.build.os === 'windows' ? './icon.ico' : './icon.png',
    // A template icon is a transparency mask that will appear to be dark in light mode and light in dark mode
    isTemplateIcon:  Deno.build.os === 'darwin',
    title: "Title",
    tooltip: "Tooltip",
    items: [
      Item1,
      Item2,
      SysTray.separator, // SysTray.separator is equivalent to a MenuItem with "title" equals "<SEPARATOR>"
      ItemExit
    ],
  },
  debug: true, // log actions
  directory: 'bin' // cache directory of binary package
});

systray.on('click', (action) => {
  if (action.item.click) {
    action.item.click();
  }
});

systray.on('ready', () => {
  console.log('tray started!');
});

systray.on('exit', () => {
  console.log('exited');
});

systray.on('error', (error) => {
  console.log(error);
});

Try the example app!

$ deno run -A https://deno.land/x/systray/example/index.ts

View platform notes.

Credits

License

MIT

deno-systray's People

Contributors

draketdl avatar keyholder avatar wobsoriano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

deno-systray's Issues

On Windows, a systray-portable console is launched

When I compile a program using deno compile with the --no-terminal flag, the main program's console is not displayed, but the subprocess console window of systray-portable, is continuously running. I have no idea how to hide this window so that launching the compiled version of the script does not display any console and works in the background. Do you have any idea how to solve this?

PS: When I close this console the entire program quits.

"Bad CPU type in executable" when running example

When I attempt to copy and past the readme.md example or run deno run -A https://deno.land/x/systray/example/index.ts I get the following error on MacOS.
image

➜  urler deno run -A https://deno.land/x/systray/example/index.ts
Download ⠼ https://deno.land/x/systray/example/index.ts                                                                                                                                                                 Warning Implicitly using latest version (v0.2.2) for https://deno.land/x/systray/example/index.ts
error: Uncaught (in promise) Error: Bad CPU type in executable (os error 86)
    this._process = Deno.run({
                         ^
    at opRun (deno:runtime/js/40_process.js:33:16)
    at Object.run (deno:runtime/js/40_process.js:116:17)
    at SysTray.run (https://deno.land/x/[email protected]/mod.ts:241:26)
    at SysTray.init (https://deno.land/x/[email protected]/mod.ts:273:12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.