From ecf3282df746aa0af7f61f67c58be4f043166268 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Thu, 5 Nov 2020 14:28:44 +0530 Subject: [PATCH 1/8] Add float for intervals so that refresh time can be 1.5 or 2.4 sec something like that --- preferences.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/preferences.py b/preferences.py index ed6d0c1..5d58a30 100644 --- a/preferences.py +++ b/preferences.py @@ -365,9 +365,9 @@ def update_parent(self, evnt=None, data=None): self.sensor_mgr.check(sensor) try: - interval = int(self.interval_entry.get_text()) - if interval <= 0: - raise ISMError(_("Interval value is not valid.")) + interval = float(self.interval_entry.get_text()) + if interval <1: + raise ISMError(_("Interval value should be greater then or equal to 1 ")) except ValueError: raise ISMError(_("Interval value is not valid.")) From 04d5c1a2ecac8e59411318cfe5fce9a6baca44e3 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Thu, 5 Nov 2020 15:26:42 +0530 Subject: [PATCH 2/8] Add Compact Net speed and Total net speed Just copied some code and did some here and their things --- budgiesysmonitor.py | 6 ++++++ sensors.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/budgiesysmonitor.py b/budgiesysmonitor.py index a0b7ea9..76c8a35 100644 --- a/budgiesysmonitor.py +++ b/budgiesysmonitor.py @@ -38,6 +38,8 @@ • mem: {mem_desc} • bat%d: {bat_desc} • net: {net_desc} +• netcomp: {netcomp_desc} +• totalnet: {totalnet_desc} • upordown: {upordown_desc} • publicip: {publicip_desc} @@ -56,6 +58,10 @@ bat_desc=_("It shows the available battery which id is %d."), net_desc=_("It shows the amount of data you are downloading and uploading \ through your network."), + netcomp_desc=_("It shows the amount of data you are downloading and uploading \ + through your network in a compact way."), + totalnet_desc=("It shows the total amount of data you downloaded and uploaded \ + through your network."), upordown_desc=_("It shows whether your internet connection is up or down \ - the sensor is refreshed every 10 seconds."), publicip_desc=_("It shows your public IP address \ diff --git a/sensors.py b/sensors.py index c9187c7..67f9905 100755 --- a/sensors.py +++ b/sensors.py @@ -70,6 +70,8 @@ def __init__(self): NvGPUSensor(), MemSensor(), NetSensor(), + NetCompSensor(), + TotalNetSensor(), BatSensor(), FSSensor(), SwapSensor(), @@ -472,6 +474,48 @@ def _fetch_net(self): current[1] /= mgr.get_interval() return '↓ {:>9s}/s ↑ {:>9s}/s'.format(bytes_to_human(current[0]), bytes_to_human(current[1])) +class NetCompSensor(BaseSensor): + name = 'netcomp' + desc = _('Network activity in Compact form.') + _last_net_usage = [0, 0] # (up, down) + + def get_value(self, sensor_data): + return self._fetch_net() + + def _fetch_net(self): + """It returns the bytes sent and received in bytes/second""" + current = [0, 0] + for _, iostat in list(ps.net_io_counters(pernic=True).items()): + current[0] += iostat.bytes_recv + current[1] += iostat.bytes_sent + dummy = copy.deepcopy(current) + + current[0] -= self._last_net_usage[0] + current[1] -= self._last_net_usage[1] + self._last_net_usage = dummy + mgr = SensorManager() + current[0] /= mgr.get_interval() + current[1] /= mgr.get_interval() + return '⇵ {:>9s}/s'.format(bytes_to_human(current[0] + current[1])) + +class TotalNetSensor(BaseSensor): + name = 'totalnet' + desc = _('Total Network activity.') + + def get_value(self, sensor_data): + return self._fetch_net() + + def _fetch_net(self): + """It returns total number the bytes sent and received""" + current = [0, 0] + for _, iostat in list(ps.net_io_counters(pernic=True).items()): + current[0] += iostat.bytes_recv + current[1] += iostat.bytes_sent + + mgr = SensorManager() + current[0] /= mgr.get_interval() + current[1] /= mgr.get_interval() + return ' Σ {:>9s}'.format(bytes_to_human(current[0] + current[1])) class BatSensor(BaseSensor): name = 'bat\d*' From a91c0b8fde7ba515b5015585d678da5adbb99661 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Thu, 5 Nov 2020 15:43:45 +0530 Subject: [PATCH 3/8] Update README.md --- README.md | 109 ++++-------------------------------------------------- 1 file changed, 7 insertions(+), 102 deletions(-) diff --git a/README.md b/README.md index 010c80f..10f9251 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,11 @@ -![indicator-sysmonitor](https://user-images.githubusercontent.com/9158844/37069705-90f272a2-21c5-11e8-806f-92b20cbf47ae.png) +Whats NEW : +\* *The following string are added:* -\* _Use following string to use custom preview that is shown above. (Proprietary Nvidia driver needed, must be running)_: - - CPU {cpu} {cputemp} | GPU {nvgpu} {nvgputemp} | MEM {mem} | SWAP {swap} - -Indicator-SysMonitor - v0.8.3 -=================== -An Application Indicator showing cpu temperature, memory, network speed, cpu usage, public IP address and internet connection status . - -Works with Unity, Xubuntu, Gnome-Shell + app-indicator extension together with any other desktop environments that support AppIndicators. - -Also works with the Budgie-Desktop - -Offers the possibility to run your own command and display its output. - ----- - -## Custom scripts - -Create your own scripts (for example in bash). Give the script execute permission (chmod +x scriptname) - -A script must output one line of text - e.g. using "echo" in bash - -The indicator can change the icon being displayed by recognising the output of a sensor "USE_ICON:full_path_to_.svg" - -## Set the display order of the indicator - -To force the indicator to appear on the left-side of all indicators you must use a override file as described here: - - - http://askubuntu.com/questions/26114/is-it-possible-to-change-the-order-of-icons-in-the-indicator-applet - ----- - -Installation - Budgie-Desktop: - -On budgie-desktop based installation - manual installation - - sudo apt-get install python3-psutil curl git - git clone https://github.com/fossfreedom/indicator-sysmonitor.git - cd indicator-sysmonitor - sudo make installbudgie - budgie-panel --replace & - - Then use Raven to add the "Panel Sys Monitor" applet - -Installation - App Indicator based desktops: - -On Ubuntu and derivatives - manual installation - - - sudo apt-get install python3-psutil curl git gir1.2-appindicator3-0.1 - git clone https://github.com/fossfreedom/indicator-sysmonitor.git - cd indicator-sysmonitor - sudo make install - nohup indicator-sysmonitor & + NetCompact {netcomp} | totalnet {totalnet} -To remove: - - cd indicator-sysmonitor - sudo make uninstall - -To install the AppIndicator via PPA: - - sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor - sudo apt-get update - sudo apt-get install indicator-sysmonitor - - Search in the dash for "indicator-sysmonitor" to run - -To install the Budgie Applet via PPA: - - open budgie-welcome - Install Software - Budgie Applets - -Changelog: - - - v0.8.3 - Rework fetch thread, README updates - - v0.8.2 - fix budgie-desktop crash and release debian package - - v0.8.1 - development - support budgie-desktop - - v0.8.0 - development - new sensor - cputemp, ability to use and change icons via a custom script - - v0.7.1 - bug fix to allow non-ubuntu kernels to be used - - v0.7.0 - new sensors - publicip and upordown. - - v0.6.3 - fixed the bug when display multiple CPU cores it always display the later ones as 0% - - v0.6.2 - bug fix to stop crash for custom sensors - - v0.6.1 - fix the debian packaging - - v0.6 - stable release - reworked to be easier to maintain - - v0.5 - GTK3 & Python3 based including bug-fix to display errors on using Test button - together with fixing crash reports when incorrect sensor values used - - v0.4.6 - bug fixes for battery indicator and for spurious overwrite when adding new sensor - - v0.4.5 - removed indicator icon since not needed - - v0.4.4 - fix dependencies and corrected shown indicator icon - - v0.4.3 - fork from original author - -Credits: - - - [24](https://github.com/fossfreedom/indicator-sysmonitor/pull/24) & [25](https://github.com/fossfreedom/indicator-sysmonitor/pull/25) SteveGuo https://github.com/SteveGuo - - [19](https://github.com/fossfreedom/indicator-sysmonitor/pull/19) & [37](https://github.com/fossfreedom/indicator-sysmonitor/pull/37) CPU & meminfo bug fixes Jesse Johnson https://github.com/holocronweaver - ----- - -Original Author: Alex Eftimie -https://launchpad.net/indicator-sysmonitor +In this version you can also set Interval time in milliseconds like 1.5sec etc... -Current fork maintainer: fossfreedom +Below is the Preview of new strings in Action on Budgie: +![Budgie Screenshot](https://user-images.githubusercontent.com/41370460/98227405-4ab9dd80-1f7d-11eb-9601-cc3e66c8718c.png) ----- +First one is Output of {netcomp} & other is the output of {totalnet} From e5ca8e040caf7fbee5e2f287220e11215dd69e13 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Thu, 5 Nov 2020 18:23:53 +0530 Subject: [PATCH 4/8] Degrade readme to orignal TO make PR easy --- README.md | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 102 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 10f9251..010c80f 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,106 @@ -Whats NEW : -\* *The following string are added:* +![indicator-sysmonitor](https://user-images.githubusercontent.com/9158844/37069705-90f272a2-21c5-11e8-806f-92b20cbf47ae.png) - NetCompact {netcomp} | totalnet {totalnet} +\* _Use following string to use custom preview that is shown above. (Proprietary Nvidia driver needed, must be running)_: + + CPU {cpu} {cputemp} | GPU {nvgpu} {nvgputemp} | MEM {mem} | SWAP {swap} + +Indicator-SysMonitor - v0.8.3 +=================== +An Application Indicator showing cpu temperature, memory, network speed, cpu usage, public IP address and internet connection status . + +Works with Unity, Xubuntu, Gnome-Shell + app-indicator extension together with any other desktop environments that support AppIndicators. + +Also works with the Budgie-Desktop + +Offers the possibility to run your own command and display its output. + +---- + +## Custom scripts + +Create your own scripts (for example in bash). Give the script execute permission (chmod +x scriptname) + +A script must output one line of text - e.g. using "echo" in bash + +The indicator can change the icon being displayed by recognising the output of a sensor "USE_ICON:full_path_to_.svg" + +## Set the display order of the indicator + +To force the indicator to appear on the left-side of all indicators you must use a override file as described here: + + - http://askubuntu.com/questions/26114/is-it-possible-to-change-the-order-of-icons-in-the-indicator-applet + +---- + +Installation - Budgie-Desktop: + +On budgie-desktop based installation - manual installation + + sudo apt-get install python3-psutil curl git + git clone https://github.com/fossfreedom/indicator-sysmonitor.git + cd indicator-sysmonitor + sudo make installbudgie + budgie-panel --replace & + + Then use Raven to add the "Panel Sys Monitor" applet + +Installation - App Indicator based desktops: + +On Ubuntu and derivatives - manual installation + + + sudo apt-get install python3-psutil curl git gir1.2-appindicator3-0.1 + git clone https://github.com/fossfreedom/indicator-sysmonitor.git + cd indicator-sysmonitor + sudo make install + nohup indicator-sysmonitor & -In this version you can also set Interval time in milliseconds like 1.5sec etc... +To remove: + + cd indicator-sysmonitor + sudo make uninstall + +To install the AppIndicator via PPA: + + sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor + sudo apt-get update + sudo apt-get install indicator-sysmonitor + + Search in the dash for "indicator-sysmonitor" to run + +To install the Budgie Applet via PPA: + + open budgie-welcome - Install Software - Budgie Applets + +Changelog: + + - v0.8.3 - Rework fetch thread, README updates + - v0.8.2 - fix budgie-desktop crash and release debian package + - v0.8.1 - development - support budgie-desktop + - v0.8.0 - development - new sensor - cputemp, ability to use and change icons via a custom script + - v0.7.1 - bug fix to allow non-ubuntu kernels to be used + - v0.7.0 - new sensors - publicip and upordown. + - v0.6.3 - fixed the bug when display multiple CPU cores it always display the later ones as 0% + - v0.6.2 - bug fix to stop crash for custom sensors + - v0.6.1 - fix the debian packaging + - v0.6 - stable release - reworked to be easier to maintain + - v0.5 - GTK3 & Python3 based including bug-fix to display errors on using Test button + together with fixing crash reports when incorrect sensor values used + - v0.4.6 - bug fixes for battery indicator and for spurious overwrite when adding new sensor + - v0.4.5 - removed indicator icon since not needed + - v0.4.4 - fix dependencies and corrected shown indicator icon + - v0.4.3 - fork from original author + +Credits: + + - [24](https://github.com/fossfreedom/indicator-sysmonitor/pull/24) & [25](https://github.com/fossfreedom/indicator-sysmonitor/pull/25) SteveGuo https://github.com/SteveGuo + - [19](https://github.com/fossfreedom/indicator-sysmonitor/pull/19) & [37](https://github.com/fossfreedom/indicator-sysmonitor/pull/37) CPU & meminfo bug fixes Jesse Johnson https://github.com/holocronweaver + +---- + +Original Author: Alex Eftimie +https://launchpad.net/indicator-sysmonitor -Below is the Preview of new strings in Action on Budgie: -![Budgie Screenshot](https://user-images.githubusercontent.com/41370460/98227405-4ab9dd80-1f7d-11eb-9601-cc3e66c8718c.png) +Current fork maintainer: fossfreedom -First one is Output of {netcomp} & other is the output of {totalnet} +---- From c7f02183f482702e23c74b400278f89c38d56e24 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Thu, 5 Nov 2020 19:15:59 +0530 Subject: [PATCH 5/8] Change KiB to KB --- sensors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sensors.py b/sensors.py index 67f9905..b6363df 100755 --- a/sensors.py +++ b/sensors.py @@ -27,16 +27,16 @@ ps_v1_api = int(ps.__version__.split('.')[0]) <= 1 -B_UNITS = ['', 'KB', 'MB', 'GB', 'TB'] +B_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'] cpu_load = [] -def bytes_to_human(num, suffix='B'): - for unit in ['','Ki','Mi','Gi','Ti','Pi','Ei','Zi']: +def bytes_to_human(num): + for unit in B_UNITS: if abs(num) < 1024.0: - return "%3.2f %s%s" % (num, unit, suffix) + return "%3.2f %s" % (num, unit) num /= 1024.0 - return "%.2f %s%s" % (num, 'Yi', suffix) + return "%.2f %s" % (num, 'YB') class ISMError(Exception): """General exception.""" From 81109f00e7de213bb5a9a5cdc2fbb70cc3520562 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Sat, 7 Nov 2020 19:21:20 +0530 Subject: [PATCH 6/8] Changing KiB -> KB by changing 1024 -> 1000 --- sensors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sensors.py b/sensors.py index b6363df..353674e 100755 --- a/sensors.py +++ b/sensors.py @@ -33,9 +33,9 @@ def bytes_to_human(num): for unit in B_UNITS: - if abs(num) < 1024.0: + if abs(num) < 1000.0: return "%3.2f %s" % (num, unit) - num /= 1024.0 + num /= 1000.0 return "%.2f %s" % (num, 'YB') class ISMError(Exception): From 255f5d5e4717c46cf135a9751647676efc611b63 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Sun, 8 Nov 2020 21:20:14 +0530 Subject: [PATCH 7/8] Remove unnecessary semicolon , pylint --- sensors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sensors.py b/sensors.py index 353674e..af83435 100755 --- a/sensors.py +++ b/sensors.py @@ -406,7 +406,7 @@ def _fetch_cpu(self, percpu=False): if percpu: return cpu_load - r = 0.0; + r = 0.0 for i in cpu_load: r += i From 78ca787457db627c22a126f3a0150a19af38c931 Mon Sep 17 00:00:00 2001 From: Prateek SU <41370460+prateekmedia@users.noreply.github.com> Date: Tue, 17 Nov 2020 19:22:03 +0530 Subject: [PATCH 8/8] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 010c80f..f99c9ad 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ ![indicator-sysmonitor](https://user-images.githubusercontent.com/9158844/37069705-90f272a2-21c5-11e8-806f-92b20cbf47ae.png) +![image](https://user-images.githubusercontent.com/41370460/98230824-9cfcfd80-1f81-11eb-9a68-2ac6e1c8adb9.png) + \* _Use following string to use custom preview that is shown above. (Proprietary Nvidia driver needed, must be running)_: - CPU {cpu} {cputemp} | GPU {nvgpu} {nvgputemp} | MEM {mem} | SWAP {swap} + CPU {cpu} {cputemp} | GPU {nvgpu} {nvgputemp} | MEM {mem} | SWAP {swap} | Net Speed Compact {netcomp} | Total Net Speed {totalnet} Indicator-SysMonitor - v0.8.3 ===================