Compare commits

...

7 Commits

Author SHA1 Message Date
Leon Henrik Plickat
6a197ebc63 README: add contribution notice 2025-05-28 23:02:01 +02:00
Leon Henrik Plickat
4fe73f96e2 remove Action enum
no longer needed
2025-05-21 17:29:06 +02:00
Leon Henrik Plickat
4a813508a3 build: add -fanalyzer to CFLAGS 2025-05-15 00:22:53 +02:00
Isaac Freund
41bc661837 Fix bash completion installation
Currently this fails if the directory for the completion does not
already exist, at least with FreeBSD install(1).
2024-12-10 13:58:41 +01:00
Leon Henrik Plickat
7735d65230 change version to 1.0.0 2024-12-05 04:07:02 +01:00
Ben Buhse
84c3e0baf1 Remove noop()
Sending a handler with incompatible pointer types is undefined
behavior, so this removes noop() and implements empty handlers for all
of its previous uses.

This used to work until C23.
2024-12-03 13:21:33 +01:00
Ben Buhse
3ef08977b3 Remove ctype.h include 2024-12-03 13:20:03 +01:00
3 changed files with 52 additions and 18 deletions

View File

@@ -6,6 +6,7 @@ MANDIR=$(PREFIX)/share/man
BASHCOMPDIR=$(PREFIX)/share/bash-completion/completions
CFLAGS+=-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result -Wno-strict-prototypes
CFLAGS+=-fanalyzer
LIBS=-lwayland-client
OBJ=wlopm.o wlr-output-power-management-unstable-v1.o
GEN=wlr-output-power-management-unstable-v1.c wlr-output-power-management-unstable-v1.h
@@ -26,6 +27,7 @@ install: wlopm
install wlopm $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(MANDIR)/man1
install -m 644 wlopm.1 $(DESTDIR)$(MANDIR)/man1
install -d $(DESTDIR)$(BASHCOMPDIR)
install bash-completion $(DESTDIR)$(BASHCOMPDIR)/wlopm
uninstall:

6
README
View File

@@ -3,3 +3,9 @@ wlopm - Wayland output power management
Simple client implementing zwlr-output-power-management-v1.
wlopm is licensed under the GPLv3.
Contributions are welcome in the form of patches via EMail. Please
reach out before working on larger changes. Please note that any
contributions making use of language models or similar machine
learning abominations will not be accepted and will lead to a lifetime
ban from contributing to or requesting help with any of my projects.

62
wlopm.c
View File

@@ -16,7 +16,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
@@ -35,7 +34,7 @@
#include "wlr-output-power-management-unstable-v1.h"
#define VERSION "0.1.0"
#define VERSION "1.0.0"
const char usage[] =
"Usage: wlopm [options...]\n"
@@ -58,12 +57,6 @@ struct Output
uint32_t global_name;
};
enum Action
{
LIST,
OPERATIONS,
};
enum Power_mode
{
ON,
@@ -93,8 +86,6 @@ struct zwlr_output_power_manager_v1 *wlr_output_power_manager = NULL;
int ret = EXIT_SUCCESS;
bool loop = true;
static void noop () {}
static void wlr_output_power_handle_mode (void *data, struct zwlr_output_power_v1 *wlr_output_power,
enum zwlr_output_power_v1_mode mode)
{
@@ -122,13 +113,43 @@ static void wl_output_handle_name (void *data, struct wl_output *wl_output,
output->name = strdup(name);
}
static void wl_output_handle_geometry (void *data, struct wl_output *wl_output,
int32_t x, int32_t y, int32_t physical_width, int32_t physical_height,
int32_t subpixel, const char* make, const char* model, int32_t transform)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_mode (void *data, struct wl_output *wl_output,
uint32_t flags, int32_t width, int32_t height, int32_t refresh)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_scale (void *data, struct wl_output *wl_output,
int32_t scale)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_description (void *data, struct wl_output *wl_output,
const char *description)
{
/* This function is deliberately left empty. */
}
static void wl_output_handle_done (void *data, struct wl_output *wl_output)
{
/* This function is deliberately left empty. */
}
static const struct wl_output_listener wl_output_listener = {
.name = wl_output_handle_name,
.geometry = noop,
.mode = noop,
.scale = noop,
.description = noop,
.done = noop,
.geometry = wl_output_handle_geometry,
.mode = wl_output_handle_mode,
.scale = wl_output_handle_scale,
.description = wl_output_handle_description,
.done = wl_output_handle_done,
};
static void registry_handle_global (void *data, struct wl_registry *registry,
@@ -151,7 +172,7 @@ static void registry_handle_global (void *data, struct wl_registry *registry,
return;
}
output->wl_output = wl_registry_bind(registry, name,
output->wl_output = wl_registry_bind(registry, name,
&wl_output_interface, 4);
wl_output_add_listener(output->wl_output, &wl_output_listener, output);
output->wlr_output_power = NULL;
@@ -165,9 +186,15 @@ static void registry_handle_global (void *data, struct wl_registry *registry,
&zwlr_output_power_manager_v1_interface, version);
}
static void registry_handle_global_remove (void *data, struct wl_registry *registry,
uint32_t name)
{
/* We don't run long enough to care. */
}
static const struct wl_registry_listener registry_listener = {
.global = registry_handle_global,
.global_remove = noop, /* We don't run long enough to care. */
.global_remove = registry_handle_global_remove,
};
static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint32_t other_data);
@@ -570,4 +597,3 @@ int main(int argc, char *argv[])
return ret;
}