Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance System Monitoring with a TUI #810

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

LAITH343
Copy link

Summary

This PR introduces a Terminal User Interface (TUI) using urwid to improve the visualization of system information, monitoring, and live statistics.

Changes

  • Added a system info module to retrieve all necessary system details.
  • Implemented a system monitor module to manage the TUI using urwid.
  • Fixed an issue with set_autofreq() where avg_all_core_temp was undefined when running in a separate thread.

Showcase

Visual-Rework-Showcase.mp4

- created a system info module
- created system monitor module
- fixed avg_all_core_temp not defined
@AdnanHodzic
Copy link
Owner

AdnanHodzic commented Feb 21, 2025

While I'll miss the "old cli look" due to nostalgic reasons :)

This looks great, gives a better overview and is just a great improvement overall with updates to the "metrics".

However, when I try to use sudo auto-cpufreq --stats command after auto-cpufreq is installed using a snap package I get following error:

sudo auto-cpufreq --stats            

Using settings defined in /etc/auto-cpufreq.conf file

----------------------------------- Warning -----------------------------------

Due to Snap package confinement limitations please consider installing auto-cpufreq using
auto-cpufreq-installer: https://github.com/AdnanHodzic/auto-cpufreq#auto-cpufreq-installer

Unable to detect state of GNOME Power Profiles daemon service!
This daemon might interfere with auto-cpufreq and should be disabled!

Steps to perform this action using auto-cpufreq: power_helper script:
git clone https://github.com/AdnanHodzic/auto-cpufreq.git
cd auto-cpufreq/auto_cpufreq
python3 power_helper.py --gnome_power_disable

Reference: https://github.com/AdnanHodzic/auto-cpufreq#configuring-auto-cpufreq

----------------------------------- Warning -----------------------------------

Unable to detect if you are using a TLP service!
This daemon might interfere with auto-cpufreq which can lead to unexpected results.
We strongly encourage you not to use TLP unless you really know what you are doing.
press Enter to continue or Ctrl + c to exit...
Traceback (most recent call last):
  File "/snap/auto-cpufreq/155/bin/auto-cpufreq", line 8, in <module>
    sys.exit(main())
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/click/core.py", line 1161, in __call__
    return self.main(*args, **kwargs)
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/click/core.py", line 1082, in main
    rv = self.invoke(ctx)
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/click/core.py", line 1443, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/click/core.py", line 788, in invoke
    return __callback(*args, **kwargs)
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/auto_cpufreq/bin/auto_cpufreq.py", line 233, in main
    monitor.run()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/auto_cpufreq/modules/system_monitor.py", line 292, in run
    self.loop.run()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 337, in run
    self._run()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 439, in _run
    self.event_loop.run()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/urwid/event_loop/select_loop.py", line 182, in run
    self._loop()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/urwid/event_loop/select_loop.py", line 224, in _loop
    alarm_callback()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/urwid/event_loop/main_loop.py", line 218, in cb
    callback(self, user_data)
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/auto_cpufreq/modules/system_monitor.py", line 98, in update
    report: SystemReport = system_info.generate_system_report()
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/auto_cpufreq/modules/system_info.py", line 278, in generate_system_report
    battery_info=self.battery_info(),
  File "/snap/auto-cpufreq/155/lib/python3.10/site-packages/auto_cpufreq/modules/system_info.py", line 190, in battery_info
    output = getoutput(
TypeError: getoutput() got an unexpected keyword argument 'encoding'

It would be great to fix this before changes are merged.

Another thing I noticed during testing is that auto-cpufreq GUI is inconsistent with CLI output and is missing i.e "System Statistics" header. Would be ideal if they both had same layout.

@LAITH343
Copy link
Author

However, when I try to use sudo auto-cpufreq --stats command after auto-cpufreq is installed using a snap package I get following error:

the error is now fixed but i didn't build a snap package to verify it. try it and tell me if there's any errors

Another thing I noticed during testing is that auto-cpufreq GUI is inconsistent with CLI output and is missing i.e "System Statistics" header. Would be ideal if they both had same layout.

i don't know how the GUI built so maybe the GUI author can help with this, but for the TUI i can change the design if you want

@AdnanHodzic
Copy link
Owner

However, when I try to use sudo auto-cpufreq --stats command after auto-cpufreq is installed using a snap package I get following error:

the error is now fixed but i didn't build a snap package to verify it. try it and tell me if there's any errors

Thanks! I just pulled the latest changes, built the snap package and it all seems to work as expected!

Another thing I noticed during testing is that auto-cpufreq GUI is inconsistent with CLI output and is missing i.e "System Statistics" header. Would be ideal if they both had same layout.

i don't know how the GUI built so maybe the GUI author can help with this

@shadeyg56 as the original implementer of GUI, any comments or suggestions regarding this?

but for the TUI i can change the design if you want

Out of curiosity, what are the design or color options?

@LAITH343
Copy link
Author

Thanks! I just pulled the latest changes, built the snap package and it all seems to work as expected!

Nice :)

Out of curiosity, what are the design or color options?

most of the colors are supported check urwid Display Attributes docs and you can apply the color in auto_cpufreq/modules/system_monitor.py line 65 to see how to looks

for the layout options check urwid widget layout docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants