-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduled Scripts Setup.bushel
More file actions
executable file
·86 lines (72 loc) · 2.37 KB
/
Scheduled Scripts Setup.bushel
File metadata and controls
executable file
·86 lines (72 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/local/bin/bushelscript -l bushelscript_en
-- Scheduled Scripts Setup
-- A convenient interface to scheduling scripts to run daily
-- using LaunchAgent plists.
use AppleScript library File
use AppleScript library Text
let script name be "Scheduled Scripts Setup"
let reverse DNS prefix be "com.justcheesy."
to make launch agent plist: label
let path be (value of env var "HOME") & "/Library/LaunchAgents/" & label & ".plist"
let plist be ##
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string></string>
<key>Program</key>
<string></string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>
##
tell File to write to file path data plist
path
end
-- Currently unused
to choose existing launch agent plist
let linefeed be ##
##-- TODO: this is dumb
set value of env var "reverse_dns_prefix" to reverse DNS prefix
#!/bin/bash
/bin/ls "$HOME"/Library/LaunchAgents |
grep "$reverse_dns_prefix"
#!
split that by linefeed
choose from that prompt "Select a label:" title script name
if not that then return that
tell Text to search text that for ".plist" replacing with ""
end
-- MARK: Main script
let options be {"Select existing (to modify an agent)", "Type manually (to create or modify an agent)"}
choose from options prompt "Select a label source:" title script name
if not that then return
if that = item 1 of options
choose existing launch agent plist
else
reverse DNS prefix & (ask "Reverse-DNS label: " & reverse DNS prefix title script name)
end
if (not that ) or (that = reverse DNS prefix) then return
let label be that
let program be ask "Full path to program:" title script name
let start hour be ask "Start hour in 24-hour format:" for integer title script name
let start minute be ask "Start minute of the hour:" for integer title script name
let file path be make launch agent plist label label
tell system
tell property list file file path
define type plist item as property list item
set value of plist item "Label" to label
set value of plist item "Program" to program
tell plist item "StartCalendarInterval"
set value of plist item "Hour" to start hour
set value of plist item "Minute" to start minute
end
end
end