Skip to content

Instantly share code, notes, and snippets.

@seonar22
Forked from fasiha/README.md
Created October 24, 2022 12:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seonar22/28cc1b10e35b3ad280e71b8d5152d3e1 to your computer and use it in GitHub Desktop.
Save seonar22/28cc1b10e35b3ad280e71b8d5152d3e1 to your computer and use it in GitHub Desktop.
iTerm2, Karabiner Elements, and Hammerspoon for new Mac

Introduction

Setup for

Setup

First, install all three tools above. (Or just iTerm2 if you don't care about keyboard speedups; or just Karabiner Elements & Hammerspoon if you don't care about iTerm2).

Then clone this repository to your local computer: run this in Terminal:

git clone https://gist.github.com/94d743ed3c4a8c097795ed1d03f52e00.git fasiha-mac-keyboard
cd fasiha-mac-keyboard

Karabiner Elements

Then, make this mod available to Karabiner Elements:

cp fasiha-karabiner.json ~/.config/karabiner/assets/complex_modifications/

Open Karabiner Elements ➜ Complex Modifications tab ➜ Add Rule. Find "fasiha's stuff", and click "Enable All" to the right.

Now, left-shift by itself should be (, while right-shift by itself should be ).

For the shortcuts to bring applications to the front with \, we need Hammerspoon.

Hammerspoon

My Hammerspoon config relies on the above Karabiner Elements mod installed and activated.

cp init.lua ~/.hammerspoon/

Restart Hammerspoon: click its icon in the very top-right menu bar and select "Reload config".

Now, \+s for example will open Safari, etc. See the init.lua file for all the applications. You can of course just tap that key for a \.

iTerm2

Open iTerm2. Go to iTerm2 ➜ Preferences ➜ Profiles ➜ Other Actions… ➜ Import JSON Profiles ➜ select the JSON file in this directory.

Now ⌥+Space (Option-Spacebar) will pop open a nice Hotkey window at the top of your screen.

{
"title": "fasiha's stuff",
"rules": [
{
"description": "Change backslash to command+control+option+shift if pressed with other keys (Post spacebar when pressed alone)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "backslash",
"modifiers": {
"optional": [
"any"
]
}
},
"to": [
{
"key_code": "left_shift",
"modifiers": [
"left_command",
"left_control",
"left_option"
]
}
],
"to_if_alone": [
{
"key_code": "backslash"
}
]
}
]
},
{
"description": "Better Shifting: Parentheses on shift keys, via Modern Space Cadet (rev 3)",
"manipulators": [
{
"type": "basic",
"from": {
"key_code": "right_shift"
},
"to": [
{
"key_code": "right_shift"
}
],
"to_if_alone": [
{
"key_code": "0",
"modifiers": [
"right_shift"
]
}
]
},
{
"type": "basic",
"from": {
"key_code": "left_shift"
},
"to": [
{
"key_code": "left_shift"
}
],
"to_if_alone": [
{
"key_code": "9",
"modifiers": [
"right_shift"
]
}
]
}
]
}
]
}
local hyper = {"cmd", "alt", "ctrl","shift"}
local applicationHotkeys = {
-- c = 'Google Chrome',
v = 'Visual Studio Code',
-- s = 'Safari',
z = 'iTerm',
f = 'Firefox',
d = 'Day One',
a = 'Signal',
}
for key, app in pairs(applicationHotkeys) do
hs.hotkey.bind(hyper, key, function()
hs.application.launchOrFocus(app)
end)
end
local wm = require('window-management')
local hotkey = require "hs.hotkey"
-- Window Management
hotkey.bind(hyper,"left", function()
wm.moveWindowToPosition(wm.screenPositions.leftTwoThird)
end)
hotkey.bind(hyper,"right", function()
wm.moveWindowToPosition(wm.screenPositions.rightTwoThird)
end)
hotkey.bind(hyper,'pad1', function()
wm.moveWindowToPosition(wm.screenPositions.bottomLeft)
end)
hotkey.bind(hyper,"pad2", function()
wm.moveWindowToPosition(wm.screenPositions.bottomMiddle)
end)
hotkey.bind(hyper,"pad3", function()
wm.moveWindowToPosition(wm.screenPositions.bottomRight)
end)
hotkey.bind(hyper,"pad4", function()
wm.moveWindowToPosition(wm.screenPositions.left)
end)
hotkey.bind(hyper,"pad5", function()
wm.moveWindowToPosition(wm.screenPositions.mid)
end)
hotkey.bind(hyper,"pad6", function()
wm.moveWindowToPosition(wm.screenPositions.right)
end)
hotkey.bind(hyper,"pad7", function()
wm.moveWindowToPosition(wm.screenPositions.topLeft)
end)
hotkey.bind(hyper,"pad8", function()
wm.moveWindowToPosition(wm.screenPositions.topMiddle)
end)
hotkey.bind(hyper,"pad9", function()
wm.moveWindowToPosition(wm.screenPositions.topRight)
end)
{
"Profiles": [
{
"Ansi 5 Color" : {
"Green Component" : 0,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Tags" : [
],
"Ansi 12 Color" : {
"Green Component" : 0.3333333432674408,
"Red Component" : 0.3333333432674408,
"Blue Component" : 1
},
"Use Non-ASCII Font" : false,
"Right Option Key Sends" : 2,
"Bold Color" : {
"Green Component" : 1,
"Red Component" : 1,
"Blue Component" : 1
},
"Ansi 8 Color" : {
"Green Component" : 0.3333333432674408,
"Red Component" : 0.3333333432674408,
"Blue Component" : 0.3333333432674408
},
"Ansi 9 Color" : {
"Green Component" : 0.3333333432674408,
"Red Component" : 1,
"Blue Component" : 0.3333333432674408
},
"Ansi 7 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Rows" : 25,
"Default Bookmark" : "No",
"Ansi 3 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0
},
"Cursor Guide Color" : {
"Red Component" : 0.70213186740875244,
"Color Space" : "sRGB",
"Blue Component" : 1,
"Alpha Component" : 0.25,
"Green Component" : 0.9268307089805603
},
"Non-ASCII Anti Aliased" : true,
"Use Bright Bold" : true,
"Ansi 10 Color" : {
"Green Component" : 1,
"Red Component" : 0.3333333432674408,
"Blue Component" : 0.3333333432674408
},
"Ambiguous Double Width" : false,
"Jobs to Ignore" : [
"rlogin",
"ssh",
"slogin",
"telnet"
],
"Ansi 15 Color" : {
"Green Component" : 1,
"Red Component" : 1,
"Blue Component" : 1
},
"Foreground Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Blinking Cursor" : false,
"Disable Window Resizing" : true,
"Sync Title" : false,
"Prompt Before Closing 2" : false,
"BM Growl" : false,
"Command" : "",
"Description" : "Default",
"Mouse Reporting" : true,
"Screen" : -1,
"Selection Color" : {
"Green Component" : 0.8353000283241272,
"Red Component" : 0.70980000495910645,
"Blue Component" : 1
},
"Only The Default BG Color Uses Transparency" : false,
"Columns" : 80,
"Idle Code" : 0,
"Ansi 13 Color" : {
"Green Component" : 0.3333333432674408,
"Red Component" : 1,
"Blue Component" : 1
},
"Custom Command" : "No",
"ASCII Anti Aliased" : true,
"Non Ascii Font" : "Monaco 12",
"Vertical Spacing" : 1,
"Use Bold Font" : false,
"Option Key Sends" : 2,
"Selected Text Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Background Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Character Encoding" : 4,
"Ansi 11 Color" : {
"Green Component" : 1,
"Red Component" : 1,
"Blue Component" : 0.3333333432674408
},
"Use Italic Font" : true,
"Unlimited Scrollback" : false,
"Keyboard Map" : {
"0xf700-0x260000" : {
"Action" : 10,
"Text" : "[1;6A"
},
"0x37-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0x32-0x40000" : {
"Action" : 11,
"Text" : "0x00"
},
"0xf709-0x20000" : {
"Action" : 10,
"Text" : "[17;2~"
},
"0xf70c-0x20000" : {
"Action" : 10,
"Text" : "[20;2~"
},
"0xf729-0x20000" : {
"Action" : 10,
"Text" : "[1;2H"
},
"0xf72b-0x40000" : {
"Action" : 10,
"Text" : "[1;5F"
},
"0xf705-0x20000" : {
"Action" : 10,
"Text" : "[1;2Q"
},
"0xf703-0x260000" : {
"Action" : 10,
"Text" : "[1;6C"
},
"0xf700-0x220000" : {
"Action" : 10,
"Text" : "[1;2A"
},
"0xf701-0x280000" : {
"Action" : 11,
"Text" : "0x1b 0x1b 0x5b 0x42"
},
"0x38-0x40000" : {
"Action" : 11,
"Text" : "0x7f"
},
"0x33-0x40000" : {
"Action" : 11,
"Text" : "0x1b"
},
"0xf703-0x220000" : {
"Action" : 10,
"Text" : "[1;2C"
},
"0xf701-0x240000" : {
"Action" : 10,
"Text" : "[1;5B"
},
"0xf70d-0x20000" : {
"Action" : 10,
"Text" : "[21;2~"
},
"0xf702-0x260000" : {
"Action" : 10,
"Text" : "[1;6D"
},
"0xf729-0x40000" : {
"Action" : 10,
"Text" : "[1;5H"
},
"0xf706-0x20000" : {
"Action" : 10,
"Text" : "[1;2R"
},
"0x34-0x40000" : {
"Action" : 11,
"Text" : "0x1c"
},
"0xf700-0x280000" : {
"Action" : 11,
"Text" : "0x1b 0x1b 0x5b 0x41"
},
"0x2d-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0xf70e-0x20000" : {
"Action" : 10,
"Text" : "[23;2~"
},
"0xf702-0x220000" : {
"Action" : 10,
"Text" : "[1;2D"
},
"0xf703-0x280000" : {
"Text" : "f",
"Action" : 10
},
"0xf700-0x240000" : {
"Action" : 10,
"Text" : "[1;5A"
},
"0xf707-0x20000" : {
"Action" : 10,
"Text" : "[1;2S"
},
"0xf70a-0x20000" : {
"Action" : 10,
"Text" : "[18;2~"
},
"0x35-0x40000" : {
"Action" : 11,
"Text" : "0x1d"
},
"0xf70f-0x20000" : {
"Action" : 10,
"Text" : "[24;2~"
},
"0xf703-0x240000" : {
"Text" : "f",
"Action" : 10
},
"0xf701-0x260000" : {
"Action" : 10,
"Text" : "[1;6B"
},
"0xf702-0x280000" : {
"Text" : "b",
"Action" : 10
},
"0xf72b-0x20000" : {
"Action" : 10,
"Text" : "[1;2F"
},
"0x36-0x40000" : {
"Action" : 11,
"Text" : "0x1e"
},
"0xf708-0x20000" : {
"Action" : 10,
"Text" : "[15;2~"
},
"0xf701-0x220000" : {
"Action" : 10,
"Text" : "[1;2B"
},
"0xf70b-0x20000" : {
"Action" : 10,
"Text" : "[19;2~"
},
"0xf702-0x240000" : {
"Text" : "b",
"Action" : 10
},
"0xf704-0x20000" : {
"Action" : 10,
"Text" : "[1;2P"
}
},
"Window Type" : 0,
"Cursor Type" : 1,
"Background Image Location" : "",
"Blur" : false,
"Badge Color" : {
"Red Component" : 1,
"Color Space" : "sRGB",
"Blue Component" : 0,
"Alpha Component" : 0.5,
"Green Component" : 0.1491314172744751
},
"Scrollback Lines" : 1000,
"Send Code When Idle" : false,
"Close Sessions On End" : true,
"Terminal Type" : "xterm-256color",
"Visual Bell" : true,
"Flashing Bell" : false,
"Silence Bell" : false,
"Ansi 14 Color" : {
"Green Component" : 1,
"Red Component" : 0.3333333432674408,
"Blue Component" : 1
},
"Name" : "Default",
"Cursor Text Color" : {
"Green Component" : 1,
"Red Component" : 1,
"Blue Component" : 1
},
"Shortcut" : "",
"Cursor Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527
},
"Transparency" : 0.10684171597633135,
"Ansi 1 Color" : {
"Green Component" : 0,
"Red Component" : 0.73333334922790527,
"Blue Component" : 0
},
"Horizontal Spacing" : 1,
"Custom Directory" : "Recycle",
"Ansi 0 Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0
},
"Scrollback With Status Bar" : true,
"Ansi 6 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0,
"Blue Component" : 0.73333334922790527
},
"Guid" : "3F8FF7C1-C7DB-4A61-A6F6-B706303414F0",
"Normal Font" : "FiraCode-Regular 13",
"Ansi 2 Color" : {
"Green Component" : 0.73333334922790527,
"Red Component" : 0,
"Blue Component" : 0
},
"Link Color" : {
"Red Component" : 0,
"Color Space" : "sRGB",
"Blue Component" : 0.73423302173614502,
"Alpha Component" : 1,
"Green Component" : 0.35916060209274292
},
"Ansi 4 Color" : {
"Green Component" : 0,
"Red Component" : 0,
"Blue Component" : 0.73333334922790527
}
},
{
"Prompt Before Closing 2" : false,
"Selected Text Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
"Rows" : 25,
"Ansi 11 Color" : {
"Green Component" : 1,
"Blue Component" : 0.3333333432674408,
"Red Component" : 1
},
"Use Italic Font" : true,
"HotKey Characters" : " ",
"Foreground Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527
},
"HotKey Window Floats" : false,
"Right Option Key Sends" : 2,
"Character Encoding" : 4,
"Selection Color" : {
"Green Component" : 0.8353000283241272,
"Blue Component" : 1,
"Red Component" : 0.70980000495910645
},
"Blend" : 0.5,
"Mouse Reporting" : true,
"Ansi 4 Color" : {
"Green Component" : 0,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0
},
"Non-ASCII Anti Aliased" : true,
"Sync Title" : false,
"Disable Window Resizing" : true,
"Description" : "Default",
"Close Sessions On End" : true,
"Jobs to Ignore" : [
"rlogin",
"ssh",
"slogin",
"telnet"
],
"Scrollback With Status Bar" : true,
"Scrollback Lines" : 1000,
"HotKey Window Reopens On Activation" : false,
"Flashing Bell" : false,
"Cursor Guide Color" : {
"Red Component" : 0.65000000000000002,
"Color Space" : "Calibrated",
"Blue Component" : 1,
"Alpha Component" : 0.25,
"Green Component" : 0.91000000000000003
},
"BM Growl" : false,
"Ansi 3 Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0,
"Red Component" : 0.73333334922790527
},
"Use Non-ASCII Font" : false,
"Link Color" : {
"Red Component" : 0.023,
"Color Space" : "Calibrated",
"Blue Component" : 0.67800000000000005,
"Alpha Component" : 1,
"Green Component" : 0.27000000000000002
},
"Shortcut" : "",
"Background Image Location" : "",
"Bold Color" : {
"Green Component" : 1,
"Blue Component" : 1,
"Red Component" : 1
},
"Unlimited Scrollback" : false,
"Custom Command" : "No",
"HotKey Key Code" : 49,
"Keyboard Map" : {
"0xf700-0x260000" : {
"Action" : 10,
"Text" : "[1;6A"
},
"0x37-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0x32-0x40000" : {
"Action" : 11,
"Text" : "0x00"
},
"0xf709-0x20000" : {
"Action" : 10,
"Text" : "[17;2~"
},
"0xf70c-0x20000" : {
"Action" : 10,
"Text" : "[20;2~"
},
"0xf729-0x20000" : {
"Action" : 10,
"Text" : "[1;2H"
},
"0xf72b-0x40000" : {
"Action" : 10,
"Text" : "[1;5F"
},
"0xf705-0x20000" : {
"Action" : 10,
"Text" : "[1;2Q"
},
"0xf703-0x260000" : {
"Action" : 10,
"Text" : "[1;6C"
},
"0xf700-0x220000" : {
"Action" : 10,
"Text" : "[1;2A"
},
"0xf701-0x280000" : {
"Action" : 11,
"Text" : "0x1b 0x1b 0x5b 0x42"
},
"0x38-0x40000" : {
"Action" : 11,
"Text" : "0x7f"
},
"0x33-0x40000" : {
"Action" : 11,
"Text" : "0x1b"
},
"0xf703-0x220000" : {
"Action" : 10,
"Text" : "[1;2C"
},
"0xf701-0x240000" : {
"Action" : 10,
"Text" : "[1;5B"
},
"0xf70d-0x20000" : {
"Action" : 10,
"Text" : "[21;2~"
},
"0xf702-0x260000" : {
"Action" : 10,
"Text" : "[1;6D"
},
"0xf729-0x40000" : {
"Action" : 10,
"Text" : "[1;5H"
},
"0xf706-0x20000" : {
"Action" : 10,
"Text" : "[1;2R"
},
"0x34-0x40000" : {
"Action" : 11,
"Text" : "0x1c"
},
"0xf700-0x280000" : {
"Action" : 11,
"Text" : "0x1b 0x1b 0x5b 0x41"
},
"0x2d-0x40000" : {
"Action" : 11,
"Text" : "0x1f"
},
"0xf70e-0x20000" : {
"Action" : 10,
"Text" : "[23;2~"
},
"0xf702-0x220000" : {
"Action" : 10,
"Text" : "[1;2D"
},
"0xf703-0x280000" : {
"Action" : 10,
"Text" : "f"
},
"0xf700-0x240000" : {
"Action" : 10,
"Text" : "[1;5A"
},
"0xf707-0x20000" : {
"Action" : 10,
"Text" : "[1;2S"
},
"0xf70a-0x20000" : {
"Action" : 10,
"Text" : "[18;2~"
},
"0x35-0x40000" : {
"Action" : 11,
"Text" : "0x1d"
},
"0xf70f-0x20000" : {
"Action" : 10,
"Text" : "[24;2~"
},
"0xf703-0x240000" : {
"Action" : 10,
"Text" : "f"
},
"0xf701-0x260000" : {
"Action" : 10,
"Text" : "[1;6B"
},
"0xf702-0x280000" : {
"Action" : 10,
"Text" : "b"
},
"0xf72b-0x20000" : {
"Action" : 10,
"Text" : "[1;2F"
},
"0x36-0x40000" : {
"Action" : 11,
"Text" : "0x1e"
},
"0xf708-0x20000" : {
"Action" : 10,
"Text" : "[15;2~"
},
"0xf701-0x220000" : {
"Action" : 10,
"Text" : "[1;2B"
},
"0xf70b-0x20000" : {
"Action" : 10,
"Text" : "[19;2~"
},
"0xf702-0x240000" : {
"Action" : 10,
"Text" : "b"
},
"0xf704-0x20000" : {
"Action" : 10,
"Text" : "[1;2P"
}
},
"Ansi 14 Color" : {
"Green Component" : 1,
"Blue Component" : 1,
"Red Component" : 0.3333333432674408
},
"Ansi 2 Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0,
"Red Component" : 0
},
"Send Code When Idle" : false,
"ASCII Anti Aliased" : true,
"Tags" : [
],
"Ansi 9 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 0.3333333432674408,
"Red Component" : 1
},
"Use Bold Font" : false,
"Silence Bell" : false,
"Ansi 12 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 1,
"Red Component" : 0.3333333432674408
},
"Window Type" : 2,
"Use Bright Bold" : true,
"Has Hotkey" : true,
"HotKey Modifier Activation" : 0,
"Cursor Text Color" : {
"Green Component" : 1,
"Blue Component" : 1,
"Red Component" : 1
},
"HotKey Window Dock Click Action" : 0,
"Default Bookmark" : "No",
"Cursor Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527
},
"Ansi 1 Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0.73333334922790527
},
"Name" : "Hotkey Window",
"Blinking Cursor" : false,
"Guid" : "941AC260-1710-49FA-BF1D-AD74A575DFC3",
"Ansi 8 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 0.3333333432674408,
"Red Component" : 0.3333333432674408
},
"Ansi 10 Color" : {
"Green Component" : 1,
"Blue Component" : 0.3333333432674408,
"Red Component" : 0.3333333432674408
},
"Idle Code" : 0,
"Badge Color" : {
"Red Component" : 1,
"Color Space" : "Calibrated",
"Blue Component" : 0,
"Alpha Component" : 0.5,
"Green Component" : 0
},
"Ambiguous Double Width" : false,
"Blur Radius" : 2,
"Ansi 0 Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
"Blur" : true,
"Normal Font" : "FiraCode-Regular 12",
"Vertical Spacing" : 1,
"Ansi 7 Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527
},
"Space" : -1,
"HotKey Window AutoHides" : true,
"Command" : "",
"Terminal Type" : "xterm-256color",
"Horizontal Spacing" : 1,
"Option Key Sends" : 2,
"HotKey Window Animates" : false,
"HotKey Modifier Flags" : 524288,
"Ansi 15 Color" : {
"Green Component" : 1,
"Blue Component" : 1,
"Red Component" : 1
},
"Ansi 6 Color" : {
"Green Component" : 0.73333334922790527,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0
},
"Transparency" : 0.30000001192092896,
"HotKey Activated By Modifier" : false,
"Background Color" : {
"Green Component" : 0,
"Blue Component" : 0,
"Red Component" : 0
},
"Screen" : -1,
"HotKey Characters Ignoring Modifiers" : " ",
"Non Ascii Font" : "Monaco 12",
"Ansi 13 Color" : {
"Green Component" : 0.3333333432674408,
"Blue Component" : 1,
"Red Component" : 1
},
"Columns" : 80,
"HotKey Alternate Shortcuts" : [
],
"Visual Bell" : true,
"Custom Directory" : "No",
"Ansi 5 Color" : {
"Green Component" : 0,
"Blue Component" : 0.73333334922790527,
"Red Component" : 0.73333334922790527
}
}
]
}
local This = {}
-- To easily layout windows on the screen, we use hs.grid to create a 3x2 grid.
-- If you want to use a more detailed grid, simply change its dimension here
local GRID_SIZE = 3
local GRID_SIZE_Y = 2
local HALF_GRID_SIZE = GRID_SIZE_Y / 2
local ONE_THIRD = GRID_SIZE / 3
local TWO_THIRD = GRID_SIZE * 2 /3
-- Set the grid size and add a few pixels of margin
-- Also, don't animate window changes... That's too slow
hs.grid.setGrid(GRID_SIZE .. 'x' .. GRID_SIZE_Y)
hs.grid.setMargins({5, 5})
hs.window.animationDuration = 0
-- Defining screen positions
local screenPositions = {}
screenPositions.left = {x = 0, y = 0, w = ONE_THIRD, h = GRID_SIZE_Y }
screenPositions.mid = {x = ONE_THIRD, y = 0, w = ONE_THIRD, h = GRID_SIZE_Y }
screenPositions.right = {x = TWO_THIRD, y = 0, w = ONE_THIRD, h = GRID_SIZE_Y }
screenPositions.topLeft = {x = 0, y = 0, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.topMiddle = {x = ONE_THIRD, y = 0, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.topRight = {x = TWO_THIRD, y = 0, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.bottomLeft = {x = 0, y = HALF_GRID_SIZE, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.bottomMiddle = {x = ONE_THIRD, y = HALF_GRID_SIZE, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.bottomRight = {x = TWO_THIRD, y = HALF_GRID_SIZE, w = ONE_THIRD, h = HALF_GRID_SIZE}
screenPositions.leftTwoThird = {x = 0, y = 0, w = TWO_THIRD, h = GRID_SIZE_Y }
screenPositions.rightTwoThird = {x = ONE_THIRD, y = 0, w = TWO_THIRD, h = GRID_SIZE_Y }
This.screenPositions = screenPositions
-- This function will move either the specified or the focuesd
-- window to the requested screen position
function This.moveWindowToPosition(cell, window)
if window == nil then
window = hs.window.focusedWindow()
end
if window then
local screen = window:screen()
hs.grid.set(window, cell, screen)
end
end
-- This function will move either the specified or the focused
-- window to the center of the sreen and let it fill up the
-- entire screen.
function This.windowMaximize(factor, window)
if window == nil then
window = hs.window.focusedWindow()
end
if window then
window:maximize()
end
end
return This
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment