Skip to content

Commit

Permalink
fix: linux tray icon (#886)
Browse files Browse the repository at this point in the history
Ref #793
  • Loading branch information
Feichtmeier authored Aug 22, 2024
1 parent 857bdef commit 2eb0090
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/app/view/system_tray.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import 'package:flutter/material.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

import '../../constants.dart';
import '../../l10n/l10n.dart';

const _exitAppMenuKey = 'exit_app';
const _showHideWindowMenuKey = 'show_hide_window';

Future<void> initTray() async {
await trayManager.setIcon(
(Platform.isWindows)
? 'assets/images/tray_icon.ico'
: 'assets/images/tray_icon.png',
);
await trayManager.setIcon(_icon());
Menu menu = Menu(
items: [
MenuItem(
Expand All @@ -31,6 +28,16 @@ Future<void> initTray() async {
await trayManager.setContextMenu(menu);
}

String _icon() {
if (Platform.isLinux) {
return kAppId;
} else if (Platform.isWindows) {
return 'assets/images/tray_icon.ico';
} else {
return 'assets/images/tray_icon.png';
}
}

Future<void> updateTrayItems(BuildContext context) async {
bool isVisible = await windowManager.isVisible();
if (!context.mounted) return;
Expand Down
2 changes: 2 additions & 0 deletions lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:yaru/constants.dart';

const kAppName = 'musicpod';

const kAppId = 'org.feichtmeier.Musicpod';

const kLinuxDBusName = 'org.mpris.MediaPlayer2.musicpod';

const kAndroidChannelId = 'org.feichtmeier.musicpod.channel.audio';
Expand Down

0 comments on commit 2eb0090

Please sign in to comment.