Skip to content

Commit 7e96a00

Browse files
committed
Add documentation (README, CONTRIBUTING)
1 parent 421a00f commit 7e96a00

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# eject-all-ejectable Contributing Guidelines
2+
3+
This script was thrown together in an afternoon, but I welcome any PR you want to throw my way.
4+
5+
## Recommended tools
6+
7+
* [Script Debugger](https://latenightsw.com/). It offers a free trial, and a limited free mode, which is drastically better than macOS' built-in Script Editor

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,99 @@
11
# eject-all-ejectable
2+
23
A quick-and-hacky AppleScript to eject every disk that can be ejected.
4+
5+
Written to make disconnecting a laptop easier. The idea: hit a keyboard shortcut, wait a couple of seconds, and safely unplug when told.
6+
7+
This script will read every disk that Finder reports as "ejectable", and attempts to eject them. It offers configuration options to disable ejection for specific disks, and makes its actions clear in a simple dialog after it runs.
8+
9+
It works well as a system-level service with a keyboard shortcut.
10+
11+
## Usage
12+
13+
### Simple usage
14+
15+
You can test it by opening `eject-all-ejectables.applescript` in Script Editor or [Script Debugger](https://latenightsw.com/) and hitting the ▶️ button.
16+
17+
### Configurable settings
18+
19+
At the top of the file are a number of configurable settings. You can change them as desired.
20+
21+
#### Safe message
22+
23+
**Name**: `safeMessage`
24+
25+
**Purpose**: Specifies the title to show on the alert dialog when all ejectable disks were ejected.
26+
27+
**Default**: `"Safe to disconnect"`
28+
29+
#### Fail message
30+
31+
**Name**: `failMessage`
32+
33+
**Purpose**: Specifies the title to show on the alert dialog when one or more disks failed to eject.
34+
35+
**Default**: `"Some disks did not eject"`
36+
37+
#### Show skipped
38+
39+
**Name**: `showSkipped`
40+
41+
**Purpose**: Show a line in the alert dialog listing disks which were intentionally not ejected.
42+
43+
**Default**: `false`
44+
45+
#### Drives to skip
46+
47+
**Name**: `drivesToSkip`
48+
49+
**Purpose**: A list of disk names which should not be ejected, even if Finder reports that they're ejectable. This may be useful for network drives, SuperDrives, SD cards, or some internal drives.
50+
51+
**Default**: `{}`
52+
53+
**Examples**:
54+
55+
```
56+
set drivesToSkip to {"External file storage"}
57+
set drivesToSkip to {"Some network location", "SDCARD"}
58+
```
59+
60+
### Adding as a service
61+
62+
This script is most useful as a system-level service, which you can use by invoking a global keyboard shortcut (like `⌃⌘⌥E`) to quickly untether from your desk.
63+
64+
Unfortunately, this is a bit complicated to set up.
65+
66+
#### Add as a service using Automator
67+
68+
1. Open Automator and create a new document
69+
2. Select `Service` as your document type
70+
3. At the top of the editor area, ensure that the following dropdowns are set:
71+
* `Service receives selected` to `no input`
72+
* `in` to `any application`
73+
4. On the left-hand side, search for "Run AppleScript". Drag the result into the editor area.
74+
5. Set the text area that appears to read (replacing the comment by copying-and-pasting):
75+
```
76+
on run
77+
-- Replace this comment with the content of eject-all-ejectable.applescript. Remove any `use` lines at the start.
78+
end run
79+
```
80+
6. Save the service. I recommend the name "Eject all disks"
81+
82+
#### Adding a global keyboard shortcut
83+
1. Open System Preferences
84+
2. Go to `Security & Privacy`
85+
3. Under `Privacy`, select `Accessibility`.
86+
4. Click the padlock to unlock, if it's locked.
87+
5. Hit +. Add `Automator` from your `/Applications` directory
88+
6. Hit + again. Hit `⇧⌘G`, and browse to `/System/Library/CoreServices`. Select `Finder`
89+
7. Go back to the home of System Preferences. Select `Keyboard`.
90+
8. Select `Shortcuts`
91+
9. On the left, select `Services`
92+
10. Hunt-and-peck for the "Eject all disks" item on the right. It will probably be under General.
93+
11. Ensure that the checkbox is checked.
94+
12. Select a keyboard shortcut by double clicking the area to the right of the title, and pressing the keyboard combination you want to use. I recommend `⌃⌘⌥E`.
95+
13. Log out and log in again.
96+
14. Pray to the Apple gods that they have blessed you on this day, and will allow you to proceed without frustration
97+
15. Press `⌃⌘⌥E` (or whichever keyboard combination) you selected. Your disks should eject, and an alert should appear.
98+
99+
Obviously, this is not ideal.

0 commit comments

Comments
 (0)