Yabai: List signals and remove signals without label

Created on 26 Mar 2020  Â·  7Comments  Â·  Source: koekeishiya/yabai

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
suggestion

Most helpful comment

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.

All 7 comments

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.

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.

I’m not trying to be difficult here, but I still don’t see any actual gain in usability by making these changes. Signals are not meant to be modified by a user manually at runtime. The label only exists because it is useful for a script to recognize a signal it automatically created, so that it can later be removed or rewritten from the same script.

Sent from my iPhone

On 21 Apr 2020, at 14:34, Jonathan Huot notifications@github.com wrote:



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.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com/koekeishiya/yabai/issues/458#issuecomment-617151201, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABPDZVZM4P6X5YZYZKKPLEDRNWHEVANCNFSM4LT4IVDA.

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.

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.

Implemented on master.

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tsujp picture tsujp  Â·  3Comments

zoenglinghou picture zoenglinghou  Â·  3Comments

eramdam picture eramdam  Â·  3Comments

haze picture haze  Â·  4Comments

stylerw picture stylerw  Â·  4Comments