indicator-doom-cpu: add a patch for python3

This commit is contained in:
Michal Vasilek 2022-01-26 17:28:19 +01:00
parent 5ff3fb79e3
commit b20d097913
2 changed files with 102 additions and 4 deletions

View file

@ -0,0 +1,99 @@
--- 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__':

View file

@ -1,15 +1,14 @@
# Template file for 'indicator-doom-cpu' # Template file for 'indicator-doom-cpu'
pkgname=indicator-doom-cpu pkgname=indicator-doom-cpu
version=1.0.1 version=1.0.1
revision=2 revision=3
depends="python-gobject" depends="python3-gobject gtk+3 libappindicator"
short_desc="CPU load indicator showing the dying face from the video game DOOM" short_desc="CPU load indicator showing the dying face from the video game DOOM"
maintainer="Andrea Brancaleoni <abc@pompel.me>" maintainer="Andrea Brancaleoni <abc@pompel.me>"
license="GPL-3.0-only" license="GPL-3.0-only"
homepage="https://github.com/ebruck/indicator-doom-cpu" homepage="https://github.com/ebruck/indicator-doom-cpu"
distfiles="${homepage}/archive/v${version}.tar.gz" distfiles="https://github.com/ebruck/indicator-doom-cpu/archive/v${version}.tar.gz"
checksum=87dcb082c5032518b2616c85967ac92cf3618b6e0276266ec413537b6256c7d5 checksum=87dcb082c5032518b2616c85967ac92cf3618b6e0276266ec413537b6256c7d5
python_version=2
do_install() { do_install() {
vinstall $pkgname 755 usr/share/indicator-doom-cpu vinstall $pkgname 755 usr/share/indicator-doom-cpu