7

TL;DR Launch Terminal and run: ifconfig | grep -B 6 'status: active' | head -n 1 | cut -d : -f 1 Then run (replace en0 below with the output of the command above): cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources sudo ./airport en0 prefs DisconnectOnLogout=NO sudo pmset -a sleep 0 Long version I am on MacOS Mojave (...


5

You can use the built-in keyboard shortcut Control + Command + Q to lock the screen. The command is also accessible via  → Lock Screen in the Menu bar.


3

Easy alias. Add this to your bashrc alias afk="osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,control down}'" type afk in your terminal to execute.


2

On my 2018 MacBook Pro with Touch Bar, none of the key combinations mentioned that use the power button (now the Touch ID button) worked. Since I couldn’t find a keyboard shortcut to put the screen to sleep, I used the software BetterTouchTool (costs money) to create a custom Touch Bar button for it. See the button “Put Display to Sleep” in this screenshot: ...


2

Everything you need to know (I think) : First, the OP is about whether it’s possible to extend the amount of time the lock screen stays lit, not how long it takes before the unlocked device’s lock screen kicks in. In doing some experimentation with an IPhone 6 and IPad Pro (2nd gen) both using iOS 12.4, Apple has set 2 timers for the lock screen and 1 ...


2

In Logitech Options, you can assign a keyboard sequence to a button. For this example, I assigned the top button on the side (the one highlighted in green) the shortcut to lock the screen CommandControlQ. Now, when I press the button, it's as if I've pressed the keyboard shortcut.


2

If you have the admin account you should be able to change the required settings. The lock screen is affected by 3 settings. The first is the System Preferences -> security & privacy -> general -> Require password 'some time' after sleep or screen saver begins. When you try to change this you should get a prompt for a password. If this does not work ...


2

I found an answer. The Lock Screen app on Github does exactly what I wanted to do. So, by downloading it and adding this to my script, I can lock my monitor remotely: run application "Lock Screen" Edit: It seems the application runs the following script: activate application "SystemUIServer" tell application "System Events" tell process "...


2

This can be done in Energy Saver: Open System Preferences Go to Energy Saver Select Power Adapter Check/mark the "Prevent computer from sleeping automatically when the display is off" option [Optional] Uncheck "Put hard disks to sleep when possible".


1

The setting you want is in preferences -> security and privacy -> general -> require password (some time) after screen sleep or screen saver. Note that the lock is will happen (some time) after either the screen saver starts or the screen sleeping.


1

This should work on most versions #!/bin/bash PATH=/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin "/System/Library/CoreServices/Menu Extras/User.menu/Contents/Resources/CGSession" -suspend sleep 5 pmset sleepnow osascript -e 'tell application "System Events" to sleep' exit 0 The -suspend line will switch to the login screen (which takes a few seconds, ...


1

This is almost as fast as having a lock script. Basically, just turn your ethernet interface(s) off/on. in a terminal run 'sudo -s' before locking run 'ifconfig en1 down' after unlocking run 'ifconfig en1 up' leave the terminal open but just minimize it for later use if you don't know which is your active interface, run ifconfig and look for the entry ...


1

Plug in any USB keyboard to the USB port. Newest MacBook Air use USB-C connectors (ThunderBolt 3) The rest use USB-A Both work with any PC keyboard or Mac keyboard or whatever usb keyboard you might have around. Hopefully the liquid damage didn’t break the USB controller or the system board. Your keyboard might be fine and the problem is no keyboard ...


1

All right, so I've figured out a way to do it. I tried using the command pmset displaysleepnow, and it works as intended. The additional thing is that you have to go to System Preferences > Security & Privacy > General and require a password immediately after the computer display goes to sleep. I then set up an alias: alias lscreen='pmset ...


1

I was able to temporarily correct this problem by deleting: /Users/xxx/Library/Preferences/com.apple.screensaver.plist and restarting my computer. This worked for a little bit, but stoped once I connected my iMac to my MBP as a Target Display.


1

sudo caffeinate -s -u man caffeinate -s Create an assertion to prevent the system from sleeping. This assertion is valid only when system is running on AC power. -u Create an assertion to declare that user is active. If the dis- play is off, this option turns the display on and prevents the display from going into ...


1

If you are using the windows keyboard, try the below shortcut to lock MAC machine, which is worked for me. Cmd+Ctrl+Q = To lock the Mac machine using windows keyboard.


1

I was stumped with some issues for days now, reading everything I could on the subject, and I finally found the solution: it is a keychain problem with as simple solution. The solution is to delete one or more folders located in ~/Library/Keychains/, that is to say folders in the Keychains folder in our user Library. The folders to be deleted have long ...


1

I have a simple one liner for this. It uses System Events to send the default key combo for the Lock Screen command and works in all versions of OSX from High Sierra (10.13) on. Even Mojave! Though it will prompt for additional Security permissions for the App, in the newer OSX versions tell application "System Events" to keystroke "q" using {control down, ...


Only top voted, non community-wiki answers of a minimum length are eligible