franciscolourenco / done

A fish-shell package to automatically receive notifications when long processes finish.
MIT License
779 stars 71 forks source link

Add support for `sway` #50

Closed ammgws closed 4 years ago

ammgws commented 5 years ago

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 if sway 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.

franciscolourenco commented 5 years ago

@ammgws thanks for the PR. can you share the swaymsg output?

franciscolourenco commented 5 years ago

@ammgws it would be great to do use grep/sed/awk instead of jq, sinde they come pre-installed in a lot of distros.

6A61736F6E206E61646572 commented 5 years ago

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).

ammgws commented 4 years ago

@franciscolourenco Can we proceed with this?

franciscolourenco commented 4 years ago

@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!

franciscolourenco commented 4 years ago

https://github.com/franciscolourenco/done/releases/tag/1.9.0