diff --git a/x11-packages/xfce4-cpugraph-plugin/0001-cpu-data.patch b/x11-packages/xfce4-cpugraph-plugin/0001-cpu-data.patch new file mode 100644 index 000000000000000..2c3b52250cdecab --- /dev/null +++ b/x11-packages/xfce4-cpugraph-plugin/0001-cpu-data.patch @@ -0,0 +1,80 @@ +diff --git a/panel-plugin/os.cc b/panel-plugin/os.cc +index a8c9e40..887c5f3 100644 +--- a/panel-plugin/os.cc ++++ b/panel-plugin/os.cc +@@ -42,6 +42,11 @@ + + using namespace std; + ++#ifdef __ANDROID__ ++#include ++#include ++#endif ++ + #if defined (__linux__) || defined (__FreeBSD_kernel__) + #define PROC_STAT "/proc/stat" + #define PROCMAXLNLEN 256 /* should make it */ +@@ -78,7 +83,7 @@ using namespace std; + static kstat_ctl_t *kc; + #endif + +-#if defined (__linux__) || defined (__FreeBSD_kernel__) ++#if (defined (__linux__) && !defined (__ANDROID__)) || defined (__FreeBSD_kernel__) + void + read_cpu_data (unordered_map &data, unordered_map &cpu_to_index) + { +@@ -401,12 +406,53 @@ read_cpu_data (unordered_map &data) + data[0].load /= nb_cpu; + return true; + } ++#elif defined (__ANDROID__) ++ ++static guint ++detect_cpu_number () ++{ ++ return sysconf(_SC_NPROCESSORS_ONLN); ++} ++ ++static bool ++read_cpu_data (unordered_map &data) ++{ ++ FILE* top_process; ++ int pid; ++ float cpu_usage; ++ int cpu_index; ++ char line[100]; ++ ++ if (G_UNLIKELY(data.size() == 0)) ++ return false; ++ ++ const size_t nb_cpu = data.size()-1; ++ ++ for (int i = 0; i <= nb_cpu; i++) { ++ data[i].user = 0; ++ data[i].load = 0; ++ } ++ ++ if ((top_process = popen("top -H -b -q -o TID,%CPU,CPU -s 2 -n 1", "r"))) { ++ while (fgets(line, sizeof(line), top_process) != NULL) { ++ if (sscanf(line, "%d %f %d", &pid, &cpu_usage, &cpu_index) == 3) { ++ data[cpu_index+1].user += cpu_usage / 100; ++ data[cpu_index+1].load += cpu_usage / 100; ++ data[0].user += cpu_usage / 100 / nb_cpu; ++ data[0].load += cpu_usage / 100 / nb_cpu; ++ if (cpu_usage < 0.05) break; ++ } ++ } ++ pclose(top_process); ++ } ++ return true; ++} + #else + #error "Your OS is not supported." + #endif + + +-#if !(defined (__linux__) || defined (__FreeBSD_kernel__)) ++#if !(defined (__linux__) || defined (__FreeBSD_kernel__)) || defined (__ANDROID__) + void + read_cpu_data (unordered_map &data, unordered_map &cpu_to_index) + { diff --git a/x11-packages/xfce4-cpugraph-plugin/build.sh b/x11-packages/xfce4-cpugraph-plugin/build.sh new file mode 100644 index 000000000000000..bc101e7f3a9a231 --- /dev/null +++ b/x11-packages/xfce4-cpugraph-plugin/build.sh @@ -0,0 +1,13 @@ +TERMUX_PKG_HOMEPAGE=https://docs.xfce.org/panel-plugins/xfce4-cpugraph-plugin/start +TERMUX_PKG_DESCRIPTION="Graphical representation of the CPU load" +TERMUX_PKG_LICENSE="GPL-2.0" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION="1.2.10" +TERMUX_PKG_SRCURL=https://archive.xfce.org/src/panel-plugins/xfce4-cpugraph-plugin/${TERMUX_PKG_VERSION%.*}/xfce4-cpugraph-plugin-${TERMUX_PKG_VERSION}.tar.bz2 +TERMUX_PKG_SHA256=37792dd052691712195658169b95fb6583f924485ce7a467b33d01e08775d915 +TERMUX_PKG_AUTO_UPDATE=true +TERMUX_PKG_DEPENDS="xfce4-panel" + +termux_step_pre_configure() { + LDFLAGS+=" $($CC -print-libgcc-file-name)" +}