epwalsh / pomo.nvim

:new: :stopwatch: A simple, customizable pomodoro timer for Neovim, written in Lua, with nvim-notify, lualine, and telescope integrations
Apache License 2.0
154 stars 7 forks source link

Add Windows support to system notifier #25

Closed jmartinn closed 2 months ago

jmartinn commented 2 months ago

This pull request introduces Windows notification support for the System Notifier, extending functionality in addition to the existing support for macOS and Linux. This enhancement addresses the existing issue of platform-specific notifications and aims to provide a seamless user experience across all major operating systems.

Changes Proposed:

Rationale:

The current implementation of the notification system only supports macOS, using AppleScript, and Linux. This pull request aims to provide an inclusive solution that accommodates users on Windows An alternative approach was considered (using the BurntToast PowerShell module for Windows; see #15), but it was not quite accurate in my opinion due to its dependency requirements which could complicate the setup process for users. My proposed solution uses native system capabilities to ensure broader compatibility and ease of use.

Implementation Details:

-- Windows Notification
elseif util.get_os() == util.OS.Windows then
    os.execute(string.format([[
        PowerShell -Command "Add-Type -AssemblyName System.Windows.Forms;
        $notify = New-Object System.Windows.Forms.NotifyIcon;
        $notify.Icon = [System.Drawing.SystemIcons]::Information;
        $notify.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Info;
        $notify.BalloonTipText = 'Timer #%d, %s%s';
        $notify.BalloonTipTitle = 'Timer done!';
        $notify.Visible = $true;
        $notify.ShowBalloonTip(10000);" ]],
        self.timer.id,
        util.format_time(self.timer.time_limit),
        repetitions_str
    ))

Conclusion:

This update ensures that all users, regardless of their operating system, can benefit from the same level of functionality when using the Pomodoro timer plugin. By leveraging native system features, we maximize compatibility and maintain ease of use without additional dependencies.

jmartinn commented 2 months ago

Note: This would completely close / solve #3

jmartinn commented 2 months ago

@epwalsh sure! Sorry for the late reply btw. I've changed the line you've mentioned and deleted the line 122 which contained the url to track the issue.