-
Notifications
You must be signed in to change notification settings - Fork 4
/
loginitems
executable file
·54 lines (51 loc) · 1.38 KB
/
loginitems
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
#!/bin/sh
usage(){
echo "Usage: loginitems [-h | -a NAME [-p PATH] [-s HIDE?] | -d NAME | -l]"
echo " -h Show this help message."
echo " -a Add an application, optionally hide with -s false."
echo " -p Path to application; defaults to /Applications/NAME.app."
echo " -s Show/hide application; defaults to true (no hide)."
echo " -d Delete an application from login items."
echo " -l List all login items (default if no option specified)."
}
hide="false"
falsehood="false no 0"
opts="h:a:p:s:d:l"
action="list"
while getopts "$opts" opt; do
case "$opt" in
a)
action="add"
name="${OPTARG}"
if [ ! $path ]; then
path="/Applications/$name.app"
fi
;;
p)
path="${OPTARG}"
;;
s)
if [[ $falsehood =~ (^| )${OPTARG}($| ) ]]
then # false show, so do hide
hide="true"
fi
;;
d)
action="delete"
name="${OPTARG}"
;;
l)
action="list"
;;
*)
usage
;;
esac
done
if [ "$action" = "add" ]; then
loginitems-add "$name" "$path" "$hide" >> /dev/null
elif [ "$action" = "delete" ]; then
loginitems-rm "$name" >> /dev/null
elif [ "$action" = "list" ]; then
loginitems-ls
fi