Key Synth Not Working from Script
- Dominant language
- C
- Stars
- 8.1k
- Forks
- 241
- PR merge metrics
- No merged PRs in 30d
Description
### **Hardware**
OS: Monterey 12.0.1 (21A559)
Chip: Apple M1 Max
### **Setup**
skhdrc excerpt
``` SHELL
window < backspace : . $HOME/.config/bin/helper && close_window
```
helper function
```SHELL
close_window ()
{
FULLSCREEN=$(yabai -m query --windows --window | jq '."is-native-fullscreen"')
if [[ $FULLSCREEN = "true" ]]; then
skhd -k 'cmd + shift - w'
fi
skhd -k "escape"
}
```
**### Issue**
`set -ex` output
```SHELL
+zsh:1> close_window
+close_window:2> FULLSCREEN=+close_window:2> yabai -m query --windows --window
+close_window:2> FULLSCREEN=+close_window:2> jq '."is-native-fullscreen"'
+close_window:2> FULLSCREEN=true
+close_window:3> [[ true = true ]]
+close_window:4> skhd -k 'cmd + shift - w'
+close_window:7> skhd -k escape
```
So it appears to be running correctly. It doesn't matter if started through brew or a terminal. `skhd -V` doesn't show any issues. On first run it asks for permissions to use system events and it is granted. skhd -k escape runs because it switches the mode appropriately.
The only thing that doesn't appear to work is `skhd -k 'cmd + shift - w'`, which does work directly from a terminal. I also tried to switch it to `osascript -l JavaScript -e 'Application("System Events").keystroke("w",{using: ["command down", "shift down"]})'` which also runs but does not close the window. I've tried including the path and even setting taking it out of the script and putting it directly into the skhdrc with the same results.
Tested on Finder and Firefox.
Edit: `yabai -m window --close` works but only when the title bar is shown in native fullscreen.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the shown skhdrc binding and helper function, then compare `skhd -k 'cmd + shift - w'` with `skhd -k escape` under the reported macOS setup. Check the `skhd -k` entry point and verify behavior in Finder and Firefox; done means the command reliably closes the window when invoked from the script.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- macos, shell
- Domain
- cli, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100