Questions tagged [script]
A collection of commands that may be from a CLI Shell, or programming language such as AppleScript, which are executed in order with limited iteration, usually as a way of automating actions or events.
122
questions with no upvoted or accepted answers
6
votes
0
answers
969
views
How to detect locked screen / login-session from a script?
I am looking a way for a script (either bash or AppleScript, doesn't matter) to detect whether the state of the screen or the user login session is locked or not (i.e. the user will need to type in ...
5
votes
0
answers
198
views
Detect macOS beta using script
In a shell script, how can I tell whether or not the script is running on a (public) beta version of macOS?
Preferrably, I would like to check this without matching a specific version of macOS, since ...
4
votes
0
answers
97
views
Shell script hangs when run with a shebang line
This didn't used to happen, but now when I try to execute a shell script in my path by name, it just hangs.
The script: ~/bin/foo:
#!/bin/sh
echo this is foo
My PATH:
/usr/bin:/bin
What happens ...
3
votes
1
answer
78
views
Bulk copy/export name, Modification & Creation Date from multiple files in a folder
I have a bunch of files inside a folder that I want to get the Date Modified and Created from and copy it into a text document or some kind of tab delimited document. I have no idea how to do this.
...
3
votes
0
answers
729
views
Force reset system preferences cache
I'm trying to enable/disable time announcement feature that's present in Dock & Menu Bar > Clock > Announce the time with a shell script.
When I read the plist file, I can see that it's set ...
3
votes
0
answers
619
views
How can I add shells to the list in Run Shell Script in the Automator now that the .plist is on the read-only volume?
This question has what seems like a duplicate here, but I have an update.
The answer to that question -- how to add a shell to Automator -- is to modify Shells.plist. Specifically:
The list of these ...
3
votes
0
answers
156
views
How can I detect which button was clicked in the DMG EULA confirmation screen
I'm using the open command to automate (via bash) opening a dmg which has a EULA attached to it. When I run open my_app_distribution.dmg I get a screen that looks like this:
The open commands uses ...
3
votes
0
answers
53
views
How can I customize Spotlight so that if a number (or some pattern matching a regex) is typed, I can execute a command or script?
I want to "augment" Spotlight to do things like:
If an integer (^\d+$), open a site, example.com/$0.
If a UUID (^\d{8}-\d{4}-\d{4}-\d{4}-\d{12}$), open another site.
If a string beginning with "user:"...
3
votes
0
answers
289
views
Can I use the Terminal to find all OpenMeta tags on my system?
I know that there are apps that can do this, so I figure it must be possible: I'd like to compile a list of every OpenMeta tag that I've used on my Mac (OS X 10.8.3). But here's the rub: I'd ideally ...
2
votes
0
answers
137
views
Automator workflow crashing silently when ran as Finder extension
I made an Automator workflow that essentially runs a shell script to optimize images. I intend to use it as a Finder.app extension, by selecting images and running the workflow as a "quick action&...
2
votes
2
answers
591
views
macOS: Double click on a file and display the output from a CLI command on the file?
There is a file type called "netCDF". My goal is to be able to double click on a netCDF file on Finder and see the text output from a CLI command to which the filename is given.
Specifics: ...
2
votes
0
answers
421
views
Switch between virtual desktops by scrolling on the menu bar
Looking for a script, macro, automation script, TIY solution that will allow me to hover my mouse over the menu bar scroll my mouse wheel up and down which in turn will switch between my left and ...
2
votes
0
answers
100
views
Automatically copy files to a flash drive in terminal
I am trying to make a script that will automatically copy any files in the home directory with the extension .txt. What commands should I use in Terminal to search for and copy any txt files to a ...
2
votes
0
answers
34
views
How to script Catalina Security & Privacy Preferences
In my line of work we use LanRev for our remote management. However, with new machines using Catalina, we've had to manually allow Full Disc Access in order for remote control to work.
Is there way ...
2
votes
0
answers
172
views
Keyboard shortcut for in-application action (Spotify play/pause) from another application
Is there a way to write a script, get an app, automator, or etc that would make spotify play/pause with a keyboard shortcut such as cmd+alt+shift+p that would work from outside of Spotify?
In other ...
2
votes
0
answers
252
views
Create Local Network Directory User on OS X server via Terminal
I found this post:
How can I create an Open Directory network user with a command?
but it didn't have any answers on it. I know there's a way to create a local network directory user, but I cannot ...
2
votes
0
answers
90
views
How to see LaTeX output in Mail.app?
I frequently receive mails with LaTeX text which appear in normal text like
$frac{(1+cos\theta)^2
but I want them to be rendered in Mail.app as it would be written in books.
Is there any plugin or ...
2
votes
0
answers
3k
views
Applescript click by position
I'm trying to click on a button using YX coordinate,
it's work with some app, but I have one app with two windows which give me an issue.
here is my original code
tell application "System Events"
...
2
votes
0
answers
90
views
Empty Trash Hook
Is there a way to trigger some custom code to run if somebody tries to empty the trash like for login / logout hooks?
Is there a way to interrupt the empty trash process for non-admin users?
2
votes
0
answers
218
views
AppleScript or Safari add-on to highlight text
I have some variable that I would like to highlight in Safari.
I was thinking AppleScript, but I can use something else otherwise.
I'm using a Chrome plug-in which does the same, any idea how to do ...
2
votes
0
answers
459
views
'Add notes' to a Calendar event using Automator
I would like to build a 'Service' for selected text which:
Get the currently selected text
Creates an Calendar event
adds the selected text as a 'note' for that Calendar event
I prefer Automator for ...
2
votes
0
answers
55
views
How can I detect an incoming call on Yosemite
I'd like to detect an incoming Facetime call and run certain scripts as a result. I'd like to achieve something similar to when iTunes pauses when there is an incoming call, but I would run my own ...
2
votes
0
answers
3k
views
Applescript / Automator - Pass variables between them
I have a question about how to pass the applescript input from one computer to another computer's automator input (I created it as a program). I've created the script below to ask for the filename and ...
2
votes
0
answers
48
views
Run script when I connect something to the line in port?
I'm connecting my phone to my mac via the line in port to listen to podcasts. I'm using the app LineIn to do this and I was wondering whether there was anyway I could have:
My audio input be set to ...
2
votes
0
answers
221
views
How can I tell programmatically whether a process is in app-nap?
I'm looking for a script, built-in shell command, or program (with sources) that can tell me whether a process is in App-nap mode or not.
I want to use it in automated testing, for profiling and to ...
2
votes
0
answers
494
views
Correct Way to Check if Spotlight Has Indexed a Folder's Contents
Okay, so I've written a script that uses mdfind to more quickly match files, however, I need to find the best way to check whether a target directory is indexed or not, so I can fall back to using ...
2
votes
0
answers
1k
views
How can I create (nested) Keynote.app slides from a XML file?
I have some nested lists (XML/OPML file) and I am looking for a (automated) process to create Keynote presentations from them. Use case: I write concepts for presentations in an Outliner, then would ...
2
votes
0
answers
796
views
With Lion, Problems Accessing Shared NTFS Folders with SMB://
We are testing a local login script that we created for our Macintosh users on Lion. It has worked fine on all OS X versions prior to 10.7. Listed below is the script that we are using. When we run ...
2
votes
2
answers
3k
views
Apple Script: 'activate' an application in fullscreen
Im trying to run tell application "X" to activate on an application that is running in fullscreen, but its not working. Any ideas on how I can work around this and give focus to a running app in ...
1
vote
0
answers
20
views
How can I assign a keyboard shortcut to a process to open a Spotlight window and repopulate it specific filter(s) (eg. "Kind" == "Folder")
My current process to search for a specific directory listing uses Spotlight wth filters in a regular Finder window. I add file attribute filters to refine my search to folders only, and sometimes a ...
1
vote
0
answers
28
views
Is there an app or tool I can use to make it so that a script will run every time a certain application launches or terminates, without polling?
I want to run a simple shell script any time one of a few different applications terminate. I can identify the applications by their filename, bundle ID, or full path, so any method that can use those ...
1
vote
0
answers
131
views
iOS feature, script or app to quickly determine who's calling based on AI search of the internet?
Most the time when I get a call from a random number, I ignore it, google it, and call them back if I recognise it’s from someone relevant.
This process is annoyingly cumbersome for something I might ...
1
vote
0
answers
64
views
Custom protocol handlers in Sonoma
I want to be able to insert hyperlinks into Calendar entries, such that when I click them, then the command
/opt/homebrew/bin/emacsclient -n --eval '(org-open-link-from-string \"" & ...
1
vote
0
answers
56
views
osascript keystroke character case with VMware web console
Looking to get the ability to simulating typing a password into a vm console. Figured osascript and keystroke should be the answer.
If I run the following I get what I believe to be the correct ...
1
vote
0
answers
88
views
How do you disable "suggest completions while typing" autocomplete feature while editing Applescript in Automator?
I think in a recent update to Ventura they added an autocomplete feature to Applescript editing. In Script Editor, there's a setting to enable or disable "suggest completions while typing". ...
1
vote
0
answers
731
views
Download file from iCloud/GoogleDrive from Terminal or script
I use Ventura with iCloud and also GoogleDrive.
I have some files in iCloud, not physically available on my MacBook, but I could right-click on it and click to "download now" (basically OS ...
1
vote
1
answer
105
views
Undentified shell script "open" added to open at login
Logged in into my laptop this morning, to see that a shell script "open" has been added to open at login. Its from an unidentified developer, created a month back, but just got added to ...
1
vote
0
answers
167
views
Cannot run shell script from mounted network share: unidentified developer
We have a few shared shell scripts on our file server, and would like them to run in Terminal when double-clicked in the Finder.
The share is mounted, and the scripts do run when called by their full ...
1
vote
0
answers
245
views
How do you make a .command file autostart on system bootup?
I'm on macOS Monterey 12.4.
How do you make a .command file autostart on system bootup?
1
vote
0
answers
264
views
Creating conditional script for softwareupdate command
Looking to create a script that runs a function if there are software updates available. Currently I am just using this:
softwareupdate -ia && myFunction
This creates my desired effect, but ...
1
vote
0
answers
368
views
How to create a file that will start 3 different instances of iTerm (or 3 different windows in iTerm) and run a command in each one of them?
Every time I restart my mac I have to open a bunch of iTerm windows/split panes and in each one of them run some commands to start my project. How can I do that in macOS?
1
vote
1
answer
90
views
Launch DMG drive script failing after restart
I have an automation (screenshots of it here: https://www.icloud.com/iclouddrive/0bB-1AiIWdJc1jmkfdjRbsAVA#Launch_Plex_Media_Automation_ )saved as an app in Automator with the following AppleScripts ...
1
vote
0
answers
200
views
Using launchd to run script once a day when logged in
I'm in the situation where I would like to run a script only once per day when I open my MacBook.
I guess I could have the script note the date it was last run, and have it reject when run on the ...
1
vote
0
answers
425
views
Apple Notes: Could someone help write a script for me that opens Notes.app, creates blank new note, opens note in sep window, bring to front?
The kind of shortcut I'm looking for is essentially: double-click an icon on right screen, launch "NEW NOTE", POP it to FRONT, so I can immediately begin typing or paste my selection into.
I'...
1
vote
2
answers
807
views
AppleScript App to start a Slideshow in Finder
I want to write an AppleScript App that starts a full screen slideshow with all pictures in the currently active folder in Finder (on Big Sur/Apple M1).
Manually, in Finder I would have to open a ...
1
vote
0
answers
119
views
Centrify: install using script in macOS 10.15
We were used to install Centrify using a simple script launched from KACE:
sudo /usr/sbin/installer -pkg CentrifyDC-5.5.2-x86_64.pkg -target /
Starting from Catalina, it seems that the script ...
1
vote
0
answers
220
views
Mounting problems with autofs and executable maps
I wanted to replace my already existing and working autofs mount to my NAS with a script variant, which additionally wakes up the server via WoL if necessary and requests the password via keychain. ...
1
vote
0
answers
42
views
How can I fix my USB volume control from changing the volume two steps at a time?
I have this USB volume control, but when I adjust the volume, it adjusts it two steps at a time.
When I connect it, it registers as a USB keyboard.
My guess is that it is sending the "keypress" for ...
1
vote
0
answers
163
views
How to open a window and tab in Terminal via Javascript automation
I want to use the Script Editor program to create a script (Javascript) that will recreate my Terminal window and tab setup. I open a few windows, open tabs within those windows, label the tabs, run ...
1
vote
0
answers
597
views
ApplesScript, autopress space bar
I am trying to run a script that will double press space bar in a fast sequence after this command
repeat 10000 times
tell application "System Events" to keystroke "g" using command down
...