Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public const int [] higher_pid = {}; //lower nice value
- public const int [] lower_pid = {}; //higher nice value
- public enum Priority {
- LOW = 15,
- NORMAL = 0,
- HIGH = -15
- }
- public static void main (string [] args) {
- Gdk.init (ref args);
- for (var i=0;i<higher_pid.length;i++)
- set_priority (higher_pid, Priority.HIGH);
- for (var i=0;i<lower_pid.length;i++)
- set_priority (higher_pid, Priority.LOW);
- var screen = Wnck.Screen.get_default ();
- screen.active_window_changed.connect ( (prev) => {
- if (prev != null)
- set_priority (prev.get_pid (), Priority.NORMAL);
- set_priority (screen.get_active_window ().get_pid (), Priority.HIGH);
- });
- var m = new MainLoop ();
- m.run ();
- }
- public static void set_priority (int pid, Priority p) {
- try {
- Process.spawn_command_line_sync ("renice "+((int)p).to_string ()+" -p "+pid.to_string ());
- } catch (Error e) { warning (e.message); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement