The scripts may not launch any app.Īs of today, only the logout hook seems to work.I've installed Ubuntu 20.04 and bluetooth is not working for me. Users place their personal scripts to these folders and make them executable. Per user installation: mkdir ~/Library/Login & mkdir ~/Library/Logout Installation: mkdir /Library/LoginWindowScriptsĬp LoginHook.sh /Library/LoginWindowScripts/LoginHook.shĬp LogoutHook.sh /Library/LoginWindowScripts/LogoutHook.shĬhmod 755 /Library/LoginWindowScripts/LoginHook.shĬhmod 755 /Library/LoginWindowScripts/LogoutHook.shĭefaults write LoginHook /Library/LoginWindowScripts/LoginHook.shĭefaults write LogoutHook /Library/LoginWindowScripts/LogoutHook.sh $1 is the user name, consider this being a sample script: #!/bin/bashĮcho `su -l $user -c /Users/$user/Library/Logout/$s` > $logfile ![]() LogoutHook.sh - commands to be executed as root when a user logs out. If thenĮcho `su -l $user -c /Users/$user/Library/Login/$s` > $logfile $1 is the user name, consider this being a sample script: #!/bin/bash LoginHook.sh - commands to be executed as root when a user logs in. ![]() You could utilize MacOS' Login/Logout hooks as long they work on your machine. The Git metadata will prevent a 'normal' rm from working. Simply clone a Git repository to your desktop. And yes, there are situations where you need to call sudo to remove your own files. Sudo may ask for the password and since it isn't entered it may fail. It is a bad idea to call sudo to remove files. Then it won't be editable for standard users. Alternatively you could save the file in /Library/LaunchAgents. So use with caution.Īlso, the user could delete this code. Warning this code deletes stuff and I did not test it. Save the code below as ~/Library/LaunchAgent/Īnd run launchctl load ~/Library/LaunchAgent/ from the command line. Now create a LaunchAgent to run your script. Make it executable by running chmod +x /usr/local/bin/cleanDesktop.sh. Login in with the account you want to use for guests.Ĭreate a small script with the following code and save it as /usr/local/bin/cleanDesktop.sh. So, creating a LaunchAgent that cleans the desktop at login would do the trick. Unless the files are created with sudo the user can delete files within his own profile. Alternatively, If there is a way for the Guest Account to not reset the dock and wallpaper on logout, this would also work. As for the data, I would like all files that have been downloaded or transferred by the user to be wiped when the user logs out (or equally, when the next user logs in). My solution was to set up a standard account, lock the dock using defaults write size-immutable -bool yes and set the wallpaper manually. The problem with the guest account is, it resets applications placed in the dock between logins as well as resetting the desktop wallpaper (which I would like to keep the same throughout logins). I don't want data to persist between logins on this second account, similar to how the Guest Account works. I have a mac that will be used by myself (admin) and a few other people (second account). Here's a bit more detail about the use case: Thanks!ĮDIT - Thanks for the help so far. More than happy to try out another solution if required. ![]() I'm pretty new to this kind of thing so please explain like I'm 5. Similar to how a guest account works, but without the account being guest and with a little more control. I've read about LaunchDaemon and LaunchAgent but as I understand it, LaunchDaemon will run the command at startup with root permissions, and LaunchAgent will run it at login but with the current user permissions, which won't always be an administrator.Īlternatively, is there a way to run my command without the need of sudo? I'm trying to wipe all files in the home directories (Desktop, Documents etc.) on user login/logout so am currently using sudo rm -rf /users/randomuser/Desktop/* etc. I'm trying to run a command at login/logout which requires sudo.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |