forked from deanishe/awgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicons.go
124 lines (117 loc) · 4.27 KB
/
icons.go
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//
// Copyright (c) 2016 Dean Jackson <[email protected]>
//
// MIT Licence. See http://opensource.org/licenses/MIT
//
package aw
import "fmt"
// Valid icon types for Icon. You can use an image file, the icon of a file,
// e.g. an application's icon, or the icon for a filetype (specified by a UTI).
const (
// For image files you wish to show in Alfred.
IconTypeImageFile = ""
// Show the icon of a file, e.g. combine with "/Applications/Safari.app"
// to show Safari's icon in Alfred.
IconTypeFileIcon = "fileicon"
// For UTIs to show the icon for a filetype, e.g. "public.folder",
// which will give you the icon for a folder.
IconTypeFileType = "filetype"
)
// Ready-to-use icons based on built-in OS X system icons.
// These icons are all found in
// /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources.
//
// The icons are the same as found in the Alfred-Workflow library
// for Python. Preview them here:
// http://www.deanishe.net/alfred-workflow/user-manual/icons.html#list-of-icons
var (
IconWorkflow *Icon // icon.png (workflow's own icon)
IconAccount *Icon // Accounts.icns
IconBurn *Icon // BurningIcon.icns
IconClock *Icon // Clock.icns
IconColor *Icon // ProfileBackgroundColor.icns
IconColour *Icon // ProfileBackgroundColor.icns
IconEject *Icon // EjectMediaIcon.icns
IconError *Icon // AlertStopIcon.icns
IconFavorite *Icon // ToolbarFavoritesIcon.icns
IconFavourite *Icon // ToolbarFavoritesIcon.icns
IconGroup *Icon // GroupIcon.icns
IconHelp *Icon // HelpIcon.icns
IconHome *Icon // HomeFolderIcon.icns
IconInfo *Icon // ToolbarInfo.icns
IconNetwork *Icon // GenericNetworkIcon.icns
IconNote *Icon // AlertNoteIcon.icns
IconSettings *Icon // ToolbarAdvanced.icns
IconSwirl *Icon // ErasingIcon.icns
IconSwitch *Icon // General.icns
IconSync *Icon // Sync.icns
IconTrash *Icon // TrashIcon.icns
IconUser *Icon // UserIcon.icns
IconWarning *Icon // AlertCautionIcon.icns
IconWeb *Icon // BookmarkIcon.icns
)
// Icon represents the icon for an Item.
//
// Alfred supports PNG or ICNS files, UTIs (e.g. "public.folder") or
// can use the icon of a specific file (e.g. "/Applications/Safari.app"
// to use Safari's icon.
//
// Type = "" (the default) will treat Value as the path to a PNG or ICNS
// file.
//
// Type = "fileicon" will treat Value as the path to a file or directory
// and use that file's icon, e.g:
//
// icon := Icon{"/Applications/Mail.app", "fileicon"}
//
// will display Mail.app's icon.
//
// Type = "filetype" will treat Value as a UTI, such as "public.movie"
// or "com.microsoft.word.doc". UTIs are useful when you don't have
// a local path to point to.
//
// You can find out the UTI of a filetype by dragging one of the files
// to a File Filter's File Types list in Alfred, or in a shell with:
//
// mdls -name kMDItemContentType -raw /path/to/the/file
//
// This will only work on Spotlight-indexed files.
type Icon struct {
Value string `json:"path"` // Path or UTI
Type string `json:"type,omitempty"` // "fileicon", "filetype" or ""
}
func systemIcon(filename string) *Icon {
icon := &Icon{}
var path string
path = fmt.Sprintf(
"/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/%s.icns", filename)
icon.Value = path
icon.Type = ""
return icon
}
func init() {
IconWorkflow = &Icon{"icon.png", ""}
IconAccount = systemIcon("Accounts")
IconBurn = systemIcon("BurningIcon")
IconClock = systemIcon("Clock")
IconColor = systemIcon("ProfileBackgroundColor")
IconColour = systemIcon("ProfileBackgroundColor")
IconEject = systemIcon("EjectMediaIcon")
IconError = systemIcon("AlertStopIcon")
IconFavorite = systemIcon("ToolbarFavoritesIcon")
IconFavourite = systemIcon("ToolbarFavoritesIcon")
IconGroup = systemIcon("GroupIcon")
IconHelp = systemIcon("HelpIcon")
IconHome = systemIcon("HomeFolderIcon")
IconInfo = systemIcon("ToolbarInfo")
IconNetwork = systemIcon("GenericNetworkIcon")
IconNote = systemIcon("AlertNoteIcon")
IconSettings = systemIcon("ToolbarAdvanced")
IconSwirl = systemIcon("ErasingIcon")
IconSwitch = systemIcon("General")
IconSync = systemIcon("Sync")
IconTrash = systemIcon("TrashIcon")
IconUser = systemIcon("UserIcon")
IconWarning = systemIcon("AlertCautionIcon")
IconWeb = systemIcon("BookmarkIcon")
}