From 77a24b38f919530356106be177e0913795226548 Mon Sep 17 00:00:00 2001 From: Ryan Kes Date: Fri, 29 Mar 2019 11:23:50 +0100 Subject: [PATCH] initial import --- LICENSE.md | 22 ++++++ README.md | 8 ++ TODO.md | 4 + slstatus-backlight-20190305-85a4a18.diff | 95 ++++++++++++++++++++++++ slstatus-separator-20190305-f4e35fa.diff | 70 +++++++++++++++++ 5 files changed, 199 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 TODO.md create mode 100644 slstatus-backlight-20190305-85a4a18.diff create mode 100644 slstatus-separator-20190305-f4e35fa.diff diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..7691a7a --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +The MIT License (MIT) +===================== + +Copyright © `2019` `Ryan Kes ` + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f2bbbc3 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Slstatus patches +Patches I've updated for [slstatus](https://tools.suckless.org/slstatus/) + +## slstatus-backlight +Shows backlight percentage + +## slstatus-separator +Prints passed separator (or any other string you wish to echo) diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..eca7f74 --- /dev/null +++ b/TODO.md @@ -0,0 +1,4 @@ +Solarized +------------ + +* Install [st-solarized-both](https://st.suckless.org/patches/solarized/st-solarized-both-20170626-b331da5.diff) patch if someone ever bothers to get it working with ST 0.8 diff --git a/slstatus-backlight-20190305-85a4a18.diff b/slstatus-backlight-20190305-85a4a18.diff new file mode 100644 index 0000000..c96ee30 --- /dev/null +++ b/slstatus-backlight-20190305-85a4a18.diff @@ -0,0 +1,95 @@ +From 165831fe7aab377343825acfabc2d4f16d6ca012 Mon Sep 17 00:00:00 2001 +From: Ryan Kes +Date: Fri, 29 Mar 2019 11:09:21 +0100 +Subject: [PATCH] backlight module + +--- + Makefile | 1 + + components/backlight.c | 36 ++++++++++++++++++++++++++++++++++++ + config.def.h | 1 + + slstatus.h | 3 +++ + 4 files changed, 41 insertions(+) + create mode 100644 components/backlight.c + +diff --git a/Makefile b/Makefile +index 945b5e3..28a205f 100644 +--- a/Makefile ++++ b/Makefile +@@ -6,6 +6,7 @@ include config.mk + + REQ = util + COM =\ ++ components/backlight\ + components/battery\ + components/cpu\ + components/datetime\ +diff --git a/components/backlight.c b/components/backlight.c +new file mode 100644 +index 0000000..fcc062a +--- /dev/null ++++ b/components/backlight.c +@@ -0,0 +1,36 @@ ++/* See LICENSE file for copyright and license details. */ ++#include ++#include ++ ++#include "../util.h" ++ ++#if defined(__linux__) ++ #include ++ #include ++ #include ++ ++ const char * ++ backlight_perc(const char *backlight) ++ { ++ float value; ++ char path[PATH_MAX]; ++ ++ if (esnprintf(path, sizeof(path), ++ "/sys/class/backlight/%s/actual_brightness", backlight) < 0) { ++ return NULL; ++ } ++ if (pscanf(path, "%f", &value) != 1) { ++ return NULL; ++ } ++ ++ return bprintf("%d", (int)(value / 852 * 100)); ++ } ++ ++#else ++ const char * ++ backlight_perc(const char *backlight) ++ { ++ return NULL; ++ } ++ ++#endif +diff --git a/config.def.h b/config.def.h +index e06be66..d0996ef 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -12,6 +12,7 @@ static const char unknown_str[] = "n/a"; + /* + * function description argument (example) + * ++ * backlight_perc backlight percentage backlight name (intel_backlight) + * battery_perc battery percentage battery name (BAT0) + * NULL on OpenBSD/FreeBSD + * battery_state battery charging state battery name (BAT0) +diff --git a/slstatus.h b/slstatus.h +index 08f610a..d9c0b5f 100644 +--- a/slstatus.h ++++ b/slstatus.h +@@ -1,5 +1,8 @@ + /* See LICENSE file for copyright and license details. */ + ++/* backlight */ ++const char *backlight_perc(const char *backlight); ++ + /* battery */ + const char *battery_perc(const char *); + const char *battery_state(const char *); +-- +2.21.0 + diff --git a/slstatus-separator-20190305-f4e35fa.diff b/slstatus-separator-20190305-f4e35fa.diff new file mode 100644 index 0000000..ce6c1f3 --- /dev/null +++ b/slstatus-separator-20190305-f4e35fa.diff @@ -0,0 +1,70 @@ +From dfd7ef09328958c4c36aedc50d80226da90a8153 Mon Sep 17 00:00:00 2001 +From: Ryan Kes +Date: Fri, 29 Mar 2019 11:16:37 +0100 +Subject: [PATCH] separator module + +--- + Makefile | 1 + + components/seperator.c | 10 ++++++++++ + config.def.h | 1 + + slstatus.h | 3 +++ + 4 files changed, 15 insertions(+) + create mode 100644 components/seperator.c + +diff --git a/Makefile b/Makefile +index 945b5e3..20796b3 100644 +--- a/Makefile ++++ b/Makefile +@@ -21,6 +21,7 @@ COM =\ + components/num_files\ + components/ram\ + components/run_command\ ++ components/seperator\ + components/swap\ + components/temperature\ + components/uptime\ +diff --git a/components/seperator.c b/components/seperator.c +new file mode 100644 +index 0000000..826a461 +--- /dev/null ++++ b/components/seperator.c +@@ -0,0 +1,10 @@ ++/* See LICENSE file for copyright and license details. */ ++#include ++ ++#include "../util.h" ++ ++const char * ++seperator(char *seperator) ++{ ++ return seperator; ++} +diff --git a/config.def.h b/config.def.h +index e06be66..af289e5 100644 +--- a/config.def.h ++++ b/config.def.h +@@ -45,6 +45,7 @@ static const char unknown_str[] = "n/a"; + * ram_total total memory size in GB NULL + * ram_used used memory in GB NULL + * run_command custom shell command command (echo foo) ++ * seperator string to echo NULL + * swap_free free swap in GB NULL + * swap_perc swap usage in percent NULL + * swap_total total swap size in GB NULL +diff --git a/slstatus.h b/slstatus.h +index 08f610a..78aef21 100644 +--- a/slstatus.h ++++ b/slstatus.h +@@ -56,6 +56,9 @@ const char *ram_used(void); + /* run_command */ + const char *run_command(const char *cmd); + ++/* seperator */ ++const char *seperator(const char *seperator); ++ + /* swap */ + const char *swap_free(void); + const char *swap_perc(void); +-- +2.21.0 +