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.
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 ).
Created attachment 7989
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:
- 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.
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.
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 :)
Why not use a symbolic icon and change the foreground color (via a custom class) to change the color?
-- 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