mirror of
https://git.sr.ht/~leon_plickat/wlopm
synced 2025-04-07 09:26:48 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
41bc661837 | ||
|
7735d65230 | ||
|
84c3e0baf1 | ||
|
3ef08977b3 | ||
|
54230d76e6 | ||
|
dffcf3d8fc | ||
|
2e8d305b9e | ||
|
38af45c797 | ||
|
4fdd606327 |
13
Makefile
13
Makefile
@ -3,8 +3,9 @@ SCANNER := wayland-scanner
|
|||||||
PREFIX=/usr/local
|
PREFIX=/usr/local
|
||||||
BINDIR=$(PREFIX)/bin
|
BINDIR=$(PREFIX)/bin
|
||||||
MANDIR=$(PREFIX)/share/man
|
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
|
LIBS=-lwayland-client
|
||||||
OBJ=wlopm.o wlr-output-power-management-unstable-v1.o
|
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
|
GEN=wlr-output-power-management-unstable-v1.c wlr-output-power-management-unstable-v1.h
|
||||||
@ -21,15 +22,19 @@ $(OBJ): $(GEN)
|
|||||||
$(SCANNER) client-header < $< > $@
|
$(SCANNER) client-header < $< > $@
|
||||||
|
|
||||||
install: wlopm
|
install: wlopm
|
||||||
install -D wlopm $(DESTDIR)$(BINDIR)/wlopm
|
install -d $(DESTDIR)$(BINDIR)
|
||||||
install -D wlopm.1 $(DESTDIR)$(MANDIR)/man1/wlopm.1
|
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:
|
uninstall:
|
||||||
$(RM) $(DESTDIR)$(BINDIR)/wlopm
|
$(RM) $(DESTDIR)$(BINDIR)/wlopm
|
||||||
$(RM) $(DESTDIR)$(MANDIR)/man1/wlopm.1
|
$(RM) $(DESTDIR)$(MANDIR)/man1/wlopm.1
|
||||||
|
$(RM) $(DESTDIR)$(BASHCOMPDIR)/wlopm
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) wlopm $(GEN) $(OBJ)
|
$(RM) wlopm $(GEN) $(OBJ)
|
||||||
|
|
||||||
.PHONY: clean install
|
.PHONY: clean install
|
||||||
|
|
||||||
|
14
bash-completion
Normal file
14
bash-completion
Normal 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
|
2
wlopm.1
2
wlopm.1
@ -74,7 +74,7 @@ Toggle the power mode of the output
|
|||||||
.
|
.
|
||||||
.SH OUTPUT NAMES
|
.SH OUTPUT NAMES
|
||||||
.P
|
.P
|
||||||
Output names are compositor dependand.
|
Output names are compositor dependent.
|
||||||
.P
|
.P
|
||||||
If instead of an output name \fB*\fR is given as parameter to an operation,
|
If instead of an output name \fB*\fR is given as parameter to an operation,
|
||||||
wlopm will do the operation for all discovered outputs.
|
wlopm will do the operation for all discovered outputs.
|
||||||
|
54
wlopm.c
54
wlopm.c
@ -16,7 +16,6 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -35,7 +34,7 @@
|
|||||||
|
|
||||||
#include "wlr-output-power-management-unstable-v1.h"
|
#include "wlr-output-power-management-unstable-v1.h"
|
||||||
|
|
||||||
#define VERSION "0.1.0"
|
#define VERSION "1.0.0"
|
||||||
|
|
||||||
const char usage[] =
|
const char usage[] =
|
||||||
"Usage: wlopm [options...]\n"
|
"Usage: wlopm [options...]\n"
|
||||||
@ -93,8 +92,6 @@ struct zwlr_output_power_manager_v1 *wlr_output_power_manager = NULL;
|
|||||||
int ret = EXIT_SUCCESS;
|
int ret = EXIT_SUCCESS;
|
||||||
bool loop = true;
|
bool loop = true;
|
||||||
|
|
||||||
static void noop () {}
|
|
||||||
|
|
||||||
static void wlr_output_power_handle_mode (void *data, struct zwlr_output_power_v1 *wlr_output_power,
|
static void wlr_output_power_handle_mode (void *data, struct zwlr_output_power_v1 *wlr_output_power,
|
||||||
enum zwlr_output_power_v1_mode mode)
|
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);
|
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 = {
|
static const struct wl_output_listener wl_output_listener = {
|
||||||
.name = wl_output_handle_name,
|
.name = wl_output_handle_name,
|
||||||
.geometry = noop,
|
.geometry = wl_output_handle_geometry,
|
||||||
.mode = noop,
|
.mode = wl_output_handle_mode,
|
||||||
.scale = noop,
|
.scale = wl_output_handle_scale,
|
||||||
.description = noop,
|
.description = wl_output_handle_description,
|
||||||
.done = noop,
|
.done = wl_output_handle_done,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void registry_handle_global (void *data, struct wl_registry *registry,
|
static void registry_handle_global (void *data, struct wl_registry *registry,
|
||||||
@ -165,9 +192,15 @@ static void registry_handle_global (void *data, struct wl_registry *registry,
|
|||||||
&zwlr_output_power_manager_v1_interface, version);
|
&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 = {
|
static const struct wl_registry_listener registry_listener = {
|
||||||
.global = registry_handle_global,
|
.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);
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user