lxpanel: add patch to fix armhf cpufreq plugin build.

This commit is contained in:
Ark74 2025-07-14 03:54:25 -06:00
parent 5b65330e61
commit abdd7515d1
2 changed files with 119 additions and 1 deletions

View file

@ -0,0 +1,117 @@
diff --git a/plugins/cpufreq/cpufreq.c b/plugins/cpufreq/cpufreq.c
index 9e1bb0f1..34e781f0 100644
--- a/plugins/cpufreq/cpufreq.c
+++ b/plugins/cpufreq/cpufreq.c
@@ -2,6 +2,7 @@
* CPUFreq plugin to lxpanel
*
* Copyright (C) 2009 by Daniel Kesler <kesler.daniel@gmail.com>
+ * 2025 Ingo Brückl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,7 +33,7 @@
#include "dbg.h"
-#define PROC_ICON "cpufreq-icon"
+#define PROC_ICON "cpufreq"
#define SYSFS_CPU_DIRECTORY "/sys/devices/system/cpu"
#define SCALING_GOV "scaling_governor"
#define SCALING_AGOV "scaling_available_governors"
@@ -114,7 +115,7 @@ get_governors(cpufreq *cf){
cf->governors = NULL;
return;
}
- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_AGOV);
+ snprintf(sstmp, sizeof(sstmp), "%s/%s", cf->cpus->data, SCALING_AGOV);
if (!(fp = fopen( sstmp, "r"))) {
printf("cpufreq: cannot open %s\n",sstmp);
@@ -178,13 +179,21 @@ cpufreq_set_governor(GtkWidget *widget, Param* p) {
set_gov(curr->data, p->data);
}
+static gboolean
+permission(cpufreq *cf, const char* file) {
+ char path [ 256 ];
+
+ snprintf(path, sizeof(path), "%s/%s", cf->cpus->data, file);
+ return (g_access(path, W_OK) == 0);
+}
+
static GtkWidget *
frequency_menu(cpufreq *cf){
FILE *fp;
Param* param;
char buf[ 100 ], sstmp [ 256 ], c, bufl = 0;
- sprintf(sstmp,"%s/%s",cf->cpus->data, SCALING_AFREQ);
+ snprintf(sstmp, sizeof(sstmp), "%s/%s", cf->cpus->data, SCALING_AFREQ);
if (!(fp = fopen( sstmp, "r"))) {
printf("cpufreq: cannot open %s\n",sstmp);
@@ -199,7 +208,7 @@ frequency_menu(cpufreq *cf){
if(bufl > 1){
buf[bufl] = '\0';
menuitem = gtk_menu_item_new_with_label(strdup(buf));
- gtk_menu_append (GTK_MENU_SHELL (menu), menuitem);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
gtk_widget_show (menuitem);
param = g_new0(Param, 1);
param->data = strdup(buf);
@@ -259,6 +268,7 @@ static GtkWidget *
cpufreq_menu(cpufreq *cf){
GList *l;
GSList *group;
+ gboolean can_write;
char buff[100];
GtkMenuItem* menuitem;
Param* param;
@@ -270,33 +280,39 @@ cpufreq_menu(cpufreq *cf){
group = NULL;
if((cf->governors == NULL) || (!cf->has_cpufreq) || (cf->cur_governor == NULL)){
- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label("CPUFreq not supported"));
- gtk_menu_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
+ menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(_("CPUFreq not supported")));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
gtk_widget_show (GTK_WIDGET (menuitem));
return GTK_WIDGET(menu);
}
+ can_write = permission(cf, SCALING_SETFREQ);
+
if(strcmp(cf->cur_governor, "userspace") == 0){
- menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(" Frequency"));
- gtk_menu_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
+ menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(_(" Frequency")));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
+ gtk_widget_set_sensitive (GTK_WIDGET (menuitem), can_write);
gtk_widget_show (GTK_WIDGET (menuitem));
gtk_menu_item_set_submenu(menuitem, frequency_menu(cf));
menuitem = GTK_MENU_ITEM(gtk_separator_menu_item_new());
- gtk_menu_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
gtk_widget_show (GTK_WIDGET(menuitem));
}
+ can_write = permission(cf, SCALING_GOV);
+
for( l = cf->governors; l; l = l->next )
{
if(strcmp((char*)l->data, cf->cur_governor) == 0){
- sprintf(buff,"> %s", l->data);
+ snprintf(buff, sizeof(buff), "▸ %s", l->data);
menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(strdup(buff)));
}else{
- sprintf(buff," %s", l->data);
+ snprintf(buff, sizeof(buff), " %s", l->data);
menuitem = GTK_MENU_ITEM(gtk_menu_item_new_with_label(strdup(buff)));
}
gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (menuitem));
+ gtk_widget_set_sensitive (GTK_WIDGET (menuitem), can_write);
gtk_widget_show (GTK_WIDGET (menuitem));
param = g_new0(Param, 1);
param->data = l->data;

View file

@ -17,7 +17,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# #
VERSION=1 VERSION=2
. ./config . ./config
@ -31,6 +31,7 @@ changelog "Backport patches from upstream lxpanel to improve stability and funct
Prevent wincmd plugin from triggering button clicks incorrectly (MR#78). Prevent wincmd plugin from triggering button clicks incorrectly (MR#78).
Avoid panel freeze caused by pop-down menu detach (MR#84). Avoid panel freeze caused by pop-down menu detach (MR#84).
Restore disabled functionality in cpufreq plugin (MR#89, 4 commits). Restore disabled functionality in cpufreq plugin (MR#89, 4 commits).
Add debian changes to fix armhf cpufreq plugin.
These changes improve reliability in power and task management plugins." These changes improve reliability in power and task management plugins."