commit 327a07ead32827b7bb39b9b3200254270f8bebed Author: MK13 Date: Sun Oct 27 21:13:31 2019 +0100 Add patches for i3wm and i3status diff --git a/i3status/PKGBUILD_enable b/i3status/PKGBUILD_enable new file mode 100644 index 0000000..2d3e83d --- /dev/null +++ b/i3status/PKGBUILD_enable @@ -0,0 +1,3 @@ +in build() + patch -Np1 -i ../../memory_unit.patch + patch -Np1 -i ../../uptime.patch diff --git a/i3status/memory_unit.patch b/i3status/memory_unit.patch new file mode 100644 index 0000000..a5aa730 --- /dev/null +++ b/i3status/memory_unit.patch @@ -0,0 +1,103 @@ +--- a/i3status.c 2019-10-25 23:31:41.210231542 +0200 ++++ b/i3status.c 2019-10-25 23:25:25.088507686 +0200 +@@ -431,6 +431,7 @@ + CFG_STR("threshold_degraded", NULL, CFGF_NONE), + CFG_STR("threshold_critical", NULL, CFGF_NONE), + CFG_STR("memory_used_method", "classical", CFGF_NONE), ++ CFG_STR("unit", "auto", CFGF_NONE), + CFG_CUSTOM_ALIGN_OPT, + CFG_CUSTOM_COLOR_OPTS, + CFG_CUSTOM_MIN_WIDTH_OPT, +@@ -757,7 +758,7 @@ + + CASE_SEC("memory") { + SEC_OPEN_MAP("memory"); +- print_memory(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getstr(sec, "format_degraded"), cfg_getstr(sec, "threshold_degraded"), cfg_getstr(sec, "threshold_critical"), cfg_getstr(sec, "memory_used_method")); ++ print_memory(json_gen, buffer, cfg_getstr(sec, "format"), cfg_getstr(sec, "format_degraded"), cfg_getstr(sec, "threshold_degraded"), cfg_getstr(sec, "threshold_critical"), cfg_getstr(sec, "memory_used_method"), cfg_getstr(sec, "unit")); + SEC_CLOSE_MAP; + } + +--- a/include/i3status.h 2019-10-25 23:31:49.170197818 +0200 ++++ b/include/i3status.h 2019-10-25 23:25:25.088507686 +0200 +@@ -225,7 +225,7 @@ + void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format, const char *format_above_threshold, const char *format_above_degraded_threshold, const char *path, const float max_threshold, const float degraded_threshold); + void print_eth_info(yajl_gen json_gen, char *buffer, const char *interface, const char *format_up, const char *format_down); + void print_load(yajl_gen json_gen, char *buffer, const char *format, const char *format_above_threshold, const float max_threshold); +-void print_memory(yajl_gen json_gen, char *buffer, const char *format, const char *format_degraded, const char *threshold_degraded, const char *threshold_critical, const char *memory_used_method); ++void print_memory(yajl_gen json_gen, char *buffer, const char *format, const char *format_degraded, const char *threshold_degraded, const char *threshold_critical, const char *memory_used_method, const char *unit); + void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *fmt_muted, const char *device, const char *mixer, int mixer_idx); + bool process_runs(const char *path); + int volume_pulseaudio(uint32_t sink_idx, const char *sink_name); +--- a/src/print_mem.c 2019-10-25 23:32:07.430120494 +0200 ++++ b/src/print_mem.c 2019-10-25 23:25:25.088507686 +0200 +@@ -12,21 +12,30 @@ + #define MAX_EXPONENT 4 + static const char *const iec_symbols[MAX_EXPONENT + 1] = {"", "Ki", "Mi", "Gi", "Ti"}; + ++static const char *const units[MAX_EXPONENT + 1] = {"", "KiB", "MiB", "GiB", "TiB"}; ++ + static const char memoryfile_linux[] = "/proc/meminfo"; + + /* + * Prints the given amount of bytes in a human readable manner. + * + */ +-static int print_bytes_human(char *outwalk, uint64_t bytes) { ++static int print_bytes_human(char *outwalk, uint64_t bytes, const char *unit) { + double size = bytes; + int exponent = 0; + int bin_base = BINARY_BASE; ++ + while (size >= bin_base && exponent < MAX_EXPONENT) { ++ if (strcasecmp(unit, units[exponent]) == 0) { ++ break; ++ } ++ + size /= bin_base; ++ + exponent += 1; + } +- return sprintf(outwalk, "%.1f %sB", size, iec_symbols[exponent]); ++ ++ return sprintf(outwalk, "%.0f %sB", size, iec_symbols[exponent]); + } + + /* +@@ -73,7 +82,7 @@ + return mem_absolute; + } + +-void print_memory(yajl_gen json_gen, char *buffer, const char *format, const char *format_degraded, const char *threshold_degraded, const char *threshold_critical, const char *memory_used_method) { ++void print_memory(yajl_gen json_gen, char *buffer, const char *format, const char *format_degraded, const char *threshold_degraded, const char *threshold_critical, const char *memory_used_method, const char *unit) { + char *outwalk = buffer; + + #if defined(linux) +@@ -162,23 +171,23 @@ + *(outwalk++) = *walk; + + } else if (BEGINS_WITH(walk + 1, "total")) { +- outwalk += print_bytes_human(outwalk, ram_total); ++ outwalk += print_bytes_human(outwalk, ram_total, unit); + walk += strlen("total"); + + } else if (BEGINS_WITH(walk + 1, "used")) { +- outwalk += print_bytes_human(outwalk, ram_used); ++ outwalk += print_bytes_human(outwalk, ram_used, unit); + walk += strlen("used"); + + } else if (BEGINS_WITH(walk + 1, "free")) { +- outwalk += print_bytes_human(outwalk, ram_free); ++ outwalk += print_bytes_human(outwalk, ram_free, unit); + walk += strlen("free"); + + } else if (BEGINS_WITH(walk + 1, "available")) { +- outwalk += print_bytes_human(outwalk, ram_available); ++ outwalk += print_bytes_human(outwalk, ram_available, unit); + walk += strlen("available"); + + } else if (BEGINS_WITH(walk + 1, "shared")) { +- outwalk += print_bytes_human(outwalk, ram_shared); ++ outwalk += print_bytes_human(outwalk, ram_shared, unit); + walk += strlen("shared"); + + } else if (BEGINS_WITH(walk + 1, "percentage_free")) { diff --git a/i3status/uptime.patch b/i3status/uptime.patch new file mode 100644 index 0000000..3a61454 --- /dev/null +++ b/i3status/uptime.patch @@ -0,0 +1,50 @@ +--- a/configure.ac 2019-10-26 01:41:51.956255868 +0200 ++++ b/configure.ac 2019-10-26 01:44:46.098279175 +0200 +@@ -79,6 +79,7 @@ + + PKG_CHECK_MODULES([CONFUSE], [libconfuse]) + PKG_CHECK_MODULES([YAJL], [yajl]) ++PKG_CHECK_MODULES([PROC], [libprocps]) + + case $host_os in + linux*) +--- a/i3status.c 2019-10-26 01:41:51.956255868 +0200 ++++ b/i3status.c 2019-10-26 01:44:46.098279175 +0200 +@@ -35,6 +35,8 @@ + + #include "i3status.h" + ++#include "proc/whattime.h" ++ + #define exit_if_null(pointer, ...) \ + { \ + if (pointer == NULL) \ +@@ -698,6 +700,10 @@ + + const char *current = cfg_getnstr(cfg, "order", j); + ++ if (strcasecmp(current, "uptime") == 0) { ++ printf("UP: %s", sprint_uptime(1)); ++ } ++ + CASE_SEC("ipv6") { + SEC_OPEN_MAP("ipv6"); + print_ipv6_info(json_gen, buffer, cfg_getstr(sec, "format_up"), cfg_getstr(sec, "format_down")); +--- a/Makefile.am 2019-10-26 01:41:51.956255868 +0200 ++++ b/Makefile.am 2019-10-26 01:44:46.098279175 +0200 +@@ -26,6 +26,7 @@ + i3status_CFLAGS = \ + $(AM_CFLAGS) \ + $(CONFUSE_CFLAGS) \ ++ $(PROC_CFLAGS) \ + $(YAJL_CFLAGS) \ + $(PULSE_CFLAGS) \ + $(NLGENL_CFLAGS) \ +@@ -38,6 +39,7 @@ + + i3status_LDADD = \ + $(CONFUSE_LIBS) \ ++ $(PROC_LIBS) \ + $(YAJL_LIBS) \ + $(PULSE_LIBS) \ + $(NLGENL_LIBS) \ diff --git a/i3wm/PKGBUILD_enable b/i3wm/PKGBUILD_enable new file mode 100644 index 0000000..bb166dd --- /dev/null +++ b/i3wm/PKGBUILD_enable @@ -0,0 +1,2 @@ +in prepare() + patch -Np1 -i ../close.patch diff --git a/i3wm/close.patch b/i3wm/close.patch new file mode 100644 index 0000000..f2add0e --- /dev/null +++ b/i3wm/close.patch @@ -0,0 +1,56 @@ +--- a/src/workspace.c 2018-03-10 18:29:14.000000000 +0100 ++++ b/src/workspace.c 2018-06-11 15:15:43.572214113 +0200 +@@ -446,29 +446,30 @@ + * way for con_focus() to know about when to clear urgency immediately and + * when to defer it. */ + if (old && TAILQ_EMPTY(&(old->nodes_head)) && TAILQ_EMPTY(&(old->floating_head))) { +- /* check if this workspace is currently visible */ +- if (!workspace_is_visible(old)) { +- LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); +- yajl_gen gen = ipc_marshal_workspace_event("empty", old, NULL); +- tree_close_internal(old, DONT_KILL_WINDOW, false, false); +- +- const unsigned char *payload; +- ylength length; +- y(get_buf, &payload, &length); +- ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload); +- +- y(free); +- +- /* Avoid calling output_push_sticky_windows later with a freed container. */ +- if (old == old_focus) { +- old_focus = NULL; +- } +- +- ewmh_update_number_of_desktops(); +- ewmh_update_desktop_names(); +- ewmh_update_desktop_viewport(); +- ewmh_update_wm_desktop(); +- } ++ /* check if this workspace is currently visible ++ *if (!workspace_is_visible(old)) { ++ * LOG("Closing old workspace (%p / %s), it is empty\n", old, old->name); ++ * yajl_gen gen = ipc_marshal_workspace_event("empty", old, NULL); ++ * tree_close_internal(old, DONT_KILL_WINDOW, false, false); ++ * ++ * const unsigned char *payload; ++ * ylength length; ++ * y(get_buf, &payload, &length); ++ * ipc_send_event("workspace", I3_IPC_EVENT_WORKSPACE, (const char *)payload); ++ * ++ * y(free); ++ * ++ * Avoid calling output_push_sticky_windows later with a freed container. ++ * if (old == old_focus) { ++ * old_focus = NULL; ++ * } ++ * ++ * ewmh_update_number_of_desktops(); ++ * ewmh_update_desktop_names(); ++ * ewmh_update_desktop_viewport(); ++ * ewmh_update_wm_desktop(); ++ *} ++ */ + } + + workspace->fullscreen_mode = CF_OUTPUT;