A cross-platform systray library for Deno.

Overview

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 https://deno.land/x/systray/example/index.ts

View platform notes.

Credits

License

MIT

You might also like...

TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy

Atlas SDK atlas_sdk is a TypeSafe MongoDB Atlas Data API SDK for Deno & Deno Deploy Links Docs Import Replace LATEST_VERSION with current latest versi

Dec 26, 2022

Deno bindings for yoga, using Deno FFI.

deno_yoga Deno bindings for yoga, using Deno FFI. Usage flags: --allow-ffi: Requires ffi access to "yogacore.dll", "libyogacore.so", "libyogacore.dyli

Feb 11, 2022

🛣️ A tiny and fast http request router designed for use with deno and deno deploy

Rutt Rutt is a tiny http router designed for use with deno and deno deploy. It is written in about 200 lines of code and is pretty fast, using an exte

Dec 10, 2022

deno-ja (Deno Japanese community) showcase

Showcase Deno本家よりも気軽に作ったものを公開できるようなShowcaseです。 スクリーンショットの撮影方法 短めのidを決めていただいて、下記のようにスクリプトを実行してください。 deno task screenshot [url] [id] ※エラーが出る場合は、下記を実行してみ

Oct 28, 2022

A command-line tool to manage Deno scripts installed via deno install

🏞️ nublar nublar is a command-line tool to manage your scripts installed via deno install. 🛳️ Installation deno install --allow-read --allow-write -

Dec 26, 2022

📗 How to write cross-platform Node.js code

📗 How to write cross-platform Node.js code

How to write cross-platform Node.js code. Why you should care: according to the 2018 Node.js user survey, 24% of Node.js developers use Windows locall

Jan 3, 2023

A cross-platform AutoHotKey-like thing with TypeScript as its scripting language

suchibot A cross-platform AutoHotKey-like thing with JavaScript/TypeScript as its scripting language. Built on top of uiohook-napi and nut.js. Install

Sep 21, 2022

LucaMail - an Open Source,Cross Platform Email Client

LucaMail -  an Open Source,Cross Platform Email Client

LucaMail v0.0.1-beta An Awesome Cross Platform Email Client! Note : This Project Is Still in Beta Version Website . Report Bug . Request Feature . Dis

Dec 28, 2022

Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

Hacker Tools cross-platform desktop App, support windows/MacOS/LInux ....

Jan 8, 2023
Comments
  • "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)
    
    
    opened by tylerssn 0
Releases(v0.2.2)
Owner
Robert Soriano
[object Object]
Robert Soriano
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
cross-platform Deno library for writing and reading clipboard.

deno-clippy This is cross-platform Deno library for writing and reading clipboard. You can read from/write image and text. This library uses Rust's ar

skanehira 34 Dec 3, 2022
Opinionated collection of TypeScript definitions and utilities for Deno and Deno Deploy. With complete types for Deno/NPM/TS config files, constructed from official JSON schemas.

Schemas Note: You can also import any type from the default module, ./mod.ts deno.json import { type DenoJson } from "https://deno.land/x/[email protected]

deno911 2 Oct 12, 2022
Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

David Sherret 150 Dec 31, 2022
Cross platform shell tools for Deno inspired by zx.

dax Note: This is very early stages. Just started working on it. Cross platform shell tools for Deno inspired by zx. Differences: No globals or global

David Sherret 45 Jul 24, 2022
GetOsLocalesCrossPlatform - A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers

getOsLocalesCrossPlatform A cross platform alternative to get locales used on the platform. Works on Node, Electron, NW.js and Browsers This script is

null 1 Jan 2, 2022
A small, but powerful HTTP library for Deno & Deno Deploy, built for convenience and simplicity

Wren Wren is a small, but powerful HTTP library for Deno & Deno Deploy, built for convenience and simplicity. convenient aliases for HTTP responses au

Jakub Neander 69 Dec 12, 2022
Webview is a tiny cross-platform library to make web-based GUIs for desktop applications.

webview_deno deno bindings for webview Webview is a tiny cross-platform library to make web-based GUIs for desktop applications. ⚠️ This project is st

webview 1.2k Jan 2, 2023
This is a simple boilerplate for a Deno website, deployed with Deno Deploy.

Simple Deno Website Boilerplate This is a simple website boilerplate built using Deno and deployed using Deno Deploy. Demo at simple-deno-website-boil

Bruno Bernardino 15 Dec 3, 2022