! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
Patch to make icons change color based on cpu frequency


Description Gert Wollny 2015-08-08 15:34:08 CEST
Created attachment 6407 
Patch against v1.1.2, tested on Gentoo Linux.

This patch changes the icon display to let the color depend on the actual cpu frequency. At the lowest frequency state the color is green and in the highest it is redish. 

The icons are currently calculated on the fly from the original icon. If I find the time I might change this that a set of icons is created at startup based on the number of frequency states, but the computational overhead of the current implementation is probably not worth the effort.

Comment 1 Gert Wollny 2017-10-15 17:37:07 CEST
Created attachment 7371 
Updated patch against 1.1.3

This is an updated patch. Now the colour coding is stored in a g_hash_table with the key being
 ( cpu frequency >> 16 ). 

Comment 2 Andre Miranda editbugs 2018-09-20 04:49:08 CEST
Created attachment 7989 
Updated patch

First of all, sorry for the long time it took for someone to review your patch.

Patch updated to this branch (soon to be merged into master):

Here are my considerations:
- gtk_widget_queue_draw was not making any difference, I replaced it by firing a signal, works but it's a hack
- The icon tinting is nifty, but not perfect:
  - https://i.imgur.com/ukBCw3z.png
  - https://i.imgur.com/kfocv6n.png
  - https://i.imgur.com/dFZzAqb.png
- When need to introduce a checkbox to disable this in the property dialog
- Do not call cpufreq_update_pixmap if the icon is hidden

If you are still interested, let me know.
Comment 3 Andre Miranda editbugs 2018-09-22 22:12:00 CEST
Another way to accomplish this is to use pre rendered versions of xfce4-cpufreq-plugin.png, for instance 5 versions going from black to red, so we take the min and max freqs and make intervals of 20% for each image. In my opnion it's much more simpler than the proposed approach and the result is pretty much the same.
Comment 4 Gert Wollny 2018-10-05 09:26:25 CEST
Cool, I wanted to update the patch myself, because - as you noted - with gtk3 gtk_widget_queue_draw didn't work correctly, for me the icon was only updated when moving the  mouse over it. 

I guess pre-rendered icons are also okay, I only did it the way I did because different CPUs may support a different numbers of frequencies, and from the coding point of view it was simpler (no need to care about new image files) but in the end the only really important thing for me was that I can get an overview of the CPU load without the need to print the frequencies (I use a vertical panel, and there it gets a bit difficult), In summary, I'm happy with any way you add this feature as long as it is somehow available :)
Comment 5 Simon Steinbeiss editbugs 2020-05-22 23:34:45 CEST
Why not use a symbolic icon and change the foreground color (via a custom class) to change the color?
Comment 6 Git Bot editbugs 2020-05-22 23:35:47 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/panel-plugins/xfce4-cpufreq-plugin/-/issues/2.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #12124

Reported by:
Gert Wollny
Reported on: 2015-08-08
Last modified on: 2020-05-22


Harald Judt
CC List:
3 users



Patch against v1.1.2, tested on Gentoo Linux. (3.08 KB, patch)
2015-08-08 15:34 CEST , Gert Wollny
no flags
Updated patch against 1.1.3 (4.50 KB, patch)
2017-10-15 17:37 CEST , Gert Wollny
no flags
Updated patch (4.80 KB, patch)
2018-09-20 04:49 CEST , Andre Miranda
no flags

Additional information