8 Commits

Author SHA1 Message Date
7735d65230 change version to 1.0.0 2024-12-05 04:07:02 +01:00
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
3ef08977b3 Remove ctype.h include 2024-12-03 13:20:03 +01:00
54230d76e6 add bash completion 2024-03-28 19:11:46 +01:00
dffcf3d8fc Fix compatibility with FreeBSD coreutils
I needed to patch this to package wlopm for chimera linux, which uses
FreeBSD's coreutils. Apparently -D is not portable, it means something
different for FreeBSD install.
2024-02-12 05:24:11 +01:00
2e8d305b9e Add -Wno-strict-prototypes to allow compiling wlopm with clang 2023-11-17 07:05:36 +01:00
38af45c797 Install man file with correct permissions 2022-08-05 22:24:56 +02:00
4fdd606327 Typo 2022-07-28 11:56:35 +02:00
4 changed files with 67 additions and 17 deletions

View File

@ -3,8 +3,9 @@ SCANNER := wayland-scanner
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
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
CFLAGS+=-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result -Wno-strict-prototypes
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
@ -21,15 +22,18 @@ $(OBJ): $(GEN)
$(SCANNER) client-header < $< > $@
install: wlopm
install -D wlopm $(DESTDIR)$(BINDIR)/wlopm
install -D wlopm.1 $(DESTDIR)$(MANDIR)/man1/wlopm.1
install -d $(DESTDIR)$(BINDIR)
install wlopm $(DESTDIR)$(BINDIR)
install -d $(DESTDIR)$(MANDIR)/man1
install -m 644 wlopm.1 $(DESTDIR)$(MANDIR)/man1
install bash-completion $(DESTDIR)$(BASHCOMPDIR)/wlopm
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/wlopm
$(RM) $(DESTDIR)$(MANDIR)/man1/wlopm.1
$(RM) $(DESTDIR)$(BASHCOMPDIR)/wlopm
clean:
$(RM) wlopm $(GEN) $(OBJ)
.PHONY: clean install

14
bash-completion Normal file
View File

@ -0,0 +1,14 @@
function __wlopm_completion ()
{
case "${COMP_WORDS[-2]}" in
"--on"|"--off"|"--toggle")
OPTS="$(wlopm | cut -d' ' -f1 | tr '\n' ' ')"
;;
*)
OPTS="-h --help -j --json -v --version --on --off --toggle"
;;
esac
COMPREPLY=($(compgen -W "${OPTS}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
}
complete -F __wlopm_completion wlopm

View File

@ -74,7 +74,7 @@ Toggle the power mode of the output
.
.SH OUTPUT NAMES
.P
Output names are compositor dependand.
Output names are compositor dependent.
.P
If instead of an output name \fB*\fR is given as parameter to an operation,
wlopm will do the operation for all discovered outputs.

56
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"
@ -93,8 +92,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 +119,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 +178,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 +192,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 +603,3 @@ int main(int argc, char *argv[])
return ret;
}