How can I remap the command key to the control key and vice versa on Mac Wine?

Questions about Wine on macOS.
Locked
Oneechan69
Newbie
Newbie
Posts: 4
Joined: Wed Sep 29, 2021 10:52 pm

How can I remap the command key to the control key and vice versa on Mac Wine?

Post by Oneechan69 »

If it helps, I installed it with homebrew https://formulae.brew.sh/cask/wine-stable, and use the terminal (terminal aliases) to run exe files.
Oneechan69
Newbie
Newbie
Posts: 4
Joined: Wed Sep 29, 2021 10:52 pm

Re: How can I remap the command key to the control key and vice versa on Mac Wine?

Post by Oneechan69 »

I did some google before and after, and didn't find a way to do so, and it seems like there isn't a way for Wine without tweaking configuration files and whatnot of the wine program. Instead what can be done on Mac is adding hotkeys with Karabiner Elements: https://karabiner-elements.pqrs.org/. First install the app, then you add complex modifications under the folder for it:

Code: Select all

~/.config/karabiner/assets/complex_modifications
In finder, press CMD + Shift + G and paste the directory into it to navigate there. Complex modifications are saved in JSON files. This is my JSON for remapping CTRL to CMD (This also works if you use Karabiner Elements which I do; it will just switch the hotkey back to CTRL. That's good if you always want to use CTRL hotkeys on macOS, inside and outside of Wine):

Code: Select all

{
    "title": "Wine Hotkeys",
    "rules": [
        {
            "description": "Swap Command with control for Wine.",
            "manipulators": [
                {
                    "type": "basic",
                    "from": {
                        "key_code": "left_command"
                    },
                    "to": [
                        {
                            "key_code": "left_control"
                        }
                    ],
                    "conditions": [
                        {
                            "type": "frontmost_application_if",
                            "bundle_identifiers": [
                                "^$"
                            ],
                            "file_paths": [
                                "^/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine-preloader",
                                "^/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine64-preloader"
                            ]
                        }
                    ]
                },
                {
                    "type": "basic",
                    "from": {
                        "key_code": "right_command"
                    },
                    "to": [
                        {
                            "key_code": "right_control"
                        }
                    ],
                    "conditions": [
                        {
                            "type": "frontmost_application_if",
                            "bundle_identifiers": [
                                "^$"
                            ],
                            "file_paths": [
                                "^/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine-preloader",
                                "^/Applications/Wine Stable.app/Contents/Resources/wine/bin/wine64-preloader"
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
I installed wine using "brew install wine-stable", so you might have to change the locations for wine-preloader and wine64-preloader depending on where they are located on your Mac. Also feel free to change the title and description to whatever you want. After you have created a JSON complex modification in the said folder, open Karabiner Elements (which should be in the Applications folder) and click "Complex Modifications" click "Add rule" and you should see your title, click "enable" to the right of it. I think you should be done now, if it doesn't work immediately after (test the hotkey a few times to make sure first), restart the application with Activity Monitor, and try restarting your Mac if that doesn't work either.
Locked