Mac::Applications::List - get a list of applications on your macOS machine
Functional programming style:
my @apps = apps;
my @apps = apps '/some/path';
my @apps = apps < /path/to/dir1 /path/to/dir2 >;
OO programming interface:
my $my_apps = MacAppList.new(); # create a MacAppList object
$my_apps.apps('/some/dir'); # populate object
$my_apps.exists('Safari'); # test to see if an app exists
$my_apps.print; # print out a list of apps
$my_apps.list; # return an array of apps
This module finds and generates a list of applications in the standard locations
on macOS. Since applications can be located anywhere and it's not practical to
search the entire drive, additional directories can be passed to the to
apps() function or method.
In the simplest usage, the module provides a single function,
takes an optional argument of an array of strings or a string scalar. The
function is automatically exported.
An OO interface is also provided which provides convenient methods for
determining if an app exists, printing the list of apps, and returning the list
of apps found.
The module searches
~/Applications directories and their subdirectories as well as the
directories and subdirectories of the directory paths passed to the function.
The optional argument to
apps is a string or array of strings representing
paths to additional directories to be searched for applications.
sub apps( [ < dir1 dir2 ... > ] )
sub apps( [ 'dir' ] )
Generates and returns unique array of application names found in standard
application installation directories on macOS. A string or array of strings of
paths to other directories can be included to search additional directories.
Returns an array of strings of the names of the applications found. The strings
do not include the path to the applications, just the application name.
If the directory does not exist, the module generates a warning. The function
will still return a list of applications found in other direcgtories.
new( [ < dir1 dir2 ... > ] )
new( [ 'dir' ] )
Creates a new MacAppList object, optionally initialized with directories to
search which will be searched in addition to standard app directory locations.
find_apps( [ < dir1 dir2 ... > ] )
find_apps( [ 'dir' ] )
Searches for new apps in standard locations, plus any directories the object
was initialized with plus any optional directories provided. Returns an array
exists( Str )
Determines if an app exists. Returns boolean.
Prints out a aplphabetical list of apps to the command line
Returns an array of apps.
Assuming Raku and zef is already installed, install the module with:
zef install Mac::Applications::List
If you don't have Raku with zef installed yet, it's easiest to install them both with homebrew if you already have brew installed:
brew install rakudo-star
If you don't have brew installed, install it with:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Note, however, that the homebrew install may be months out of date.
To ensure you get the absolute latest version of Raku, see this
page for other
installation options. Whatever method you choose to install Raku, just be sure
zef command gets installed and is working on your machine as well.
Bugs and Limitations
This app will not find apps that have been "localized," i.e. apps contained in
a diectory with a ".localized" extension. A future release will address this
Copyright and License
©2022 – Cosmic heat death under the Artistic License, v2.0