Closed ammgws closed 4 years ago
@ammgws thanks for the PR. can you share the swaymsg output?
@ammgws it would be great to do use grep/sed/awk instead of jq, sinde they come pre-installed in a lot of distros.
Sample swaymsg
output here. The currently focused container will have "focused": true
.
I thought about it and it might not be too bad to stick with jq
:
・swaymsg output is JSON-encoded and awk/etc are most likely not suitable/reliable for this use case.
・I would wager sway users are likely have jq installed as the user base tend to be power users and would often write their own scripts parsing swaymsg output for various things.
・It isn't a hard dependency, so if it is not installed the only thing that happens is that the script doesn't work (same behaviour as pre-PR).
@franciscolourenco Can we proceed with this?
@ammgws still think we should go the extra mile and parse it with grep/sed/awk. Please consider giving it a try if you have time. In the meanwhile I will trust that your implementation is working and merge this. Thank you!
This PR adds support for sway, which is a Wayland compositor.
The current code uses
xprop
to get window IDs, however this does not work for non-X11 sessions.With this PR the
$SWAYSOCK
env var is first checked to see ifsway
is running, and if so, a sway specific command is used to get window IDs. If sway is not running then it should work exactly the same as it is now.Tested with sway 1.2-rc1 and is working well so far. (Cheers for the great fish plugin!)
Note:
jq
is required in order to parse the swaymsg output for the currently focused window ID. If someone has a better or dependency-less method then feel free to comment.