Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Tray icon not working on Flatpak for Linux #232

Merged
merged 2 commits into from
Jan 8, 2025

Conversation

Fei1Yang
Copy link
Contributor

@Fei1Yang Fei1Yang commented Jan 8, 2025

This pull request will:

  • Use correct icon brightness
  • When in Flatpak, use installed tray icon to workaround filesystem difference between the sandboxed envirnoment and host.

Summary by Sourcery

Use the correct tray icon brightness on Linux. When running in a Flatpak environment, use the installed tray icon to resolve filesystem discrepancies between the sandboxed environment and the host.

New Features:

  • Add support for Flatpak environments by using the installed tray icon.

Enhancements:

  • Improve the tray icon selection logic to use different icons based on the system brightness.

Copy link

sourcery-ai bot commented Jan 8, 2025

Reviewer's Guide by Sourcery

This pull request improves the tray icon on Linux by using the correct icon brightness and using the installed tray icon when in a Flatpak environment to workaround filesystem differences between the sandboxed environment and the host.

Sequence diagram for tray icon path resolution

sequenceDiagram
    participant App
    participant TrayManager
    participant Platform
    participant SchedulerBinding

    App->>TrayManager: getTrayIconPath()
    TrayManager->>Platform: isMacOS
    alt is MacOS
        Platform-->>TrayManager: true
        TrayManager-->>App: assets/mac-tray.svg
    else not MacOS
        Platform-->>TrayManager: false
        TrayManager->>SchedulerBinding: get platformBrightness
        SchedulerBinding-->>TrayManager: current brightness
        TrayManager->>Platform: isWindows
        alt is Windows
            Platform-->>TrayManager: true
            TrayManager-->>App: assets/tray_icon_{brightness}.ico
        else not Windows
            Platform-->>TrayManager: false
            TrayManager->>Platform: isLinux && FLATPAK_ID
            alt is Linux Flatpak
                Platform-->>TrayManager: true
                TrayManager-->>App: ci.not.Rune-tray-{brightness}
            else regular Linux
                Platform-->>TrayManager: false
                TrayManager-->>App: assets/linux-tray-{brightness}.svg
            end
        end
    end
Loading

State diagram for tray icon path selection

stateDiagram-v2
    [*] --> CheckPlatform
    CheckPlatform --> MacOS: Platform.isMacOS
    CheckPlatform --> GetBrightness: !Platform.isMacOS

    MacOS --> [*]: Return mac-tray.svg

    GetBrightness --> Windows: Platform.isWindows
    GetBrightness --> Linux: !Platform.isWindows

    Windows --> [*]: Return tray_icon_{brightness}.ico

    Linux --> FlatpakCheck
    FlatpakCheck --> LinuxFlatpak: FLATPAK_ID exists
    FlatpakCheck --> RegularLinux: FLATPAK_ID not exists

    LinuxFlatpak --> [*]: Return ci.not.Rune-tray-{brightness}
    RegularLinux --> [*]: Return linux-tray-{brightness}.svg
Loading

File-Level Changes

Change Details Files
Use correct icon brightness on Linux
  • Added logic to select a dark or light tray icon based on the system brightness.
  • Added dark and light tray icons to assets.
  • Updated pubspec.yaml to include the new assets.
lib/utils/tray_manager.dart
pubspec.yaml
assets/linux-tray-dark.svg
assets/linux-tray-light.svg
Use installed tray icon when in Flatpak on Linux
  • Added logic to use the installed tray icon when the application is running in a Flatpak environment on Linux.
lib/utils/tray_manager.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@dosubot dosubot bot added C - UI UI related issue P - Linux Linux system related issue labels Jan 8, 2025
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Fei1Yang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Losses Losses changed the title Improve tray icon on Linux fix: Tray icon not working on Flatpak for Linux Jan 8, 2025
@Losses Losses merged commit 1db3301 into Losses:master Jan 8, 2025
2 checks passed
@Fei1Yang Fei1Yang deleted the linux-tray-icon branch January 8, 2025 04:07
Losses pushed a commit that referenced this pull request Jan 10, 2025
* fix: Use correct brightness for Linux tray icon

* fix: Use installed tray icon when in Flatpak
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - UI UI related issue P - Linux Linux system related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants