Skip to content

Repository files navigation

MenuLock

implements CMD+L for windows enthusiasts To be more precise, it puts display to sleep.

To lock your computer, you need to have System Preferences > Security & Privacy > Require the password Immediately after sleep saver begins, and a password set.

example

(Hi, Cédric!)

Why ?

  • Because Keychain Access' menubar introduce the question: "Why lock keychain?"
  • Because ctrl+shift+power/eject can become halt or reboot if user is not careful
  • Because Hot Corners are not loved by everyone (and they only start screensaver)

Some details

Building the App

Workspace Setup

This app uses Cocoapods. Please first install it (usually with sudo gem install cocoapods). Then follow this:

  • git clone https://github.com/ftiff/MenuLock.git
  • cd MenuLock
  • pod install
  • open MenuLock.xcworkspace/

Then go to Product > Scheme > Edit Scheme… and make sure Run > Executable is set to "MenuLock.app".

Build

install

  • sudo installer -target / -pkg /tmp/MenuLock-1.1.pkg
  • sudo launchctl load /Library/LaunchAgents/io.fti.MenuLock.plist

Key Modifiers

let keyMask: NSEventModifierFlags = [ .AlternateKeyMask, .ShiftKeyMask]

event modifier flagDescription
AlphaShiftKeyMaskCaps Lock
ShiftKeyMaskShift
ControlKeyMaskControl
AlternateKeyMaskAlt
CommandKeyMaskCommand
NumericPadKeyMaskSet if any key in the numeric keypad is pressed (and arrows)
HelpKeyMaskHelp Key (does this still exists?)
FunctionKeyMaskThe function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).

Key Code

let keyCode = UInt(0x25)

These are defined in /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/Headers/Events.h. Be careful these work for US Keyboards. I'd love to learn a better way to do this.

Key CodeHex Equivalent
A0x00
S0x01
D0x02
F0x03
H0x04
G0x05
Z0x06
X0x07
C0x08
V0x09
B0x0B
Q0x0C
W0x0D
E0x0E
R0x0F
Y0x10
T0x11
10x12
20x13
30x14
40x15
60x16
50x17
Equal0x18
90x19
70x1A
Minus0x1B
80x1C
00x1D
RightBracket0x1E
O0x1F
U0x20
LeftBracket0x21
I0x22
P0x23
L0x25
J0x26
Quote0x27
K0x28
Semicolon0x29
Backslash0x2A
Comma0x2B
Slash0x2C
N0x2D
M0x2E
Period0x2F
Grave0x32
KeypadDecimal0x41
KeypadMultiply0x43
KeypadPlus0x45
KeypadClear0x47
KeypadDivide0x4B
KeypadEnter0x4C
KeypadMinus0x4E
KeypadEquals0x51
Keypad00x52
Keypad10x53
Keypad20x54
Keypad30x55
Keypad40x56
Keypad50x57
Keypad60x58
Keypad70x59
Keypad80x5B
Keypad90x5C
Return0x24
Tab0x30
Space0x31
Delete0x33
Escape0x35
Command0x37
Shift0x38
CapsLock0x39
Option0x3A
Control0x3B
RightShift0x3C
RightOption0x3D
RightControl0x3E
Function0x3F
F170x40
VolumeUp0x48
VolumeDown0x49
Mute0x4A
F180x4F
F190x50
F200x5A
F50x60
F60x61
F70x62
F30x63
F80x64
F90x65
F110x67
F130x69
F160x6A
F140x6B
F100x6D
F120x6F
F150x71
Help0x72
Home0x73
PageUp0x74
ForwardDelete0x75
F40x76
End0x77
F20x78
PageDown0x79
F10x7A
LeftArrow0x7B
RightArrow0x7C
DownArrow0x7D
UpArrow0x7E

About

implements CMD+L for windows enthusiasts

Resources

Stars

32 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages