Commit graph

47 commits

Author SHA1 Message Date
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
emersion 63b4bf5000
Update for swaywm/wlroots#1126 2018-07-09 22:54:30 +01:00
Armin Preiml 354648cc07 refactor success_object 2018-06-30 10:38:16 +02:00
Armin Preiml 659871de1e fix swaymsg: errors are displayed again
Command errors didn't get displayed, because the success function didn't
accept objects
2018-06-30 10:29:32 +02:00
Brian Ashworth a1b5b93d29 Store sway_outputs so that they can be reenabled 2018-06-06 20:11:24 -04:00
Ryan Dwyer 6f4cb2b29d Add tree representation to IPC workspace description 2018-05-29 17:42:11 +10:00
Ryan Dwyer 508a76695c swaymsg: Fix exit code 2018-05-28 13:33:02 +10:00
Ryan Dwyer c72940837c Implement IPC get_seats command 2018-05-12 18:17:36 +10:00
Nicolas Braud-Santoni cb2a3e9036 swaymsg: Fix spelling in error message 2018-05-05 20:40:34 +02:00
emersion 4ab5506064
ipc: add output modes 2018-03-12 13:48:42 +01:00
Dominique Martinet 51f6718581 swaymsg: convert to wlr_log 2018-01-05 23:40:09 +01:00
Rachel K dc0e6d46fb update json-c dep to 0.13 2018-01-04 15:46:37 +00:00
emersion fff67906e1
Pretty-print all output info in swaymsg -t get_outputs 2017-12-29 11:16:57 +01:00
Tony Crisci a4c1270ef0 fix memory leak in swaymsg 2017-12-19 05:38:41 -05:00
Tony Crisci 8b4d81114a fix memory leak in swaymsg 2017-12-18 17:52:50 -05:00
Tony Crisci f2985000f3 ipc get_inputs 2017-12-18 14:27:38 -05:00
nyorain 1cca551c6f Add get_clipbard ipc errors; Adapt swaymsg
Also increase the get_clipboard timeout to 30 secs
2017-07-11 18:04:28 +02:00
nyorain c0f2acce4e Rework get_clipboard implementation 2017-07-07 21:51:34 +02:00
nyorain 02c75ebe37 Implement ipc get_clipboard 2017-07-07 15:38:45 +02:00
Sebastian Noack 173b338567 Add -DVERSION flag for release version numbers 2017-04-26 15:56:46 +02:00
Drew DeVault 60ce81e06a Add pretty printing to swaymsg
If stdout is a tty, it will pretty print unless -r (--raw) is given.

Sample outputs:

```
~/s/s/build > ./bin/swaymsg fullscreen toggle
Error: Permission denied for fullscreen toggle via IPC

~/s/s/build > ./bin/swaymsg -t get_workspaces
Workspace 3:三
  Output: DVI-I-1
  Layout: splith

Workspace 1:一 (off-screen)
  Output: HDMI-A-1
  Layout: splith

Workspace 5:五 (focused)
  Output: HDMI-A-1
  Layout: splith

~/s/s/build > ./bin/swaymsg -t get_inputs
Input device Metadot - Das Keyboard Das Keyboard
  Type: Keyboard
  Sway ID: 9456:320:Metadot_-_Das_Keyboard_Das_Keyb

Input device Wacom Intuos S 2 Pen
  Type: Tablet tool
  Sway ID: 1386:827:Wacom_Intuos_S_2

Input device Wacom Intuos S 2 Pad
  Type: Tablet pad
  Sway ID: 1386:827:Wacom_Intuos_S_2

Input device Logitech Gaming Mouse G502
  Type: Keyboard, Mouse
  Sway ID: 1133:49277:Logitech_Gaming_Mous

~/s/s/build > ./bin/swaymsg -t get_outputs
Output DVI-I-1
  Geometry: 1920x1080 @ 3840,0
  Scale factor: 1x
  Workspace: 3:三

Output DVI-D-1
  Geometry: 1920x1080 @ 0,0
  Scale factor: 1x
  Workspace: 4:四

Output HDMI-A-1
  Geometry: 1920x1080 @ 1920,0
  Scale factor: 1x
  Workspace: 5:五
```
2017-04-03 07:27:25 -04:00
Drew DeVault 9aed9d9359 UnGNUify the codebase 2017-03-10 23:41:24 -05:00
Tony Crisci 6535da7bde swaymsg: pretty print ipc response
fixes #809
2016-07-31 14:47:32 -04:00
Mikkel Oscar Lyderik 5e253fdd9a Correctly exit sway on errors.
Calling `exit` in sway_terminate prevents sway from correctly shutting
down (freeing data, cleanly terminating the ipc server, etc.).

A better way is to exit straight away if the failure occurs before
`wlc_run` and use sway_abort as usual if it occur when wlc is running.
2016-02-26 09:42:21 +01:00
Cole Mickens 28081b7689 libinput 2016-01-19 06:51:36 -08:00
Christoph Gysin 88368362df swaymsg: add newline after response 2015-12-02 22:41:10 +02:00
Christoph Gysin 923c3245ac Fix option parsing
Using 'flag' results in duplicate code paths for short and long options.

This broke the -q short option in swaymsg, because there was:

 {"quiet", no_argument, &quiet, 'q'}

Which will set quiet to 'q' and return 0, not 'q'.
2015-11-28 23:50:44 +02:00
Christoph Gysin bf97a5ada5 swaymsg: Add --help option that prints usage 2015-11-28 23:50:44 +02:00
Christoph Gysin 0d55d1a067 swaymsg: Print usage and exit on unknown options 2015-11-28 23:50:44 +02:00
Christoph Gysin 3ba33321de Use macros for exit values 2015-11-28 23:50:10 +02:00
Drew DeVault 062c74b7d0 Add command line to swaygrab
Also modifies IPC client so that we can work with persistent
connections.
2015-11-27 10:10:29 -05:00
Drew DeVault 27f03c705d Move IPC client into common, refactor IPC 2015-11-27 09:50:04 -05:00
Drew DeVault 5ae359279b Fix build warnings 2015-11-27 09:42:24 -05:00
Drew DeVault a1018f3280 Implement swaymsg IPC behavior 2015-11-26 15:06:41 -05:00
Drew DeVault 9a15371ba3 Parse command line args for swaymsg 2015-11-26 14:31:29 -05:00
Drew DeVault d69cbeabc0 Add swaymsg subproject 2015-11-26 12:41:24 -05:00