Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List signals and remove signals without label #458

Closed
danijar opened this issue Mar 26, 2020 · 7 comments
Closed

List signals and remove signals without label #458

danijar opened this issue Mar 26, 2020 · 7 comments
Labels
suggestion Request for new feature or some form of enhancement

Comments

@danijar
Copy link

danijar commented Mar 26, 2020

It would be nice to see a list of registered signals and remove them without having to reload yabai.

For example, list the signals (not sure if JSON output would be more consistent):

$ yabai -m signal --list
0: event=application_activated action=...
1: event=application_activated action=...
2: event=space_changed action=...

Then delete them by index:

$ yabai -m signal --remove 2
@koekeishiya koekeishiya added the suggestion Request for new feature or some form of enhancement label Mar 30, 2020
@koekeishiya
Copy link
Owner

Not sure if I see the point in this. I don't think "permanent" signals should be manually queried and modified in a running session. If you are still in a prototyping stage, labels are just as simple to utilize in my opinion. If you are modifying signals during runtime, I would also suggest labeling them.

@JonathanHuot
Copy link

I have the same feeling that something is missing in the signal labelling feature.
May I propose alternatives:

  • add a "-m signal clear" action to remove all signals
  • make "label" mandatory
  • if "label" is missing, randomly generate one (however still need a "-m signal list" feature

However the API is asymmetric that cuz we can add but remove only those with label.

@koekeishiya
Copy link
Owner

koekeishiya commented Apr 21, 2020 via email

@koekeishiya
Copy link
Owner

koekeishiya commented Apr 21, 2020

If someone can come up with a practical problem they are trying to solve, that require changes to the signal system, or is tedious to do because of limitations of the current system, please let me know and we can discuss viable solutions from that point.

@danijar
Copy link
Author

danijar commented Apr 21, 2020

Having a function to list existing signals would let users inspect this hidden state, making it easier to set up new signal handlers. When I created signal handlers, it was quite confusing because at some point I ended up with multiple handlers registered to the same signal and no way to query this information, so I had to restart yabai often.

@koekeishiya koekeishiya added the addressed on master; not released Fixed upstream, but not yet released label May 23, 2020
@koekeishiya
Copy link
Owner

Implemented on master.

@koekeishiya
Copy link
Owner

koekeishiya commented May 23, 2020

sample output:

~ yabai -m signal --list | jq                                                                     0:48
[
  {
    "index": 0,
    "label": "",
    "app": "",
    "title": "",
    "event": "application_terminated",
    "action": "yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
  },
  {
    "index": 1,
    "label": "",
    "app": "",
    "title": "",
    "event": "application_activated",
    "action": "pkill -SIGUSR1 limelight &> /dev/null"
  },
  {
    "index": 2,
    "label": "",
    "app": "",
    "title": "",
    "event": "window_destroyed",
    "action": "yabai -m query --windows --window &> /dev/null || yabai -m window --focus mouse"
  },
  {
    "index": 3,
    "label": "AA1BE1CD-6665-47B5-B5C4-111FBFFF0E1D",
    "app": "",
    "title": "",
    "event": "window_moved",
    "action": "\trestore=\"$(yabai -m query --windows --window \"${YABAI_WINDOW_ID}\" |\n    jq -re --arg YABAI_WINDOW_ID \"${YABAI_WINDOW_ID}\" '\n        if .floating == 1 then\n           .frame | \"yabai -m window \\($YABAI_WINDOW_ID) --move abs:\\(.x):\\(.y)\\n\"\n               + \"yabai -m window \\($YABAI_WINDOW_ID) --resize abs:\\(.w):\\(.h)\"\n        else\n            empty\n        end')\" \n\tif [[ ! -z \"${restore}\" ]]\n\tthen\n\t\techo \"${restore}\" > \"/tmp/yabai-restore/${YABAI_WINDOW_ID}.restore\"\n\t\tchmod +x \"/tmp/yabai-restore/${YABAI_WINDOW_ID}.restore\"\n\tfi"
  },
  {
    "index": 4,
    "label": "91CC175D-9D33-4D48-9767-0FAF33E63209",
    "app": "",
    "title": "",
    "event": "window_resized",
    "action": "\trestore=\"$(yabai -m query --windows --window \"${YABAI_WINDOW_ID}\" |\n    jq -re --arg YABAI_WINDOW_ID \"${YABAI_WINDOW_ID}\" '\n        if .floating == 1 then\n           .frame | \"yabai -m window \\($YABAI_WINDOW_ID) --move abs:\\(.x):\\(.y)\\n\"\n               + \"yabai -m window \\($YABAI_WINDOW_ID) --resize abs:\\(.w):\\(.h)\"\n        else\n            empty\n        end')\" \n\tif [[ ! -z \"${restore}\" ]]\n\tthen\n\t\techo \"${restore}\" > \"/tmp/yabai-restore/${YABAI_WINDOW_ID}.restore\"\n\t\tchmod +x \"/tmp/yabai-restore/${YABAI_WINDOW_ID}.restore\"\n\tfi"
  }
]

Remove by using the index from the output: yabai -m signal --remove 1
Note that the index is based on its location in the list and is not a fixed identifier, e.g if you remove signal with index 4, the signal that previously had index 5 will now become index 4 etc.

@koekeishiya koekeishiya removed the addressed on master; not released Fixed upstream, but not yet released label Jun 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Request for new feature or some form of enhancement
Projects
None yet
Development

No branches or pull requests

3 participants