[hackers] [slstatus] Fix typo in temperature || Aaron Marcher

2018-04-29 Thread git
commit c3ce506b7fe4c9615c8bf1b6936dd235d6c04750
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 22:44:09 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 22:44:09 2018 +0200

Fix typo in temperature

diff --git a/components/temperature.c b/components/temperature.c
index a5df012..e2c6a77 100644
--- a/components/temperature.c
+++ b/components/temperature.c
@@ -35,7 +35,7 @@ temp(const char *null)
 
size = sizeof(temp);
 
-   if (sysctl(mib, 5, &temp, &sz, NULL, 0) == -1) {
+   if (sysctl(mib, 5, &temp, &size, NULL, 0) == -1) {
fprintf(stderr, "sysctl 'SENSOR_TEMP': %s\n", strerror(errno));
return NULL;
}



[hackers] [slstatus] Update README for OpenBSD build || Aaron Marcher

2018-04-29 Thread git
commit 4113a39ee6a13e37797cff53626253c4bc094482
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 22:33:15 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 22:33:15 2018 +0200

Update README for OpenBSD build

diff --git a/README b/README
index 14544dc..b6f2961 100644
--- a/README
+++ b/README
@@ -37,7 +37,7 @@ In order to build slstatus you need the Xlib header files.
 Installation
 
 Edit config.mk to match your local setup (slstatus is installed into the
-/usr/local namespace by default).
+/usr/local namespace by default). Uncomment OSSLIBS on OpenBSD.
 
 Afterwards enter the following command to build and install slstatus (if
 necessary as root):



[hackers] [slstatus] battery: Separate function for readbility || Aaron Marcher

2018-04-29 Thread git
commit 09950055baa8ef17ba3ccee8bbe391de3110cc6f
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 20:02:42 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 20:02:42 2018 +0200

battery: Separate function for readbility

diff --git a/components/battery.c b/components/battery.c
index 75f2945..955d8ab 100644
--- a/components/battery.c
+++ b/components/battery.c
@@ -14,17 +14,21 @@
 
 #include "../util.h"
 
+#if defined(__linux__)
 const char *
 battery_perc(const char *bat)
 {
-#if defined(__linux__)
int perc;
char path[PATH_MAX];
 
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, 
"/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
   bprintf("%d", perc) : NULL;
+}
 #elif defined(__OpenBSD__)
+const char *
+battery_perc(const char *null)
+{
struct apm_power_info apm_info;
int fd;
 
@@ -42,8 +46,8 @@ battery_perc(const char *bat)
close(fd);
 
return bprintf("%d", apm_info.battery_life);
-#endif
 }
+#endif
 
 #if defined(__linux__)
 const char *



[hackers] [slstatus] uptime: Separate function for readbility || Aaron Marcher

2018-04-29 Thread git
commit 273d3db573e55e5160c0697afbbb3c29781e961e
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 20:07:09 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 20:07:09 2018 +0200

uptime: Separate function for readbility

diff --git a/components/uptime.c b/components/uptime.c
index a3082f2..debe4cb 100644
--- a/components/uptime.c
+++ b/components/uptime.c
@@ -11,18 +11,31 @@
 
 #include "../util.h"
 
+#if defined(__linux__)
 const char *
 uptime(void)
 {
int h;
int m;
int uptime = 0;
-#if defined(__linux__)
struct sysinfo info;
 
sysinfo(&info);
uptime = info.uptime;
+
+   h = uptime / 3600;
+   m = (uptime - h * 3600) / 60;
+
+   return bprintf("%dh %dm", h, m);
+}
 #elif defined(__OpenBSD__)
+const char *
+uptime(void)
+{
+   int h;
+   int m;
+   int uptime = 0;
+
int mib[2];
size_t size;
time_t now;
@@ -41,9 +54,10 @@ uptime(void)
fprintf(stderr, "sysctl 'KERN_BOOTTIME': %s\n", 
strerror(errno));
return NULL;
}
-#endif
+
h = uptime / 3600;
m = (uptime - h * 3600) / 60;
 
return bprintf("%dh %dm", h, m);
 }
+#endif



[hackers] [slstatus] ram: Move up includes || Aaron Marcher

2018-04-29 Thread git
commit cee6811036382215975792af4fa4f1624fc86a43
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 20:00:38 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 20:00:38 2018 +0200

ram: Move up includes

diff --git a/components/ram.c b/components/ram.c
index b200882..55ec5b9 100644
--- a/components/ram.c
+++ b/components/ram.c
@@ -1,5 +1,11 @@
 /* See LICENSE file for copyright and license details. */
 #include 
+#if defined (__OpenBSD__)
+#include 
+#include 
+#include 
+#include 
+#endif
 
 #include "../util.h"
 
@@ -52,11 +58,6 @@ ram_used(void)
   NULL;
 }
 #elif defined(__OpenBSD__)
-#include 
-#include 
-#include 
-#include 
-
 inline int
 load_uvmexp(struct uvmexp *uvmexp)
 {



[hackers] [slstatus] Sort LICENSE according to first commit || Aaron Marcher

2018-04-29 Thread git
commit 7baad64a4b26673b170b110899bdab0ebbdfd761
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 18:50:44 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 18:50:44 2018 +0200

Sort LICENSE according to first commit

diff --git a/LICENSE b/LICENSE
index c3de995..ae87dc6 100644
--- a/LICENSE
+++ b/LICENSE
@@ -5,10 +5,10 @@ Copyright 2016-2018 Aaron Marcher 
 Copyright 2016 Roy Freytag 
 Copyright 2016 Vincent Loupmon 
 Copyright 2016 Daniel Walter 
+Copyright 2016-2018 Ali H. Fardan 
 Copyright 2016 Jody Leonard 
-Copyright 2016 Mike Coddington 
 Copyright 2016-2017 Quentin Rameau 
-Copyright 2016-2018 Ali H. Fardan 
+Copyright 2016 Mike Coddington 
 Copyright 2016-2018 parazyd 
 Copyright 2017 Tobias Stoeckmann 
 Copyright 2017 Laslo Hunhold 



[hackers] [slstatus] temp: Port to OpenBSD || Aaron Marcher

2018-04-29 Thread git
commit 489c6f87d1d19831a7d43840dd76b111d657750b
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 18:35:41 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 18:35:41 2018 +0200

temp: Port to OpenBSD

In OpenBSD temperature gets fetched using sysctl now.

diff --git a/README b/README
index 6753c35..14544dc 100644
--- a/README
+++ b/README
@@ -66,4 +66,3 @@ The following functions are not portable at the moment:
 - entropy
 - swap_{free,perc,total,used}
 - battery_{power,state}
-- temp
diff --git a/components/temperature.c b/components/temperature.c
index 4a447e5..a5df012 100644
--- a/components/temperature.c
+++ b/components/temperature.c
@@ -1,9 +1,16 @@
 /* See LICENSE file for copyright and license details. */
-#if defined(__linux__)
+#include 
 #include 
+#include 
+#if defined(__OpenBSD__)
+#include 
+#include 
+#include 
+#endif
 
 #include "../util.h"
 
+#if defined(__linux__)
 const char *
 temp(const char *file)
 {
@@ -12,4 +19,27 @@ temp(const char *file)
return (pscanf(file, "%d", &temp) == 1) ?
   bprintf("%d", temp / 1000) : NULL;
 }
+#elif defined(__OpenBSD__)
+const char *
+temp(const char *null)
+{
+   int mib[5];
+   size_t size;
+   struct sensor temp;
+
+   mib[0] = CTL_HW;
+   mib[1] = HW_SENSORS;
+   mib[2] = 0; /* cpu0 */
+   mib[3] = SENSOR_TEMP;
+   mib[4] = 0; /* temp0 */
+
+   size = sizeof(temp);
+
+   if (sysctl(mib, 5, &temp, &sz, NULL, 0) == -1) {
+   fprintf(stderr, "sysctl 'SENSOR_TEMP': %s\n", strerror(errno));
+   return NULL;
+   }
+
+   return bprintf("%d", (temp.value - 27315) / 100); /* kelvin to 
celsius */
+}
 #endif



[hackers] [slstatus] Add OpenBSD support in volume.c || parazyd

2018-04-29 Thread git
commit d66e775c8d6e4ac77b808a276c80933770c35ec6
Author: parazyd 
AuthorDate: Sun Apr 29 15:41:18 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 15:57:17 2018 +0200

Add OpenBSD support in volume.c

diff --git a/components/volume.c b/components/volume.c
index 4c9a6ac..7c831c9 100644
--- a/components/volume.c
+++ b/components/volume.c
@@ -1,8 +1,11 @@
 /* See LICENSE file for copyright and license details. */
-#if defined(__linux__)
 #include 
 #include 
-#include 
+#if defined(__OpenBSD__)
+# include 
+#else
+# include 
+#endif
 #include 
 #include 
 #include 
@@ -42,4 +45,3 @@ vol_perc(const char *card)
 
return bprintf("%d", v & 0xff);
 }
-#endif
diff --git a/config.mk b/config.mk
index 9369843..a148da4 100644
--- a/config.mk
+++ b/config.mk
@@ -10,11 +10,14 @@ MANPREFIX = ${PREFIX}/share/man
 X11INC = /usr/X11R6/include
 X11LIB = /usr/X11R6/lib
 
+# OpenBSD (uncomment)
+#OSSLIBS = -lossaudio
+
 # flags
 CPPFLAGS = -I$(X11INC) -D_DEFAULT_SOURCE
 CFLAGS   = -std=c99 -pedantic -Wall -Wextra -Os
 LDFLAGS  = -L$(X11LIB) -s
-LDLIBS   = -lX11
+LDLIBS   = -lX11 ${OSSLIBS}
 
 # compiler and linker
 CC = cc



[hackers] [slstatus] Update LICENSE for parazyd || Aaron Marcher

2018-04-29 Thread git
commit 57b1c1719f26755ae7d1567b65d6d74af4b607c9
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 16:05:53 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 16:05:53 2018 +0200

Update LICENSE for parazyd

diff --git a/LICENSE b/LICENSE
index 60c18e3..c3de995 100644
--- a/LICENSE
+++ b/LICENSE
@@ -7,9 +7,9 @@ Copyright 2016 Vincent Loupmon 
 Copyright 2016 Daniel Walter 
 Copyright 2016 Jody Leonard 
 Copyright 2016 Mike Coddington 
-Copyright 2016-2017 parazyd 
 Copyright 2016-2017 Quentin Rameau 
 Copyright 2016-2018 Ali H. Fardan 
+Copyright 2016-2018 parazyd 
 Copyright 2017 Tobias Stoeckmann 
 Copyright 2017 Laslo Hunhold 
 Copyright 2018 Darron Anderson 



[hackers] [slstatus] Remove vol_perc() from todo in README || Aaron Marcher

2018-04-29 Thread git
commit b6d2b652d02d993377142b2d310baa96029d7d6c
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 16:08:45 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 16:08:45 2018 +0200

Remove vol_perc() from todo in README

diff --git a/README b/README
index cedbad9..6753c35 100644
--- a/README
+++ b/README
@@ -67,4 +67,3 @@ The following functions are not portable at the moment:
 - swap_{free,perc,total,used}
 - battery_{power,state}
 - temp
-- vol_perc



Re: [hackers] [slstatus] ip: add OpenBSD support

2018-04-29 Thread Aaron Marcher

Thanks, applied.

--
Web: https://drkhsh.at/ or http://drkhsh5rv6pnahas.onion/
Gopher: gopher://drkhsh.at or gopher://drkhsh5rv6pnahas.onion
GPG: 0x7A65E38D55BE96FE
Fingerprint: 4688 907C 8720 3318 0D9F AFDE 7A65 E38D 55BE 96FE



[hackers] [slstatus] ip: add OpenBSD support || Ali H. Fardan

2018-04-29 Thread git
commit 7a9a9b7d76808744796a5ce8f890836296f05763
Author: Ali H. Fardan 
AuthorDate: Sun Apr 29 10:55:38 2018 +0300
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 12:54:28 2018 +0200

ip: add OpenBSD support

ip.c already works on OpenBSD, it's just missing some headers:

diff --git a/components/ip.c b/components/ip.c
index 686344b..422b448 100644
--- a/components/ip.c
+++ b/components/ip.c
@@ -1,5 +1,9 @@
 /* See LICENSE file for copyright and license details. */
-#if defined(__linux__)
+#if defined(__OpenBSD__)
+#include 
+#include 
+#endif
+
 #include 
 #include 
 #include 
@@ -69,4 +73,3 @@ ipv6(const char *iface)
 
return NULL;
 }
-#endif



[hackers] [slstatus] Remove ipv{4,6}() from todo in README || Aaron Marcher

2018-04-29 Thread git
commit 96330ff42b9af1f14e5cb03c6c325ccf06c76065
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 13:00:12 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 13:00:12 2018 +0200

Remove ipv{4,6}() from todo in README

diff --git a/README b/README
index 80edd50..cedbad9 100644
--- a/README
+++ b/README
@@ -61,7 +61,6 @@ Todo
 Porting to OpenBSD is the current goal before thinking about a release.
 
 The following functions are not portable at the moment:
-- ipv{4,6}
 - wifi_{perc,essid}
 - cpu_{freq,perc,iowait}
 - entropy



[hackers] [slstatus] Update LICENSE for Ali H. Fardan || Aaron Marcher

2018-04-29 Thread git
commit 53ecbcb3ad919bcb875391dbeea51ee58560e010
Author: Aaron Marcher 
AuthorDate: Sun Apr 29 13:02:08 2018 +0200
Commit: Aaron Marcher 
CommitDate: Sun Apr 29 13:02:08 2018 +0200

Update LICENSE for Ali H. Fardan

diff --git a/LICENSE b/LICENSE
index bc669e9..60c18e3 100644
--- a/LICENSE
+++ b/LICENSE
@@ -7,9 +7,9 @@ Copyright 2016 Vincent Loupmon 
 Copyright 2016 Daniel Walter 
 Copyright 2016 Jody Leonard 
 Copyright 2016 Mike Coddington 
-Copyright 2016-2017 Ali H. Fardan 
 Copyright 2016-2017 parazyd 
 Copyright 2016-2017 Quentin Rameau 
+Copyright 2016-2018 Ali H. Fardan 
 Copyright 2017 Tobias Stoeckmann 
 Copyright 2017 Laslo Hunhold 
 Copyright 2018 Darron Anderson 



[hackers] [slstatus] ip: add OpenBSD support

2018-04-29 Thread Ali H. Fardan
ip.c already works on OpenBSD, it's just missing some headers:

diff --git a/components/ip.c b/components/ip.c
index 686344b..422b448 100644
--- a/components/ip.c
+++ b/components/ip.c
@@ -1,5 +1,9 @@
 /* See LICENSE file for copyright and license details. */
-#if defined(__linux__)
+#if defined(__OpenBSD__)
+#include 
+#include 
+#endif
+
 #include 
 #include 
 #include 
@@ -69,4 +73,3 @@ ipv6(const char *iface)
 
return NULL;
 }
-#endif