How to center GNOME popup notification?

To display the GNOME popup notification on (200,400) on the screen (using Python):

import pynotify n = pynotify.Notification("This is my title", "This is my description") n.set_hint('x', 200) n.set_hint('y', 400) n.show() 

I am gtk noob. How can I show this notification centered on the screen or at the bottom of the screen?

Perhaps my question should be that "which Python fragment gets me the Linux screen sizes?" And I will include them in set_hint () if necessary.

+4
source share
3 answers

Since you are using GNOME, here is a GTK way to get screen resolution

 import gtk.gdk import pynotify n = pynotify.Notification("This is my title", "This is my description") n.set_hint('x', gtk.gdk.screen_width()/2.) n.set_hint('y', gtk.gdk.screen_height()/2.) n.show() 
+4
source

A bit of a hack, but this works:

 from Tkinter import * r = Tk() r.withdraw() width, height = r.winfo_screenwidth(), r.winfo_screenheight() 

Another variant:

 from commands import getstatusoutput status, output = getstatusoutput("xwininfo -root") width = re.compile(r"Width: (\d+)").findall(output)[0] height = re.compile(r"Height: (\d+)").findall(output)[0] 
0
source

in the windows

  from win32api import GetSystemMetrics width = GetSystemMetrics (0) height = GetSystemMetrics (1) print "Screen resolution = %dx%d" % (width, height) 

I can not find the Linux version for it.

-4
source

All Articles