You are not logged in.

#1 2013-01-23 21:25:29

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

[SOLVED] dbus notification shell script

EDIT: https://github.com/nowrep/notify-desktop

I need a one line command for shell for dbus to show a notification.

I'm using this python script for now:

#!/usr/bin/env python
# -*- coding: utf8 -*- 

"""This is a python script that creates a notification using dbus."""
import os, dbus
item = ('org.freedesktop.Notifications')
path = ('/org/freedesktop/Notifications')
interface = ('org.freedesktop.Notifications')


datum = os.popen("date +%X").read()

icon = '/home/mladen/.irssi/irssitop.png'
array = ''
hint = ''
time = 3 # Use seconds x 1000, 0 means wait for confirmation
app_name = ('irssi')
title = ('irssi обавјештење')
body = ('Неко вас је споменуо\n\nВријеме:\t'+str(datum))

bus = dbus.SessionBus()
notif = bus.get_object(item, path)
notify = dbus.Interface(notif, interface)
notify.Notify(app_name, 0, icon, title, body, array, hint, time)

os.popen("ogg123 -q /usr/share/sounds/KDE-Im-Irc-Event.ogg &>/dev/null &").read()

But the problem is that I would prefer a one line command, if possible, and I'm not familliar with coding in python, so I'm unable to adapt it to suit my needs.

Last edited by Demon (2014-01-11 20:52:30)

Offline

#2 2013-01-23 21:29:52

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,595
Website

Re: [SOLVED] dbus notification shell script

Dunno about a oneliner but does the code in the following provide food for thought?

https://aur.archlinux.org/packages/mpc-osd-git


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#3 2013-01-23 21:31:07

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [SOLVED] dbus notification shell script

Thanks graysky, but I'm looking for a shell script, and this is python based. smile

Offline

#4 2013-01-23 21:32:21

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] dbus notification shell script

just use notify-send ?

That python script is just ....................

Last edited by Mr.Elendig (2013-01-23 21:32:47)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#5 2013-01-23 22:14:15

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [SOLVED] dbus notification shell script

I've tried this, no succes:

% dbus-send --session --dest=org.freedesktop.Notifications --type=method_call --reply-timeout=10000 /org/freedesktop/Notifications org.freedesktop.Notifications string:'Test Application' uint32:0 string: string:'NOTIFICATION TEST' string:'This is a test of the notification system via DBus.' array:string: dict:string: int32:10000 
dbus-send: Data item "" is badly formed

Offline

#6 2013-01-24 13:14:00

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] dbus notification shell script

notify-send != dbus-send.
Has different letters and stuff in it.


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#7 2013-01-24 13:35:52

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [SOLVED] dbus notification shell script

Mr.Elendig wrote:

notify-send != dbus-send.
Has different letters and stuff in it.

I don't want to use notify-send.

Offline

#8 2013-01-25 07:26:07

knopwob
Member
From: Hannover, Germany
Registered: 2010-01-30
Posts: 239
Website

Re: [SOLVED] dbus notification shell script

Demon wrote:
Mr.Elendig wrote:

notify-send != dbus-send.
Has different letters and stuff in it.

I don't want to use notify-send.

why not?

Offline

#9 2013-01-26 05:27:42

Stebalien
Member
Registered: 2010-04-27
Posts: 1,237
Website

Re: [SOLVED] dbus notification shell script

1. dict needs to be in the format 'dict:string:string:' not 'dict:string:'
2. You didn't specify the function (org.freedesktop.Notifications.Notify instead of org.freedesktop.Notifications).

dbus-send --session --print-reply --dest=org.freedesktop.Notifications --type=method_call --reply-timeout=10000 /org/freedesktop/Notifications org.freedesktop.Notifications.Notify string:'Test Application' uint32:0 string: string:'NOTIFICATION TEST' string:'This is a test of the notification system via DBus.' array:string: dict:string:string: int32:10000

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C
Do not email: honeypot@stebalien.com

Offline

#10 2014-01-11 20:51:38

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [SOLVED] dbus notification shell script

Offline

Board footer

Powered by FluxBB