Skip to content

Instantly share code, notes, and snippets.

@jdleslie
Last active February 9, 2024 18:41
Show Gist options
  • Star 44 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • 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"
}
]
}
]
}
@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$"
]
}
]

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