![]() Switching between user accounts is a matter of a few seconds. To use the window with a file, use the Jupyter: Run Current File in Python Interactive Window command from the Command Palette. You can then type in code, using Enter to go to a new line and Shift+Enter to run the code. You can find the gist here do shell script "'/System/Library/CoreServices/Menu Extras/nu/Contents/Resources/CGSession' -suspend"īoth scripts are in my quicksilver catalog. To use the window as a console, open it with the Jupyter: Create Interactive Window command from the Command Palette. To just invoke the Login Screen I have another script. Set AppleScript's text item delimiters to ASTID Set AppleScript's text item delimiters to replaceText Set sourceText to text items of sourceText Set AppleScript's text item delimiters to findText Set ASTID to AppleScript's text item delimiters ![]() On findReplace(findText, replaceText, sourceText) Tell process "SecurityAgent" to set value of text field 1 of window 1 to pswd You can run a JXA script from Keyboard Maestro by either of these Execute Script Actions: ExecuteaJavaScriptForAutomation The JXA script may be accessed as text in the Action, or from a file. If exists window 1 of application process "SecurityAgent" then Set pswd to (do shell script "security find-generic-password -g -s \"" & username & "\" -D \"User Login\" 2>&1 1>/dev/null | sed -e 's/password: \"//' -e 's/\"//'") If (do shell script "stat -f %Su /dev/console") is username then exit repeat ![]() Use universal access to enter the text and to click the button The `id -ur username` part gets the uid number that corresponds to the username and substitutes it at the end of the CGSession commandĭo shell script "/System/Library/CoreServices/'Menu Extras'/nu/Contents/Resources/CGSession -switchToUserID `id -ur " & username & "`" Set username to word -1 of my findReplace(".scpt", "", (path to me as text)) This script requires "Enable access for assistive devices" to be enabled in the Universal Access system preference pane. The first time you run this script, you will be prompted to allow Keychain Scripting to access the password of the key. The script assumes that you make this key in your login.keychain, which is the default one. a key) for the other user's password using Keychain Access, and call it "", where "user" is the other user's name and with the description "User Login". You must first make a password item (a.k.a. This script MUST be named "Switch to User.scpt", where User is the name of the user to switch to. The password is stored in the keychain, so you don't have to worry about storing login password in cleartext. ![]() I had problems with it so I tweaked it to get if to work. So I chose the Execute Shell Script action, execute script file and chose the script (path: ~/Documents/Obsidian/Scripts/Obsidian_Export.sh).To switch to a specific user I invoke a script I found in the comments of a article. Invoking it via KM can’t be difficult task, can it…? As a newbie it took me a while to learn about variables and copying from the clipboard but when it worked I thought that I’ve achieved the hard part. Mv "$.pdf" ~/Library/Mobile\ Documents/com~apple~CloudDocs/Desktopįairly simple but it does what it should – at least when I run it from the terminal. To do so I have to copy the note’s title and then invoke the script: #!/bin/sh What do I try to do? I want a simple possibility to export an Obsidian note to pdf and I want to solve this with a combination of a shell script and KM. Maybe anyone could give some assistance on my mistake? This would be great for learning purposes! So if you don’t mind I’d post the script and what I try to achieve. Thank you for both of your answers! However, I am fairly new to scripting, KM and so on. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |