github.com/shurcool/trayhost@v0.0.0-20181020202213-114974ef9e16/doc.go (about)

     1  // Package trayhost is a cross-platform Go library to place an icon
     2  // in the host operating system's taskbar.
     3  //
     4  // Platform Support
     5  //
     6  // -	macOS - Fully implemented and supported by @dmitshur.
     7  //
     8  // -	Linux - Partially implemented, but unsupported (needs an owner/maintainer).
     9  //
    10  // -	Windows - Partially implemented, but unsupported (needs an owner/maintainer).
    11  //
    12  // Notes
    13  //
    14  // On macOS, for Notification Center user notifications to work, your Go binary that
    15  // uses trayhost must be a part of a standard macOS app bundle.
    16  //
    17  // Most other functionality of trayhost will be available if the binary is not a part
    18  // of app bundle, but you will get a terminal pop up, and you will not be able to
    19  // configure some aspects of the app.
    20  //
    21  // Here's a minimal layout of an app bundle:
    22  //
    23  // 	$ tree "Trayhost Example.app"
    24  // 	Trayhost\ Example.app
    25  // 	└── Contents
    26  // 	    ├── Info.plist
    27  // 	    ├── MacOS
    28  // 	    │   └── example
    29  // 	    └── Resources
    30  // 	        └── Icon.icns
    31  //
    32  // Here's a minimal Info.plist file as reference (only the entries that are needed,
    33  // nothing extra):
    34  //
    35  // 	<?xml version="1.0" encoding="UTF-8"?>
    36  // 	<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    37  // 	<plist version="1.0">
    38  // 	<dict>
    39  // 		<key>CFBundleExecutable</key>
    40  // 		<string>example</string>
    41  // 		<key>CFBundleIconFile</key>
    42  // 		<string>Icon</string>
    43  // 		<key>CFBundleIdentifier</key>
    44  // 		<string>ExampleApp</string>
    45  // 		<key>NSHighResolutionCapable</key>
    46  // 		<true/>
    47  // 		<key>LSUIElement</key>
    48  // 		<string>1</string>
    49  // 	</dict>
    50  // 	</plist>
    51  //
    52  // -	CFBundleIdentifier needs to be set to some value for Notification Center to work.
    53  //
    54  // -	The binary must be inside Contents/MacOS directory for Notification Center to work.
    55  //
    56  // -	NSHighResolutionCapable to enable Retina mode.
    57  //
    58  // -	LSUIElement is needed to make the app not appear in Cmd+Tab list and the dock
    59  // while still being able to show a tooltip in the menu bar.
    60  //
    61  // On macOS, when you run an app bundle, the working directory of the executed process
    62  // is the root directory (/), not the app bundle's Contents/Resources directory.
    63  // Change directory to Resources if you need to load resources from there.
    64  //
    65  // 	ep, err := os.Executable()
    66  // 	if err != nil {
    67  // 		log.Fatalln("os.Executable:", err)
    68  // 	}
    69  // 	err = os.Chdir(filepath.Join(filepath.Dir(ep), "..", "Resources"))
    70  // 	if err != nil {
    71  // 		log.Fatalln("os.Chdir:", err)
    72  // 	}
    73  //
    74  package trayhost