Commit Graph

428 Commits (17841f9ece526aaebceb753fcfa4408eb34b9e70)

Author SHA1 Message Date
Andri Yngvason e710d47f2e ctl-client: Use EAGAIN instead of ENODATA
The latter is obsolete in POSIX.1-2008.
2023-01-23 22:26:38 +00:00
Andri Yngvason 267a4e55e3 ctl-commands: Use slightly more helpful schemas 2023-01-17 20:05:17 +00:00
Andri Yngvason 5bf6f23eed ctl-client: Replace = with : in event description
Let's not abuse the equality sign more than necessary. ;)
2023-01-17 20:05:17 +00:00
Andri Yngvason b54b0a31f7 ctl-commands: Fix typo 2023-01-17 20:05:17 +00:00
Andri Yngvason 6fccedcf41 ctl-commands: Capitalise "VNC" 2023-01-17 20:05:17 +00:00
Andri Yngvason f49aea40a4 ctl-server: Improve error messages for missing arguments 2023-01-17 20:05:17 +00:00
Andri Yngvason 0b970ba355 ctl-server: Fix segfault in error path
This would segfault e.g. if issuing:
$ waynvcctl client-disconnect # without argument
2023-01-17 20:05:17 +00:00
Andri Yngvason 6e326af2ff ctl-client: Print trailing newline for events
If someone wants to parse this instead of using jq, a trailing
newline delimits the end of the event.
2023-01-17 20:05:17 +00:00
Andri Yngvason aa96103ae8 ctl-client: Don't print "<<null>" for events with no params
It's inconsistent and doesn't seem helpful either.
2023-01-17 20:05:17 +00:00
Andri Yngvason 5d1421a063 ctl-client: Remove decorations in client/output lists
Those decorations do not appear to improve readability or
parsability.
2023-01-17 20:05:17 +00:00
Andri Yngvason d8bc5cd328 ctl-client: Remove messages about how many clients/outputs there are
When you type "ls", it doesn't tell you how many files there are.
If the user wants to know that, they can use "wc -l" or count them.
2023-01-17 20:05:17 +00:00
Andri Yngvason bbea931f8c ctl-client: Rename print_as_yaml -> print_for_human
The goal is to have this human friendly, not yaml.
2023-01-17 20:05:17 +00:00
Andri Yngvason 0fc43ef757 ctl-client: Use more descriptive response error message 2023-01-17 20:05:17 +00:00
Andri Yngvason baea2e8f4c ctl-client: Add a few vertical spaces + style changes
This change is intended to make things easier to read for myself.
2023-01-17 20:05:17 +00:00
Andri Yngvason 889f5900cc ctl-client: Rename WARNING log level to ERROR
All of these are basically errors.

A warning is often a recoverable event, an error isn't.
2023-01-17 20:05:17 +00:00
Andri Yngvason 98db05434a ctl-client: Align log messages with other log messages 2023-01-17 20:05:17 +00:00
Andri Yngvason cec46490a9 main: Don't init render node with gpu disabled
Otherwise, a warning will be generated when there is no render node.
2023-01-15 23:02:53 +00:00
Jim Ramsay 749b64666a Clean up command summary printing
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay cc27b127d1 Autoprint option default values
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay 177ea507e3 Allow reflow of multiline text
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay 104040291b Add option_parser_print_usage
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay dcb23ebfe1 Add 'schema' to wayvncctl command parameters
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay a52b7a1985 Add description and argument help to wayvnc --help
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay 405e9a13df Add help output for wayvncctl positional arguments
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay 23527a095a Allow positional args for single-param commands
Less typing = more happy

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-12 17:47:50 -05:00
Jim Ramsay a28ce15521 Split wayvnctl output-set into output-set and output-cycle
Rather than optional params, unique commands are easier to use.

This also removes the ability to cycle through in reverse since the list
order is already arbitrary.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 18:23:45 -05:00
Jim Ramsay 8df085a65a Rename and reorder all wayvncctl commands
This introduces a better hierarchical naming convention for IPC
commands.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 13:51:10 -05:00
Jim Ramsay dd19da6143 Add command and event details to help output
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 12:42:38 -05:00
Jim Ramsay d1e1f62d1e Refactor option-parser table printing code for reuse
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 12:42:38 -05:00
Jim Ramsay aec9304885 Add help text for wayvncctl-only events
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 12:42:38 -05:00
Jim Ramsay fbd373143c Remove 'help' command and clean up help output
The redundant "help" command is now hidden from the wayvncctl UI.

This also moves event description help text to:
  wayvncctl event-receive --show=<event-name>

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-08 12:42:38 -05:00
Jim Ramsay d475e0e52f Fix segfault for wayvncctl help --command=bad-name
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-02 20:18:14 -05:00
Jim Ramsay 522b1deb28 Convert wayvncctl subcommands to use option-parser
Also cleans up access to unparsed options.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2023-01-02 16:38:46 -05:00
Andri Yngvason 474ce23d42 Implement custom option parser 2023-01-01 09:12:29 +00:00
Jim Ramsay 86652c8a42 Fixup buffer.c compiler warning
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-29 05:50:44 -05:00
Jim Ramsay 92e79bb971 Add more error logs for wayland init failures
This should help with troubleshooting issues like #206 more quickly.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-29 01:25:00 -05:00
Jim Ramsay 2f2f6f410b Force a wayland round-trip after an output appears
This way outputs are always fully initialized.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-25 21:31:49 -05:00
Jim Ramsay 5cf9ad6eab Increase client receive buffer size
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-21 09:18:46 -05:00
Jim Ramsay 5d443bfa60 Improve error message for client receive buffer overflow
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-21 09:18:46 -05:00
Jim Ramsay 3e5d6ea8eb Fix segfault after hot-plugging outputs
When new outputs appear, either because they were just created or
because they have been disabled/reenabled, ensure we always set up the
right xdg_output and wlr_output_power listeners.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-19 16:20:56 -05:00
Jim Ramsay 2a9e3dac58 Fix trace logging assert crash
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-09 02:43:03 -05:00
Jim Ramsay 00539935ba Add output power state to get_outputs ipc command
I forgot to plumb this through when I did the initial state on the
output power state.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-07 19:56:37 -05:00
Jim Ramsay cb116cc980 Handle all wayvncctl help commands locally
This means that wayvncctl can now provide full descriptions of all
commands and events without wayvnc running.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-07 19:56:06 -05:00
Jim Ramsay d75ca4bf51 Refactor comand and event name parsing
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-07 19:56:06 -05:00
Jim Ramsay 4def8f3cb8 Switch wayvncctl to use option_parser
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-07 19:56:06 -05:00
Andri Yngvason e3238cf71d output: The name the "unknown" power state is "UNKNOWN" 2022-12-01 21:30:06 +00:00
Andri Yngvason 03d7f1dc6d output: Abort on invalid power state 2022-12-01 21:27:55 +00:00
Jim Ramsay 5bb8cbfa92 Blank the capture screen when output power turns off
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-01 19:11:32 +00:00
Jim Ramsay 6b44a6648e Turn output power on when starting capture
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-01 19:11:32 +00:00
Jim Ramsay 3cba374172 Don't attempt capture if an output is powered off
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-01 19:11:32 +00:00
Jim Ramsay 308308b63a Add power management state to the output object
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-12-01 19:11:32 +00:00
Andri Yngvason 312ddd8960 Move control command schemas into own files
This allows them to be used by ctl-client as well.
2022-11-27 10:48:03 +00:00
Andri Yngvason 052160cbd4 ctl: Fix sign compare warnings 2022-11-27 10:33:09 +00:00
Andri Yngvason c3c3e97794 main: Use stronger error checking for client ids 2022-11-27 10:33:09 +00:00
Jim Ramsay 89bd6da3bb Add a brief timeout between a capture failure and the retry
Ensures we don't spin eating CPU if capture is continually failing due
to DPMS (for example) by only trying to restart screen capture every
100ms.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-27 10:29:24 +00:00
Jim Ramsay e958b06e44 Add wayvncctl wayvnc-exit command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Jim Ramsay 467cfa1889 Add wayvncctl capture-changed event
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Jim Ramsay 19862aace8 Cleanup magic strings in event sending code
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Jim Ramsay 5c8014d19b Add wayvncctl disconnect-client command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Jim Ramsay 3e9aa0e3ae Ensure cmd parsing never mis-sets the type
Why leave the cmd.type to chance? Force it to the right value.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Jim Ramsay 80fd6b074e Add wayvncctl get-outputs command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 19:57:53 +00:00
Andri Yngvason ac5e207321 ctl-server: Fix sign compare warning 2022-11-26 18:17:30 +00:00
Andri Yngvason 8a70c54928 buffer: Add braces to side-step bogus fallthrough warning 2022-11-26 18:16:14 +00:00
Jim Ramsay 80efc9d487 Start capture on output switch iff clients are connected
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-26 14:12:59 +00:00
Jim Ramsay 19e3d78d78 Add wayvncctl get-clients command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-23 09:41:46 +00:00
Jim Ramsay 72238686c4 Make better client IDs for wayvncctl
We were using a stringified pointer, but that wasnt great to leak, and
may end up being reused while wayvnc is running.

Using an unsigned int will make the IDs more generic and more unique.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-23 09:41:46 +00:00
Jim Ramsay 349693ed87 Fix segfault if running wayvncctl with no args
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-22 22:40:09 +00:00
Andri Yngvason ef2e68af70 Fixup previous commit 2022-11-21 10:09:24 +00:00
Andri Yngvason 1604b12f78 Create separate data-control for each client 2022-11-20 23:00:03 +00:00
Andri Yngvason b99120ddfc Create separate input for each client
This should clean up state for virtual input devices.

This is also a step towards multi-seat support.
2022-11-20 12:20:23 +00:00
Andri Yngvason b79ab71dca main: Add per-client state 2022-11-20 11:32:52 +00:00
Jim Ramsay fe10e46e29 Introduce wayvncctl startup amd shutdown events
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-19 11:58:07 +00:00
Jim Ramsay 325b45ef49 Clean up wayvncctl logging
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-18 09:24:31 +00:00
Jim Ramsay 1d25535e7a Add wayvncctl --reconnect option
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-18 09:24:31 +00:00
Jim Ramsay 6e13974b27 Add wayvncctl --wait option
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-18 09:24:31 +00:00
Jim Ramsay 372b530d3a Fix wayvncctl usage and manpage typos
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-18 09:24:31 +00:00
Jim Ramsay c86e2a756e Cleanup stale unix socket, iff inactive
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-13 23:06:43 +00:00
Andri Yngvason 13aa584075 ctl-server: Fix sign-compare warning 2022-11-13 15:57:27 +00:00
Andri Yngvason 125121613e Create option parser interface
This is an interface that combines option parsing with help text formatting.
2022-11-13 15:43:50 +00:00
Jim Ramsay 3ee620b8b6 Add example event-watcher script
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay d8239109e5 Introduce an event loop mode in wayvncctl
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay debd8a67cb Added event help text
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay c75b64eae8 Add server event infrastructure
Includes "client-connect" and "client-disconnect" events as
proof-of-concept.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay 8d32dfaead Add jsonipc event message constructor
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay c859c50463 Ensure fatal errors are sent first
Once we start enqueueing asynchronous events, it's more important to
send fatal errors (which then disconnect) imediately by prepending them
to the send queue. Everything else is still processed FIFO.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-12 20:11:00 +00:00
Jim Ramsay 231a08ce19 Clarify the various wayvncctl 'help' modes
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 01bd225247 Add wayvncctl human-readable output
Also adds the '--json' option to produce machine-readable output.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 1275609aee Allow 'wayvncctl foo --help' syntax
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 15735b3256 Add wayvncctl version command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 73fd2e386f Add wayvnctl help command
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 01851dc339 Add initial wayvncctl executable
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay be42c8b7bf Add ctl-client code
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 5043f8e149 Refactor some common utilities out of main
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 1a0e8aae97 Add ctl control socket and initial command infrastructure
This implements the first wayvncctl command: set-output

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay 19e1e14eab Add json-ipc message plumbing
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-10 18:02:59 +00:00
Jim Ramsay cb95ce931e Switch to previous output if current output disappears
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-06 14:55:38 +00:00
Jim Ramsay 7a159570ef Add functions to switch outputs on the fly
One to switch to an arbitrary outout, and then two helpers to switch
to the next/previous in the output list.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-06 14:55:38 +00:00
Jim Ramsay 4018c698c2 Add output_cycle to get next/prev outputs
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-06 14:55:38 +00:00
Jim Ramsay a1aa69625c Refactor output selection code
Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-06 14:55:38 +00:00
Jim Ramsay 49ecbe14fa Refactor pointer initialization code
Additionally, make the pointer setup reentrant, destroying the previous
setup if needed.

Signed-off-by: Jim Ramsay <i.am@jimramsay.com>
2022-11-06 14:55:38 +00:00