command line - Showing notification in Ubuntu based installs - Ask Ubuntu
i (trying) write simple python script ubuntu based os. part of script, notification shown. now, have gone through number of posts on here each 1 have accompanying question (and problem). following different ways, have tried (and associated issue),
using notify2
this has largely worked well. however, following issue,
a. reason, icon isn't being shown in notification bubble , there no error. simple print statement,print(os.path.abspath('icon.svg')
, returning path, yields correct path still no image.
here's exact code using,
def show_notification(title, content): notify2.init(title) n = notify2.notification(title, content, os.path.abspath('icon.svg')) n.show()
using gi.repository import notify
following hello-unity file here. tried use notify. have not been able running @ all! last time tried, got error importerror: cannot import name notify
running script python test.py
.
running same using python3 in python3 test.py
results in different error importerror: cannot import name notify, introspection typelib not found
.
to overcome this, did try install python-gobject
, libnotify-bin
these installed on system (elementary os loki). errors still persists.
using subprocess
this has worked without problem not sure if best way show notification since intend show regular notifications. code used,
import subprocess s s.call(['notify-send','foo','bar'])
core question
since first time trying develop linux community (or rather ubuntu), new linux development. trying search simple (and correct) implementation such of notification has been rather time consuming , confusing. apart suggesting right way of implementing notifications, appreciate if point me in right direction, android developer guide shows or has api references.
and before asks development preferences, more comfortable python. regarding gui, again not sure path take although gtk seems more popular.
calling notifications applications on ubuntu
definitely third one, using either subprocess.call()
or subprocess.popen()
. noting import subprocess
. nothing new install. simple , easy, works perfectly.
a few examples:
Comments
Post a Comment