Instead of logging out, just return to login screen?

Discussion in 'macOS' started by dpaanlka, Feb 27, 2007.

  1. dpaanlka macrumors 601

    dpaanlka

    Joined:
    Nov 16, 2004
    Location:
    Illinois
    #1
    Is it possible to set the computer to not log you out, but just return you to the login screen after a certain amount of time?
     
  2. GimmeSlack12 macrumors 603

    GimmeSlack12

    Joined:
    Apr 29, 2005
    Location:
    San Francisco
    #2
    The only way I know to do it is have the Quick Switch User icon in the menu bar, under that menu has the Login Window option. Takes you to the login window without logging you out.

    As for going to that window automatically after a certain amount of time you'll have to explore. Or use a screensaver password feature.
     
  3. semaja2 macrumors 6502a

    Joined:
    Dec 12, 2005
    Location:
    Adelaide
    #3
    This is actually possibly using AppleScript and some perl/doshellscript

    Ill see what i can come up with.

    Edit: Well that took less time then expected

    heres the code:

    Code:
    -- Screen-Lock.applescript
    -- Screen-Lock
    
    --  Created by Andrew James on 28/02/07.
    --  Copyright 2007 semaja2.net. All rights reserved.
    
    
    on launched theObject
    	
    	tell user defaults
    		make new default entry at end of default entries with properties {name:"idleTime", content:60}
    	end tell
    	
    end launched
    
    
    on idle theObject
    	
    	set idleTime to (do shell script "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle,\"\";last}'") as integer
    	--log idleTime
    	if idleTime > (content of default entry "idleTime" of user defaults) then
    		set normalCommand to "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -suspend"
    		
    		do shell script normalCommand
    		
    	end if
    	
    	return 5
    	
    end idle
    
    and heres the application/project file, the application can be hidden by adding the LSUIElement = 1 into the info.plist
     

    Attached Files:

  4. dpaanlka thread starter macrumors 601

    dpaanlka

    Joined:
    Nov 16, 2004
    Location:
    Illinois
    #4
    I don't get the part about hiding it.

    EDIT: Yup, I definitely must be missing something about making it hidden, because this isn't working:

    Picture 3.png

    I also tried String = 1, and Boolean = Yes
     
  5. semaja2 macrumors 6502a

    Joined:
    Dec 12, 2005
    Location:
    Adelaide
    #5
    Make sure your editing the correct info.plist, the one your looking for unless your recompiling in xcode is the file inside Screen-Lock.app

    So select the application and select "Show Package contents"


    PS. to edit the idle time (60 sec by default) use the following command in terminal

    defaults write com.semaja2.Screen-Lock idleTime <time in seconds>

    PSS. Its a number for the setting:

    <key>LSUIElement</key>
    <integer>1</integer>
     
  6. dpaanlka thread starter macrumors 601

    dpaanlka

    Joined:
    Nov 16, 2004
    Location:
    Illinois
    #6
    Awesome this works perfectly now. Should be part of the OS. Thanks!
     
  7. semaja2 macrumors 6502a

    Joined:
    Dec 12, 2005
    Location:
    Adelaide
    #7
    It was no problem, already had most the code lying around here, and i do agree OSX needs some of the features from windows such as the handy "win+l" to lock the screen

    My solution uses the above code to lock the screen but i use quicksilver to run the script.

    I dont think we should have to waste menubar real estate on fast user switch just to lock the screen, or enable the screen saver to lock the screen
     
  8. pianoman macrumors 68000

    pianoman

    Joined:
    May 31, 2006
    #8
    if you don't want to tinker around your system's insides, you might want to try WinSwitch. this requires a menubar icon and manual action, though - it's not automatic.
     
  9. kenyabob macrumors regular

    Joined:
    Jul 13, 2003
    Location:
    San Francisco
    #9
    thank you so much

    Ive been looking for something that could do this for a while, and using this script with iBackground Scripts is the perfect solution. Thanks so much!
     
  10. psxguru macrumors 6502a

    Joined:
    May 19, 2006
    #10
    While I agree there should be a dedicated lock screen function, you can easily imitate it without having to use scripts.

    So long you have the 'require password after sleep/screen saver' enabled in security system preferences. You can then press CTRL SHIFT EJECT to sleep the display or have hot corners setup with one corner being sleep display.
    Admittedly it relies on the screen saver security but it's not a major hassle.
     
  11. kenyabob macrumors regular

    Joined:
    Jul 13, 2003
    Location:
    San Francisco
    #11
    I share this computer with my girlfriend. I setup her own account, but unless the she remembers to hit 'switch user' when she is prompted for my password on wake — she'll simply put in my password and use my account.

    Another poster here has a similar issue with his kid. Unless you can make sure to remind other users on your machine to always hit the switch user button, or to the keyboard shorcut you posted, chances are, they are simply going to use the account of whoever is logged in already.
     
  12. NicoleRichie macrumors 6502

    Joined:
    Jun 30, 2007
    #12
    Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5)

    Just set a hot corner in you sleep settings for screen lock.
     
  13. lineskc macrumors newbie

    Joined:
    Nov 17, 2013
    #13
    Clarification

    I know this is a REALLY OLD post, but it has been very helpful in for me in allowing me to have my computer auto-return to the login window. I am not really familiar with all the code-writing info presented, so I was wondering if you could provide clarification on how to edit the idle time? I'm not sure where to put that, what to put, etc.
    Thank you
     

Share This Page