Skip to content

Commit

Permalink
fix: Tray icon not working on Flatpak for Linux (#232)
Browse files Browse the repository at this point in the history
* fix: Use correct brightness for Linux tray icon

* fix: Use installed tray icon when in Flatpak
  • Loading branch information
Fei1Yang authored Jan 8, 2025
1 parent e076b88 commit 1db3301
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
1 change: 1 addition & 0 deletions assets/linux-tray-dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
21 changes: 14 additions & 7 deletions lib/utils/tray_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ final SystemTray systemTray = SystemTray();

class TrayManager {
static String getTrayIconPath() {
if (Platform.isMacOS) {
return 'assets/mac-tray.svg';
}

final brightness =
SchedulerBinding.instance.platformDispatcher.platformBrightness ==
Brightness.light
? Brightness.dark.name
: Brightness.light.name;

if (Platform.isWindows) {
return SchedulerBinding.instance.platformDispatcher.platformBrightness ==
Brightness.light
? 'assets/tray_icon_dark.ico'
: 'assets/tray_icon_light.ico';
return 'assets/tray_icon_$brightness.ico';
}

if (Platform.isMacOS) {
return 'assets/mac-tray.svg';
if (Platform.isLinux && bool.hasEnvironment('FLATPAK_ID')) {
return 'ci.not.Rune-tray-$brightness';
}

return 'assets/linux-tray.svg';
return 'assets/linux-tray-$brightness.svg';
}

bool? _cachedPlaying;
Expand Down
3 changes: 2 additions & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ flutter:
- assets/branding-text.svg
- assets/startup_0.ogg
- assets/startup_1.ogg
- assets/linux-tray.svg
- assets/linux-tray-dark.svg
- assets/linux-tray-light.svg
- assets/mac-tray.svg
- assets/tray_icon_light.ico
- assets/tray_icon_dark.ico
Expand Down

0 comments on commit 1db3301

Please sign in to comment.