Various ‘macOS’-oriented Tools and Utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2.4 KiB

---
output: rmarkdown::github_document
---

# mactheknife

Various 'macOS'-oriented Tools and Utilities

## Description

A set of tools/methods and data that are geared towards the 'macOS' ecosystem.

## NOTE

- Uses `reticulate` so a working Python *3* implementation is needed. Consider setting `RETICULATE_PYTHON` to a valid, working Python 3 installation if this package is not working for you.

## What's Inside The Tin

The following functions are implemented:

- `airport_scan`: Scan for available wireless network (requires Wi-Fi enabled Mac)
- `applescript`: Execute AppleScript and Return Results
- `resolve_alias`: Resovle macOS binary alias files to their POSIX path strings
- `kernel_state`: Retrieve kernel state information
- `find_dsstore`: Find and optionally remove '.DS_Store' files on a locally-accessible filesystem
- `read_dsstore`: Read a '.DS_Store' from a file/URL
- `software_update_history`: Retrieve Software Update history
- `sw_vers`: Retrieve macOS Operating System Version Information

## Installation

```{r eval=FALSE}
devtools::install_git("git://gitlab.com/hrbrmstr/mactheknife")
devtools::install_git("git://github.com/hrbrmstr/mactheknife")
```

```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```

## Usage

```{r message=FALSE, warning=FALSE, error=FALSE}
library(mactheknife)

# current verison
packageVersion("mactheknife")

```

### Kernel state vars

```{r}
kernel_state()
```

### `.DS_Store` example

Using built-in data

```{r}
read_dsstore(
path = system.file("extdat", "DS_Store.ctf", package = "mactheknife")
)
```

### From a URL

A URL I should not have let a `.DS_Store` file lying around in

```{r}
read_dsstore("https://rud.is/books/21-recipes/.DS_Store")
```

### A Directory of`.DS_Store`s

A larger example using my "~/projects" folder (use your own dir as an example).

```{r}
library(magrittr)

list.files(
path = "~/projects", pattern = "\\.DS_Store",
all.files=TRUE, recursive = TRUE, full.names = TRUE
) %>%
lapply(read_dsstore) -> x

str(x)
```

### "Software Update" History

```{r}
software_update_history()
```

### macOS Version Info (short)

```{r}
sw_vers()
```

### Airport scan

```{r airport, cache=TRUE}
airport_scan()
```

```{r applescript}
res <- applescript('
tell application "iTunes"
set r_name to name of current track
set r_artist to artist of current track
end
return "artist=" & r_artist & "\ntrack=" & r_name
')

print(res)
```