Commit Diff


commit - 8f16cb3ee7a8516f90d4d7109d26d49f0cf9255d
commit + c440ada7313356339c7a6cc7784eec32c7032de8
blob - /dev/null
blob + 272690931dda27225d0cdee325cc54712c8f7558 (mode 644)
--- /dev/null
+++ LICENSE
@@ -0,0 +1,13 @@
+Copyright (c) 2024 Benjamin Stürz <benni@stuerz.xyz>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
blob - 56149b80cc8e9511fe07dc44643972135aa79857
blob + d4d16fb114b495e953a8da848f444e2a96379b48
--- apmtop.c
+++ apmtop.c
@@ -1,3 +1,18 @@
+/*
+ * Copyright (c) 2024 Benjamin Stürz <benni@stuerz.xyz>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
 #include <sys/types.h>
 #include <machine/apmvar.h>
 #include <sys/signal.h>
@@ -5,6 +20,7 @@
 #include <sys/sysctl.h>
 #include <sys/ioctl.h>
 #include <sys/sensors.h>
+
 #include <stdbool.h>
 #include <ncurses.h>
 #include <locale.h>
@@ -328,6 +344,10 @@ main (int argc, char *argv[])
 {
 	struct display dpy;
 
+	// pledge(2) doesn't work, because apmtop(1) needs sysctl(2).
+	unveil ("/usr/share/terminfo", "r");
+	unveil (NULL, NULL);
+
 	memset (&dpy, 0, sizeof (dpy));
 	dpy.ncpu = num_cpu ();
 	dpy.cpus = calloc (dpy.ncpu, sizeof (struct cpu_usage));
blob - /dev/null
blob + 05c21d3f7f856376af565647df3e82fb3cad55b2 (mode 644)
--- /dev/null
+++ README.md
@@ -0,0 +1,17 @@
+# apmtop
+Monitor power-consuption-related statistics on OpenBSD.
+
+## Installation
+```sh
+$ make
+# make install
+```
+
+## TODO
+- getopt(3)
+- Better error handling
+- Code looks a little ugly
+- Bonus: calculate the cpuspeed() multiple times, between calls to update(),
+  and average the result, to make the measurments more precise
+  (cpuspeed can jump a lot, even within 100ms)
+- Bonus: follow style(9)