forked from raycast/script-commands
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiconsur.sh
executable file
·68 lines (57 loc) · 1.71 KB
/
iconsur.sh
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
#!/bin/bash
# Dependency: requires iconsur (https://github.com/rikumi/iconsur)
# Install via Homebrew: `brew install iconsur`
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Change Application Icon
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🅱️
# @raycast.argument1 { "type": "text", "placeholder": "Application" }
# @raycast.argument2 { "type": "text", "placeholder": "Root Password", "secure": true, "optional": true }
# @raycast.argument3 { "type": "text", "placeholder": "Use Local Icon (y)" , "optional": true }
# @raycast.packageName iconsur
# Documentation:
# @raycast.description Change App icons to match Big Sur
# @raycast.author StevenRCE0
# @raycast.authorURL https://github.com/StevenRCE0
# Test iconsur
t=$(which iconsur)
if [ -z "$t" ]; then
echo "Iconsur not found, install using brew install iconsur"
exit 1
fi
# Workaround for the error message
exec 2>/dev/null
# Test file
appPath=""
if [ -d "/Applications/$1.app" ]; then
appPath="/Applications/$1.app"
elif [ -d "$HOME/Applications/$1.app" ]; then
appPath="$HOME/Applications/$1.app"
else
echo "Application not found, make sure it's in Applications folder"
exit 2
fi
loc=""; omit=0
if [ -z $3 ] && [ $2 = "y" -o $2 = "Y" ]; then
loc="-l"
omit=1
fi
if [ $omit -eq 0 ] && [ $3 = "y" -o $3 = "Y" ]; then
loc="-l"
fi
if [ $2 ] && [ $omit -eq 0 ]; then
echo $2|sudo -S iconsur set "$appPath" $loc
if [ ${PIPESTATUS[1]} -eq 1 ]; then
echo "Password incorrect"
exit 2
fi
else
iconsur set "$appPath" $loc 1>/dev/null
if [ ${PIPESTATUS[0]} -eq 1 ]; then
echo "It didn't work, try again with password"
exit 2
fi
fi
echo "Icon changed successfully"