You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-3Lines changed: 54 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@
22
22
-**Single Instance Management**: Ensures that only one instance of the application can run at a time and allows restoring focus to the running instance when another instance is attempted.
23
23
-**Tray Position Detection**: Allows determining the position of the system tray, which helps in positioning related windows appropriately.
24
24
-**Compose Recomposition Support**: The tray supports Compose recomposition, making it possible to dynamically show or hide the tray icon, for example:
25
-
25
+
26
26
<palign="center">
27
27
<imgsrc="screenshots/demo.gif"alt="demo">
28
28
</p>
@@ -63,7 +63,7 @@ application {
63
63
Icon(
64
64
Icons.Default.Favorite,
65
65
contentDescription ="",
66
-
tint =Color.White,
66
+
tint =Color.Unspecified, // If not defined icon will be tinted with LocalContentColor.current
67
67
modifier =Modifier.fillMaxSize() // This is crucial!
68
68
)
69
69
},
@@ -131,6 +131,41 @@ application {
131
131
-**dispose**: Call to remove the system tray icon and exit gracefully.
132
132
-**Primary Action**: An action triggered by a left-click on the tray icon (Windows and macOS) or as a top item in the context menu (Linux).
133
133
134
+
### 🎨 Icon Rendering Customization
135
+
136
+
The `IconRenderProperties` class allows you to customize how your tray icon is rendered. This is an optional parameter when using the Tray component, with a default value already provided:
1.**forCurrentOperatingSystem()**: Creates properties optimized for the current operating system:
145
+
- Windows: 32x32 pixels
146
+
- macOS: 44x44 pixels
147
+
- Linux: 24x24 pixels
148
+
149
+
```kotlin
150
+
IconRenderProperties.forCurrentOperatingSystem(
151
+
sceneWidth =192, // Optional: Width of the compose scene (default: 192)
152
+
sceneHeight =192, // Optional: Height of the compose scene (default: 192)
153
+
density =Density(2f) // Optional: Density for the compose scene (default: 2f)
154
+
)
155
+
```
156
+
157
+
2.**withoutScalingAndAliasing()**: Creates properties that don't force icon scaling and aliasing:
158
+
159
+
```kotlin
160
+
IconRenderProperties.withoutScalingAndAliasing(
161
+
sceneWidth =192, // Optional: Width of the compose scene (default: 192)
162
+
sceneHeight =192, // Optional: Height of the compose scene (default: 192)
163
+
density =Density(2f) // Optional: Density for the compose scene (default: 2f)
164
+
)
165
+
```
166
+
167
+
This allows you to fine-tune how your icon appears in the system tray across different platforms.
168
+
134
169
### 🔄 Single Instance Management
135
170
136
171
The `SingleInstanceManager` ensures that only one instance of the application is running at a time. When a second instance tries to start, it sends a restore request to the existing instance to bring it to the foreground.
@@ -153,6 +188,22 @@ if (!isSingleInstance) {
153
188
154
189
In this example, the `SingleInstanceManager` will check if an instance is already running. If not, it will acquire the lock and start watching for restore requests. If an instance is already running, it will send a restore request to bring the existing window to the foreground, allowing you to focus on the already-running application rather than starting a new instance.
This is useful when you need single-instance management but want finer-grained control.
201
+
202
+
By specifying a custom `lockFilesDir`, you limit the scope of single-instance management
203
+
from every instance of your app on the whole system to only those that share the specified data directory.
204
+
205
+
Setting the custom `appIdentifier` can be used for even more granular control.
206
+
156
207
### 📌 Tray Position Detection
157
208
158
209
The `getTrayPosition()` function allows you to determine the current position of the system tray on the screen. This information can be useful for aligning application windows relative to the tray icon.
@@ -213,4 +264,4 @@ Feel free to open issues or pull requests if you find any bugs or have suggestio
213
264
214
265
## 🙏 Acknowledgements
215
266
216
-
This library is developed and maintained by Elie G, aiming to provide an easy and cross-platform system tray solution for Kotlin applications.
267
+
This library is developed and maintained by Elie G, aiming to provide an easy and cross-platform system tray solution for Kotlin applications.
0 commit comments