Code Monkey home page Code Monkey logo

notification's Introduction

notification

Easily send desktop notifications.

Supported OS

  • Linux/BSD (requires libdbus)

Installation

nimble install notification

Example

import notification

var n = initNotification(
  summary = "hello",
  body = "world",
  icon = "help-faq")

n.add Hint(kind: hkUrgency, urgency: Critical)

let handle = n.notify

Extended example using custom hint type

# Example of sending a custom Hint type that replaces an 
# existing notification as outlined here: 
# https://wiki.archlinux.org/index.php/Desktop_notifications#Replace_previous_notification 
#
# Note that unlike replaceId, which works only when replacing a notification within a 
# running application, this approach works across different processes, as it uses 
# libnotify's in-built mechanism for this.  

import notification
import dbus
import os

let hint = Hint(
    kind: hkCustom, 
    customName:"x-canonical-private-synchronous", 
    customValue: "some-identifier".asDbusValue)

var n = initNotification(
  appname = "someapp",
  summary = "hello",
  body = "I'm gonna be here a real long time...",
  icon = "help-faq", 
  timeout = initTimeout(30 * 1000), 
)
n.add(hint)

discard n.notify

n = initNotification(
  appname = "someapp",
  summary = "hello again",
  body = "Think again!",
  icon = "help-faq", 
  timeout = initTimeout(5 * 1000), 
)

n.add(hint)

sleep(2000)
discard n.notify

notification's People

Contributors

jmetz avatar solitudesf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

jmetz

notification's Issues

Update Notifications

Hi!

I really liked the package! But I couldn't get a message update to work!

It is possible to do using dbus! https://sylvaindurand.org/update-notifications-with-libnotify/

gdbus call \
    --session \
    --dest org.freedesktop.Notifications \
    --object-path /org/freedesktop/Notifications \
    --method org.freedesktop.Notifications.Notify \
    "identifier" \
    "1" \
    "" \
    "Notification title" \
    "Notification description" \
    "[]" \
    "{}" \
    "2000"

Once this command is executed, the system returns a response that looks like :

(uint32 13,)

gdbus call \
    --session \
    --dest org.freedesktop.Notifications \
    --object-path /org/freedesktop/Notifications \
    --method org.freedesktop.Notifications.Notify \
    "identifier" \
    "13" \
    "" \
    "My updated title" \
    "My updated description" \
    "[]" \
    "{}" \
    "2000"

Is it possible to update the notification? Using notification?

Thanks,
Marcelo Módolo

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.