100 lines
3.1 KiB
Diff
100 lines
3.1 KiB
Diff
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -24,7 +24,10 @@ APP_AUTHORS = [a[10:] for a in str.splitlines(APP_LICENCE) if a.startswith("Copy
|
|
import os
|
|
import time
|
|
|
|
-from gi.repository import Gtk, GObject, GdkPixbuf
|
|
+from gi import require_version
|
|
+require_version('Gtk', '3.0')
|
|
+
|
|
+from gi.repository import Gtk, GLib, GObject, GdkPixbuf
|
|
|
|
try:
|
|
from gi.repository import AppIndicator3 as AppIndicator
|
|
@@ -129,7 +132,7 @@ class AbstractDOOMCPUIndicator(object):
|
|
image_idx = cpu_load / (100/(APP_NUM_IMAGES-1))
|
|
|
|
if image_idx != self.previous_image_idx:
|
|
- self.set_icon(APP_IMAGES[image_idx])
|
|
+ self.set_icon(APP_IMAGES[image_idx])
|
|
|
|
if cpu_load != self.previous_cpu_load:
|
|
self.cpu_load_menu_item.set_label('CPU: %d%%' % int(cpu_load))
|
|
@@ -145,7 +148,7 @@ class AbstractDOOMCPUIndicator(object):
|
|
AboutDialog()
|
|
|
|
def set_icon(self, icon):
|
|
- pass
|
|
+ pass
|
|
|
|
def run(self):
|
|
Gtk.main()
|
|
@@ -162,8 +165,8 @@ class DOOMCPUIndicator(AbstractDOOMCPUIndicator):
|
|
self.app_indicator.set_menu(self.menu)
|
|
|
|
def set_icon(self, icon):
|
|
- super(DOOMCPUIndicator, self).set_icon(icon)
|
|
- self.app_indicator.set_icon(icon)
|
|
+ super(DOOMCPUIndicator, self).set_icon(icon)
|
|
+ self.app_indicator.set_icon(icon)
|
|
|
|
|
|
class DOOMCPUStatusIcon(AbstractDOOMCPUIndicator):
|
|
|
|
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -1,4 +1,4 @@
|
|
-#!/usr/bin/env python
|
|
+#!/usr/bin/env python3
|
|
APP_LICENCE = '''
|
|
Copyright (C) 2014 Edward G. Bruck <ed.bruck1@gmail.com>
|
|
Copyright (C) 2017 Andrea Brancaleoni <miwaxe@gmail.com>
|
|
|
|
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -53,7 +53,7 @@ class CPUsage:
|
|
self.result = self.compute()
|
|
|
|
def get_time(self):
|
|
- stat_file = file('/proc/stat', 'r')
|
|
+ stat_file = open('/proc/stat', 'r')
|
|
time_list = stat_file.readline().split(' ')[2:6]
|
|
stat_file.close()
|
|
for i in range(len(time_list)):
|
|
|
|
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -99,7 +99,7 @@ class AboutDialog(Gtk.AboutDialog):
|
|
class AbstractDOOMCPUIndicator(object):
|
|
def __init__(self):
|
|
global APP_IMAGES
|
|
- GObject.timeout_add(1000, self.on_update_timer)
|
|
+ GLib.timeout_add(1000, self.on_update_timer)
|
|
|
|
self.menu_item = None
|
|
self.cpu_load_menu_item = None
|
|
|
|
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -130,7 +130,7 @@ class AbstractDOOMCPUIndicator(object):
|
|
def on_update_timer(self):
|
|
global APP_IMAGES, APP_NUM_IMAGES
|
|
cpu_load = int(CPUsage(interval=0.2).result)
|
|
- image_idx = cpu_load / (100/(APP_NUM_IMAGES-1))
|
|
+ image_idx = int(cpu_load / (100/(APP_NUM_IMAGES-1)))
|
|
|
|
if image_idx != self.previous_image_idx:
|
|
self.set_icon(APP_IMAGES[image_idx])
|
|
|
|
--- a/indicator-doom-cpu
|
|
+++ b/indicator-doom-cpu
|
|
@@ -180,6 +180,7 @@ class DOOMCPUStatusIcon(AbstractDOOMCPUIndicator):
|
|
|
|
def set_icon(self, icon):
|
|
super(DOOMCPUStatusIcon, self).set_icon(icon)
|
|
+ self.icon_indicator = Gtk.StatusIcon() # Werks
|
|
self.icon_indicator.set_from_file(icon)
|
|
|
|
if __name__ == '__main__':
|