jtroo / kanata

Improve keyboard comfort and usability with advanced customization
GNU Lesser General Public License v3.0
3.05k stars 127 forks source link

Feature request: have root permissions but execute cmd as a different user #760

Open moritzketzer opened 9 months ago

moritzketzer commented 9 months ago

Requirements

Describe the bug

When executing Yabai (MacOS window manager) commands within Kanata, the commands fail with a failed to connect to socket error unless prefixed with sudo -u <myusername>.

It seems that the underlying problem is related to how shell commands are executed within Kanata (and KMonad) when interacting with Yabai on macOS. The key issues stem from commands being executed as the root user by Kanata, which conflicts with Yabai's expectation to receive commands from the same user that started it.

Is this a solvable issue or do we have to live with the boilerplate when using Yabai from Kanata?

Thanks for your work and I am happy to assist in troubleshooting!

Relevant kanata config

No response

To Reproduce

ysn (cmd yabai -m space --focus next) leads to yabai-msg: failed to connect to socket. ysn (cmd sudo -u <myusername> sh -c "yabai -m space --focus next") executes successfully. ysn (cmd sh -c "su $SUDO_USER -c 'yabai -m space --focus next'") executes successfully as well (though it feels slower to me).

Expected behavior

Not needing that boilerplate code as a workaround.

Kanata version

kanata 1.6.0-prerelease-1

Debug logs

No response

Operating system

MacOS

Additional context

The issue also exists in KMonad and still persists (I just confirmed it by running yabai with and without boilerplate from KMonad).

Relevant References from KMonad

jtroo commented 9 months ago

From a technical standpoint everything is working as intended, so really there's no bug. But there could certainly be a feature added that makes this more convenient and also perhaps some documentation to aid in the discovery of the issue and any potential solutions.