Skip to content

Instantly share code, notes, and snippets.

@jdleslie
Last active November 14, 2024 13:36
Show Gist options
  • Save jdleslie/9a3566037e35437a3846c428f306318f to your computer and use it in GitHub Desktop.
Save jdleslie/9a3566037e35437a3846c428f306318f to your computer and use it in GitHub Desktop.
Map Apple modifiers (Ctrl, Option, Command) to Windows modifiers (Ctrl, Win, Alt) in Citrix Workspace using Karabiner Elements, with working Alt+Tab and Windows key shortcuts
{
"title": "Citrix Receiver/Workspace modifiers for Ctrl, Alt, Windows order",
"rules": [
{
"description": "In Citrix, add fn modifier to tab so it is forwarded",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "tab",
"modifiers": [ "fn" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change left_option to Alt key via \"⌘⌥ Command (left)-Option\"",
"manipulators": [
{
"from": {
"key_code": "left_option",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "left_option",
"modifiers": [ "left_command", "fn" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change right_option to Alt key via \"⌘⌥ Command (left)-Option\"",
"manipulators": [
{
"from": {
"key_code": "right_option",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "right_option",
"modifiers": [ "left_command", "fn" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change left_command as well via \"Send Windows logo key using ⌘ Command (right)\"",
"manipulators": [
{
"from": {
"key_code": "left_command",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "right_command"
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}
]
}
{
"title": "Citrix Receiver/Workspace modifiers for Ctrl, Windows, Alt order",
"rules": [
{
"description": "In Citrix, add fn modifier to tab so it is forwarded",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "tab",
"modifiers": [ "fn" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change left_command to Alt via \"⌘⌥ Command (left)-Option\"",
"manipulators": [
{
"from": {
"key_code": "left_command",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "left_command",
"modifiers": [ "left_option" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change right_command to Alt via \"⌘⌥ Command (left)-Option\"",
"manipulators": [
{
"from": {
"key_code": "right_command",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "left_command",
"modifiers": [ "left_option" ]
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change left_option to Windows logo key via \"Send Windows logo key using ⌘ Command (right)\"",
"manipulators": [
{
"from": {
"key_code": "left_option",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "right_command"
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}, {
"description": "In Citrix, change right_option to Windows logo key via \"Send Windows logo key using ⌘ Command (right)\"",
"manipulators": [
{
"from": {
"key_code": "right_option",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "right_command"
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
]
}
]
}
]
}
]
}
{
"title": "Home/End mapping compatible with Citrix Receiver/Workspace",
"rules": [
{
/* In Citrix, the Windows remote handles this combination natively */
"description": "Except in Citrix, change Control-Home to navigate to top of document via Command-Up",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "home",
"modifiers": {
"mandatory": [
"control"
],
"optional": [
"shift"
]
}
},
"to": [
{
"key_code": "up_arrow",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
},
{
/* ibid */
"description": "Except in Citrix, change Control-End to navigate to bottom of document via Command-Down",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "end",
"modifiers": {
"mandatory": [
"control"
],
"optional": [
"shift"
]
}
},
"to": [
{
"key_code": "down_arrow",
"modifiers": [
"left_command"
]
}
],
"type": "basic"
}
]
},
{
/* Fn-Left/Right maps to Home/End in Citrix, making it a better choice than Command-Left/Right for Citrix users.
MacOS supports Home/End functionality in two ways:
* Command-Left/Right: Maps to Control-Left/Right in Citrix (useless), behaves as expected in MacOS
* Fn-Left/Right: Maps to Home/End correctly in Citrix, behaves as expected in MacOS
Reference: https://www.cnet.com/how-to/two-mac-keyboard-shortcuts-for-missing-home-and-end-keys/
*/
"description": "Change Home to navigate to start of line via Fn-Left (Fn-Left maps to Home in Citrix)",
"manipulators": [
{
"from": {
"key_code": "home",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": [
"fn"
]
}
],
"type": "basic"
}
]
},
{
/* ibid */
"description": "Change End to navigate to end of line via Fn-Right (Fn-Right maps to End in Citrix)",
"manipulators": [
{
"from": {
"key_code": "end",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": [
"fn"
]
}
],
"type": "basic"
}
]
}
]
}
{
/* Based on https://gist.github.com/permil/ed5a66f7e0cb712b0a9c03532530b9dd */
"title": "Print Screen mapping compatible with Citrix Receiver/Workspace",
"rules": [
{
"description": "Except in Citrix, change print_screen to capture entire screen via Command-Shift-3",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "print_screen"
},
"to": [
{
"key_code": "3",
"modifiers": [
"left_command",
"left_shift"
]
}
],
"type": "basic"
}
]
},
{
"description": "Except in Citrix, change print_screen to capture current window via Command-Shift-4",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.citrix\\.XenAppViewer$",
"^com\\.citrix\\.receiver\\.icaviewer\\.mac$"
],
"type": "frontmost_application_unless"
}
],
"from": {
"key_code": "print_screen",
"modifiers": {
"mandatory": [
"option"
]
}
},
"parameters": {
"basic.to_delayed_action_delay_milliseconds": 50
},
"to": [
{
"key_code": "4",
"modifiers": [
"left_command",
"left_shift"
]
}
],
"to_delayed_action": {
"to_if_invoked": [
{
"key_code": "spacebar"
}
]
},
"type": "basic"
}
]
}
]
}
@raneenmoves
Copy link

Hi! This is awesome thanks! Any idea how to use ALT for other shortcut functions? E.g. Excel Group / Ungroup shortcut is ALT+SHIFT + Left/Right Arrow - This doesn't seem to work anymore once I updated my mac and trying to map it from the windows keyboard to citrix receiver.

@QuantumHawk
Copy link

QuantumHawk commented Jan 9, 2022

Hi! can you help me make it work?
My issue is I use left control instead left command in my mac
but after that, left control become a Win button in citrix. But it has to work like a control!
so ctrl+c/ctrl+V is not working
I need a rule when left control will work in citrix like in mac..

Monosnap 2022-01-06 23-39-51

```

{
"title": "Citrix Receiver/Workspace modifiers for Ctrl",
"rules": [
{
"description": "Ctrl",
"manipulators": [
{
"from": {
"key_code": "left_control",
"modifiers": { "optional": [ "any" ] }
},
"to": {
"key_code": "left_command",
"modifiers": { "optional": [ "any" ] }
},
"type": "basic",
"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\.citrix\.XenAppViewer$",
"^com\.citrix\.receiver\.icaviewer\.mac$"
]
}
]
}
]
}
]
}

@oxblood8
Copy link

oxblood8 commented May 1, 2022

Hi there. So I am new to the Macos world, coming from 20+ years of Windows dev. I am using Citrix daily for work and thank you for the wonderful scripts above, massive help.

However, within Macos I have switched the Command/Control keys to make it more Windows (damn muscle memory). When I do this, it throws off the commands within Citrix (Left Control key is what is triggering Windows start button, not the windows key).

Therefore I am wondering is there a way to update the JSON files to account for the Control/Command swap within Macos?

@jdleslie
Copy link
Author

jdleslie commented May 2, 2022

Hi there. So I am new to the Macos world, coming from 20+ years of Windows dev. I am using Citrix daily for work and thank you for the wonderful scripts above, massive help.

However, within Macos I have switched the Command/Control keys to make it more Windows (damn muscle memory). When I do this, it throws off the commands within Citrix (Left Control key is what is triggering Windows start button, not the windows key).

Therefore I am wondering is there a way to update the JSON files to account for the Control/Command swap within Macos?

You might try to update the value of key_code value in from and reload the rules in Karabiner. Here is a list of key codes: https://github.com/JoshuaManuel/Karabiner-Elements-Key-List

Mapping a mapped key sounds fragile, but will probably work.

@denisula
Copy link

Hi! can you help me make it work? My issue is I use left control instead left command in my mac but after that, left control become a Win button in citrix. But it has to work like a control! so ctrl+c/ctrl+V is not working I need a rule when left control will work in citrix like in mac..

Monosnap 2022-01-06 23-39-51
> {
> "title": "Citrix Receiver/Workspace modifiers for Ctrl",
> "rules": [
> {
> "description": "Ctrl",
> "manipulators": [
> {
> "from": {
> "key_code": "left_control",
> "modifiers": { "optional": [ "any" ] }
> },
> "to": {
> "key_code": "left_command",
> "modifiers": { "optional": [ "any" ] }
> },
> "type": "basic",
> "conditions": [
> {
> "type": "frontmost_application_if",
> "bundle_identifiers": [
> "^com\.citrix\.XenAppViewer$",
> "^com\.citrix\.receiver\.icaviewer\.mac$"
> ]
> }
> ]
> }
> ]
> }
> ]
> }

I have same question

@peterminlee
Copy link

I have a question on the Alt function. It seems that after applying this script, my "Alt" gets triggered if I hold down the Option button but not as a single click. For example, when I am in Excel on Citrix, I would normally run Excel shortcuts by clicking Alt + X + X (i.e. Alt-H-I-C to add a new column). However, because I have to hold Option for Alt to trigger, I can't run these shortcuts. Any advice on how to make this work?

@GeorgeCas
Copy link

GeorgeCas commented Aug 30, 2022

This is beautiful, chef's kiss. Makes using Citrix on my Mac so much nicer. I find it best to just double tap the window so it's maximised but not fullscreen and then it's easy to hop around in and out the session.

Makes me actually want to use my MacBook for programming on the go through Citrix. The only criticism I have is for Citrix themselves not offering all this functionality as standard through their app.

@airstrike
Copy link

airstrike commented Mar 6, 2023

I have a question on the Alt function. It seems that after applying this script, my "Alt" gets triggered if I hold down the Option button but not as a single click. For example, when I am in Excel on Citrix, I would normally run Excel shortcuts by clicking Alt + X + X (i.e. Alt-H-I-C to add a new column). However, because I have to hold Option for Alt to trigger, I can't run these shortcuts. Any advice on how to make this work?

I realize it's been almost a year since you asked this, but I had the exact same issue. I solved it by removing the , "fn" modifier from lines #38 and #62 in the gist above. I also never needed to add the rule called "add fn modifier to tab so it is forwarded". I've made these edits in a forked gist to make your life easier in case you're interested

FYI I have also add a few rules under "Simple modifications" which make life easier. Here's a screenshot in case you'd like to copy them:

image

@airstrike
Copy link

This is beautiful, chef's kiss. Makes using Citrix on my Mac so much nicer. I find it best to just double tap the window so it's maximised but not fullscreen and then it's easy to hop around in and out the session.

Makes me actually want to use my MacBook for programming on the go through Citrix. The only criticism I have is for Citrix themselves not offering all this functionality as standard through their app.

Can't you just use Cmd+Tab to alt-tab out of the full screen Citrix window and Option+Tab as "Alt+Tab" within Citrix? That's how I roll

@GeorgeCas
Copy link

Can't you just use Cmd+Tab to alt-tab out of the full screen Citrix window and Option+Tab as "Alt+Tab" within Citrix? That's how I roll

Yeah, I have it setup to work that way too and it's nice. For whatever reason I still just keep it as a maximised window, I like having the Mac top toolbar visible. Also respect for responding to the year old query of the other guy ;)

If OP sees this then again, chef's kiss, I daily your config for work purposes.

@stephenharper82
Copy link

Thank you so much for sharing this. Straightforward instructions and worked first time! Looking forward to using my Mac for my day job now! :D

@stephenharper82
Copy link

What key combination gets a '#' please?

@stephenharper82
Copy link

I've been able to workaround the above by disabling the rules for the right hand side of the keyboard and using opt + 3 as normal.

I am struggling to get the equivalent of hodling ALT and selecting text to select a rectangular block. Using my mapped to alt opt key results in a right click most of the time (I have seen it do a block select twice and I can't figure out why). Any ideas?

@den3erw
Copy link

den3erw commented Jun 30, 2023

Is there any way to restrict these key maps to Citrix? I am also seeing these changes throughout MacOS.

@oxblood8
Copy link

oxblood8 commented Jul 1, 2023

@den3erw Yes you can limit this to just Citrix. In the scripts you will see the following:

"conditions": [
{
"type": "frontmost_application_if",
"bundle_identifiers": [
"^com\.citrix\.XenAppViewer$",
"^com\.citrix\.receiver\.icaviewer\.mac$"
]
}
]

@larrylsp
Copy link

larrylsp commented Nov 14, 2024

Struggling to have these key binds work for me. I'm running Sequoia 15.1, Karabiner Elements 15.3, Citrix Workspace 24.09.054. I have a MX Keys device with the LHS keys labeled as following: Ctrl, Option/Start, Command/Alt. My Mac keyboard settings are all default. I've tried enabling both key order types (separately) and have the right options ticked in Workspace. Also did a full restart.

What gives? Has anyone else faced this problem before? Really appreciate any help or tips.

Update: I didn't turn on the Device in settings. First time using Karabiner. Works like a charm - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment