Open vkravets opened 12 years ago
Hi Vladimir,
Thank you for rewriting me the C++ version of Wallpapoz daemon.
Performance is nice. Previously Wallpapoz was written in C++. But many people got problem compiling Wallpapoz. So I decided to convert it to python. But maybe I can put C++ side by side. Let me think about it.
Thank you again.
Me.
On Wed, Apr 4, 2012 at 12:07 AM, Vladimir Kravets reply@reply.github.com wrote:
I think that to have good performance and lower memory usage for such behavior need to do such things:
- Rewrite daemon to C++
- Use libwnck to register event for changing workspace (in this case we will have dependency for gtk2). Look at the below code as example of usage:
#! /usr/bin/python # -*- coding: utf-8 -*- import wnck import gtk import os import pynotify def workspace_active_changed(screen, previous): workspace = screen.get_active_workspace() pynotify.init("Workspace Changed Notify") notification = pynotify.Notification("Workspace changed...", workspace.get_name(), "dialog-info") notification.set_urgency(pynotify.URGENCY_NORMAL) notification.set_timeout(pynotify.EXPIRES_DEFAULT) notification.show() screen = wnck.screen_get_default() screen.connect('active-workspace-changed', workspace_active_changed) gtk.main()
Reply to this email directly or view it on GitHub: https://github.com/vajrasky/wallpapoz/issues/4
I'm just trying to rewrite above python script to vala and I have such result:
using Wnck;
using Gtk;
using Notify;
namespace org.test {
class WorkspaceChanger : GLib.Object {
private Wnck.Screen screen;
public void register() {
screen = Wnck.Screen.get_default();
//show_notify("change workspace", @"Screen info: $(screen.get_workspace_count())");
screen.active_workspace_changed.connect(workspaceChanged);
}
public void workspaceChanged(Wnck.Workspace? prev_workspace) {
var workspace = screen.get_active_workspace();
show_notify("change workspace", @"Number $(workspace.get_name())");
}
public void show_notify(string sum, string body) {
var note = new Notify.Notification(sum, body, null);
note.set_timeout(3000);
note.set_urgency(Notify.Urgency.NORMAL);
try {
note.show();
} catch (GLib.Error err) {
}
}
public static int main(string[] args) {
Gdk.threads_init();
Gtk.init(ref args);
var test = new WorkspaceChanger();
test.register();
// Enter the Glib eventloop
// Everything from this point on is completely signal based
Gdk.threads_enter();
Gtk.main();
Gdk.threads_leave();
return 0;
}
}
}
Mem: Python ~30Mb, Vala: ~7Mb Speed is much grated since vala compiler translate code to c.
Please try =)
I think that performance and lower memory usage can be improvement. For this need to do such things: