Bon, finalement ça s'arrange !
Mais du coup j'ai écrit un script qui fait la même chose, sans utiliser python-notify, ni notify-osd.
C'est juste une fenêtre Gtk (elle devrait s'afficher en vert pour cet exemple) -> donc ça pourrait reprendre la couleur de la notification principale
Le code est un peu plus long, mais ça devrait fonctionner chez tout le monde, sans ajouter de dépendance. (en root ou en normal)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pygtk
pygtk.require('2.0')
import gtk
import gtk.gdk
import time
import math
class Time:
def auto(self, Time, donnees=None):
# entourage
cadre = gtk.Frame("Titre")
self.boite.add(cadre)
# initialisation etiquette
etiquette = gtk.Label()
etiquette.set_alignment(0.5, 0.5)
etiquette.set_justify(gtk.JUSTIFY_CENTER)
cadre.add(etiquette)
# texte 1
etiquette.set_markup("<i><b>Message 1</b></i>")
# affichage
etiquette.show()
self.boite.show()
cadre.show()
self.window.show()
# affichage notification 1
then = time.time()
while then + 10 > time.time():
while gtk.events_pending():
gtk.main_iteration()
time.sleep(0.1)
# fermeture notification 1
self.window.hide()
while gtk.events_pending():
gtk.main_iteration()
#pause de 2s
time.sleep(2)
#texte 2
etiquette.set_markup("<i><b>Message 2</b></i>")
#affichage notification 2
self.boite.show()
self.window.show()
then = time.time()
while then + 10 > time.time():
while gtk.events_pending():
gtk.main_iteration()
time.sleep(0.1)
print "sortie"
exit()
def __init__(self):
color = "#10a000"
#positionX = 1560 # config pour mon écran
#positionY = 35
positionX = 800
positionY = 35
# Création fenetre principale
self.window = gtk.Window(gtk.WINDOW_POPUP)
# Position de la fenetre principale
self.window.move(positionX+100, positionY)
self.window.set_default_size(250, 80)
self.window.set_position(gtk.WIN_POS_NONE)
self.window.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
self.window.connect('size-allocate', self.reshaperect)
# Couleur de la fenetre
map = self.window.get_colormap()
colour = map.alloc_color(color)
style = self.window.get_style().copy()
style.bg[gtk.STATE_NORMAL] = colour
self.window.set_style(style)
#boite
self.boite = gtk.HBox()
self.window.add(self.boite)
self.auto(self, Time)
def reshaperect(self, obj, allocation): # pour les coins arrondis
w,h = allocation.width, allocation.height
bitmap = gtk.gdk.Pixmap(None, w, h, 1)
# Clear the bitmap
fg = gtk.gdk.Color(pixel=0)
bg = gtk.gdk.Color(pixel=-1)
fg_gc = bitmap.new_gc(foreground=fg, background=bg)
bitmap.draw_rectangle(fg_gc, True, 0, 0, w, h)
# Draw our shape into the pixmap using cairo
# Let's try drawing a rectangle with rounded edges.
padding=2 # Padding from the edges of the window
rounded=10 # How round to make the edges
cr = bitmap.cairo_create()
cr.set_source_rgb(0,0,0)
# Move to top corner
cr.move_to(0+padding+rounded, 0+padding)
# Top right corner and round the edge
cr.line_to(w-padding-rounded, 0+padding)
cr.arc(w-padding-rounded, 0+padding+rounded, rounded, math.pi/2, 0)
# Bottom right corner and round the edge
cr.line_to(w-padding, h-padding-rounded)
cr.arc(w-padding-rounded, h-padding-rounded, rounded, 0, math.pi/2)
# Bottom left corner and round the edge.
cr.line_to(0+padding+rounded, h-padding)
cr.arc(0+padding+rounded, h-padding-rounded, rounded, math.pi+math.pi/2, math.pi)
# Top left corner and round the edge
cr.line_to(0+padding, 0+padding+rounded)
cr.arc(0+padding+rounded, 0+padding+rounded, rounded, math.pi/2, 0)
# Fill in the shape.
cr.fill()
# Set the window shape
self.window.shape_combine_mask(bitmap, 0, 0)
self.window.show()
def main():
gtk.main()
return 0
if __name__ == "__main__":
Time()
main()
Pour la position, j'ai mis au pif. ça devrait s'afficher en haut, mais pour la position horizontale ça dépend de la taille de l'écran. Mais pareil, la config du logiciel pourrait donner toutes ces infos.
Si ça marche, on pourra choisir l'une ou l'autre solution.
@metalux:
Je ne sais pas si
xfce4-notifyd est indispensable pour xfce, si
notification-daemon le remplace, ou même s'il est installé par défaut dans Xubuntu.. c'est un peu la jungle.
Et ça fonctionne aussi en root ?