Compare commits

..

No commits in common. "master" and "v0.1.0" have entirely different histories.

5 changed files with 23 additions and 75 deletions

View File

@ -3,10 +3,8 @@ 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 -Wno-strict-prototypes
CFLAGS+=-fanalyzer
CFLAGS+=-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result
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
@ -23,19 +21,15 @@ $(OBJ): $(GEN)
$(SCANNER) client-header < $< > $@
install: wlopm
install -d $(DESTDIR)$(BINDIR)
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
install -D wlopm $(DESTDIR)$(BINDIR)/wlopm
install -D wlopm.1 $(DESTDIR)$(MANDIR)/man1/wlopm.1
uninstall:
$(RM) $(DESTDIR)$(BINDIR)/wlopm
$(RM) $(DESTDIR)$(MANDIR)/man1/wlopm.1
$(RM) $(DESTDIR)$(BASHCOMPDIR)/wlopm
clean:
$(RM) wlopm $(GEN) $(OBJ)
.PHONY: clean install

6
README
View File

@ -3,9 +3,3 @@ 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.

View File

@ -1,14 +0,0 @@
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 dependent.
Output names are compositor dependand.
.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.

62
wlopm.c
View File

@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <ctype.h>
#include <errno.h>
#include <signal.h>
#include <stdbool.h>
@ -34,7 +35,7 @@
#include "wlr-output-power-management-unstable-v1.h"
#define VERSION "1.0.0"
#define VERSION "0.1.0"
const char usage[] =
"Usage: wlopm [options...]\n"
@ -57,6 +58,12 @@ struct Output
uint32_t global_name;
};
enum Action
{
LIST,
OPERATIONS,
};
enum Power_mode
{
ON,
@ -86,6 +93,8 @@ 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)
{
@ -113,43 +122,13 @@ 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 = wl_output_handle_geometry,
.mode = wl_output_handle_mode,
.scale = wl_output_handle_scale,
.description = wl_output_handle_description,
.done = wl_output_handle_done,
.geometry = noop,
.mode = noop,
.scale = noop,
.description = noop,
.done = noop,
};
static void registry_handle_global (void *data, struct wl_registry *registry,
@ -172,7 +151,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;
@ -186,15 +165,9 @@ 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 = registry_handle_global_remove,
.global_remove = noop, /* We don't run long enough to care. */
};
static void sync_handle_done (void *data, struct wl_callback *wl_callback, uint32_t other_data);
@ -597,3 +570,4 @@ int main(int argc, char *argv[])
return ret;
}