Commit Graph

85 Commits

Author SHA1 Message Date
Simon Ser fc640d5f6c Define _POSIX_C_SOURCE globally
See discussion in https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4555
2024-02-23 17:43:19 +03:00
rj1 d63497698b fix typo 2023-02-25 10:50:43 +01:00
Simon Ser 0695f3fa2a swaymsg: s/inactive/disabled/
The JSON field is named "active", but that's confusing for users:
`output disable` is the command which results in `active = false`
outputs. Use the same terminology in end-user messages.
2023-02-02 12:00:06 -05:00
Simon Ser f22d4dbab7 swaymsg: print output power status 2023-02-02 12:00:06 -05:00
Simon Ser 78b5c0a77e swaymsg: show mode picture aspect ratio 2022-10-03 13:35:52 +02:00
Alex Maese cffb006feb swaymsg: show non-desktop property when pretty printing outputs 2022-09-19 07:26:45 -04:00
llyyr e98b97a45b swaymsg: fix floating_nodes being ignored
Fix floating_nodes being ignored in pretty_print_tree.
2022-07-26 10:56:50 +02:00
Simon Ser 513fa00a5e swaymsg: add GET_TREE pretty-printing 2021-12-21 11:07:11 +01:00
Simon Ser d9ce781d4c swaymsg: replace if with switch in pretty_print 2021-12-21 11:07:11 +01:00
Jason Nader 9303bed4d4 refactor: use JSON_MAX_DEPTH everywhere 2021-10-25 10:18:40 +02:00
Sefa Eyeoglu b223f70250 refactor: use sway_abort instead 2021-10-22 09:57:05 +02:00
Sefa Eyeoglu 96baef8ae9 fix: use sane value for json_tokener max_depth
INT_MAX causes a NULL pointer if there is not enough memory available to
fit (INT_MAX * sizeof(struct json_tokener_srec)).
2021-10-22 09:57:05 +02:00
Sefa Eyeoglu 944d7031c5 fix: handle NULL from json_tokener_new_ex
if there is not enough memory to fit json_tokener and (depth *
json_tokener_srec) in RAM, don't segfault.
2021-10-22 09:57:05 +02:00
Jason Nader db70f6496c swaymsg: fix misplaced return value 2021-10-18 14:20:24 +02:00
Jason Nader 55cd8abd76 swaymsg: be explicit about the json parser error 2021-10-18 14:20:24 +02:00
Jason Nader f873bcc4e1 swaymsg: use INT_MAX max JSON depth when parsing IPC response
Same reasoning as fe11caeac9.
Without this, swaymsg would fail with a cryptic error message
when the JSON was nested too deep.
2021-10-18 14:20:24 +02:00
Manuel Stoeckl 169b90f90b Make command line option lists const 2021-02-04 09:49:06 +01:00
SpizzyCoder 7cf25d3b98 Changed fprintf(stdout,...) to printf(...) for more readable code 2021-01-16 20:24:41 +01:00
Ronan Pigott 0d04864fd1 swaymsg: use 3 digits for fractional part of the refresh rate
The fractional part of the real number we want to represent never has
more than 3 decimal digits, so use 3 decimal digits of precision.

e.g. 'swaymsg -t get_outputs' would show a refresh rate of 59934 mHz
as 59.933998 Hz, now correctly as 59.934 Hz.
2021-01-15 21:32:42 +01:00
Jason Nader 45859be03f i3-compat: add GET_BINDING_STATE IPC command 2020-06-14 00:55:14 -04:00
Simon Ser a2d49099e1 Add adaptive_sync_status to output IPC reply 2020-03-07 00:32:04 +01:00
Ronan Pigott 6968fb3123 add scale_filter output config option 2019-11-29 18:13:37 +01:00
Ivan Molodetskikh fe84ec2f24 Add max_render_time to output JSON 2019-11-17 20:18:42 +01:00
Brian Ashworth a8a239e2f1 swaymsg: return 2 for sway errors
This mirrors a change in i3 4.17 that returns 2 for errors from sway,
including invalid command, command failed, and invalid subscription
requests
2019-08-06 11:31:39 +09:00
Abdelhakim Qbaich 9bfbb0dd49 Add the missing constant for the switch input type 2019-06-07 10:15:03 +03:00
Brian Ashworth c8e4ca355d swaymsg: fix quiet error reporting
This makes it so swaymsg still returns the correct successful or failed
error code when in quiet mode
2019-05-03 11:09:49 -06:00
Brian Ashworth d7d29fe546 swaymsg: add timeout and type checks
This adds a 3 second timeout to the initial reply in swaymsg. This
prevents swaymsg from hanging when `swaymsg -t get_{inputs,seats}` is
used in i3. The timeout is removed when waiting for a subscribed event
or monitoring for subscribed events.

This also adds type checks to commands where i3 does not reply with all
of the properties that sway does (such as `modes` in `get_outputs`).

This is mostly just a behavioral adjustment since swaymsg should run on
i3. When running under i3, some command reply's (such as the one for
`get_outputs) may have more useful information in the raw json than the
pretty printed version.
2019-04-17 09:07:08 +03:00
Ranieri Althoff fd6903673b Send disabled output available modes on IPC get_outputs
- Also fix missing trailing newline on pretty print

Signed-off-by: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com>
2019-04-16 00:16:20 -04:00
Benjamin Cheng 6737b90cb9 Add heuristics to differentiate touchpads
Use libinput_device_config_tap_get_finger_count to determine whether
a pointer is a touchpad.

swaymsg is also updated to reflect the new touchpad type.
2019-04-14 19:31:36 -04:00
Geoff Greer 6e3046878d Add support for manually setting subpixel hinting on outputs.
Many laptop screens report unknown subpixel order. Allow users to manually set subpixel hinting to work around this.

Addresses https://github.com/swaywm/sway/issues/3163
2019-03-24 09:37:24 +02:00
Flakebi 2578669de7 Flush stdout in swaymsg when in subscribe mode 2019-03-16 12:32:09 -04:00
Peter Grayson b7fe5097e9 Add -p/--pretty option to swaymsg
This new option forces pretty (non-raw/non-JSON) output. By default, when
not using a tty, swaymsg outputs using the "raw" format. This makes it
impossible to, for example, pipe the pretty output to a pager such as
`less` since piping does not use a tty.

The new -p/--pretty option gives the user explicit control over the output
format while retaining the default tty-dependent behavior.

Signed-off-by: Peter Grayson <pete@jpgrayson.net>
2019-03-08 14:29:39 -05:00
Brian Ashworth 7f700e08ac ipc: describe libinput device configuration
This adds the device configurations to the ipc response for libinput
devices. Only supported configuration options for the device will be
added. This also moves `libinput_send_events` inside a new `libinput`
object that contains the rest of the configuration options. sway-ipc(7)
has been updated to reflect the changes and document the new additions.
2019-03-07 08:41:19 -07:00
Brian Ashworth a64a3ee6bb ipc: handle unnamed xkb_active_layout_name
If the active xkb_layout does not have a name, use `NULL` instead of
`json_object_new_string(NULL)`. This also makes it so swaymsg will pretty
print this as `(unnamed)`.
2019-02-11 01:07:11 +01:00
Jan Beich ba96983bf0 Make json-c include respect pkg-config --cflags
json-c.pc contains `Cflags: -I${includedir}/json-c`, so `<json-c/json.h>`
won't be found unless the parent directory is searched by default.
2019-01-23 21:50:06 -05:00
M Stoeckl 1211a81aad Replace wlr_log with sway_log
This commit mostly duplicates the wlr_log functions, although
with a sway_* prefix. (This is very similar to PR #2009.)
However, the logging function no longer needs to be replaceable,
so sway_log_init's second argument is used to set the exit
callback for sway_abort.

wlr_log_init is still invoked in sway/main.c

This commit makes it easier to remove the wlroots dependency for
the helper programs swaymsg, swaybg, swaybar, and swaynag.
2019-01-21 12:59:42 +01:00
Brian Ashworth 4dba42555f get_inputs: add libinput send events mode
Add `libinput_send_events` to the IPC output for `get_inputs` to allow
scripting of mode changes.
2019-01-09 23:17:27 -05:00
Ian Fan a82b8a3c14 Remove readline.c
All occurrences of read_line have been replaced by getline.
peek_line has been absorbed into detect_brace.
2019-01-01 09:01:25 +00:00
Brian Ashworth e62ab6ddbd swaymsg: parse success of single object
Allows swaymsg to parse the success attribute of a single object
response. This is needed for the subscribe event.
2018-11-28 21:41:58 -05:00
Brian Ashworth bf9a52bab0 Implement support for swaymsg -t SUBSCRIBE [-m]
In `i3 4.16`, `i3-msg` can be used with the message type `subscribe`
and has the ability to monitor for responses until killed. This adds
support for both to swaymsg.

If the JSON array of event types is malformed or contains an invalid
event, sway will send a response with `success` set to `false`. If
swaymsg sees this, it will not display the failure and exit.

If the `subscribe` event is successful, swaymsg will wait for the first
response and display that instead of the success message. If
`-m/--monitor` is given, swaymsg will continue monitor for responses
until killed or a malformed response is received.

For the `subscribe` event, the responses will always be printed as JSON.
If `-r/--raw` is given, the JSON will not be pretty printed, which may
be preferred when monitoring due to there being multiple responses.

Example: `swaymsg -t SUBSCRIBE -m "['window']"`
2018-11-28 11:19:18 -05:00
emersion 3a310f92ab
Replace _XOPEN_SOURCE with _POSIX_C_SOURCE
And make sure we don't define both in the same source file.
2018-11-25 17:19:43 +01:00
Harish Krupo d8ad429e39 IPC: Send keyboard layout info in IPC_GET_INPUTS
Signed-off-by: Harish Krupo <harishkrupo@gmail.com>
2018-11-12 22:00:22 +05:30
Cole Mickens ef888321ba ipc: move refresh from output to output->current_mode 2018-11-03 15:09:34 -07:00
Cole Mickens 1f486fe898 swaymsg: get_outputs: use output->current_mode for current mode display 2018-11-03 04:30:53 -07:00
emersion eb675f0dfd
swaymsg: fix get_outputs status code 2018-10-29 11:25:54 +01:00
Ryan Dwyer fa8959532b Fix program name in version strings
When running swaymsg -v, the version returned is actually the version of
swaymsg itself, yet the message displayed was "sway version <version>".
This can create confusion if users update sway and swaymsg but don't
restart sway, then use swaymsg to check the version.

This patch changes the wording to be "swaymsg version <version>"
instead, and likewise for swaybar.

To get the version of a running sway instance, users should run swaymsg
-t get_version.
2018-10-10 18:34:50 +10:00
Ian Fan 3edaf2ce2a ipc: add tick event 2018-08-01 16:57:15 +01:00
emersion ba3511b243 Remove `clipboard` command and `get_clipboard` message 2018-07-10 22:09:21 +01:00
Ian Fan 23c1c26c3f Add get_config message type to ipc 2018-07-10 12:37:37 +01:00
Ian Fan 5fd36164a0 Add get_binding_modes message type to ipc 2018-07-10 12:03:46 +01:00