From 4eac510be912d63cfd033bff2eaaf11a9525cb5b Mon Sep 17 00:00:00 2001 From: jmartinn Date: Thu, 16 May 2024 10:20:23 +0200 Subject: [PATCH 1/4] Add Windows support to system notifier feat. small refactor --- CHANGELOG.md | 5 ++++- lua/pomo/notifiers/system.lua | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 050b3c8..4dc5070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased +### Added +Added Windows support for System notifications. + ## [v0.6.0](https://github.com/epwalsh/pomo.nvim/releases/tag/v0.6.0) - 2024-04-02 ### Added @@ -14,7 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [v0.5.0](https://github.com/epwalsh/pomo.nvim/releases/tag/v0.5.0) - 2024-03-27 -## Added +### Added - Added Linux support for System notifications. diff --git a/lua/pomo/notifiers/system.lua b/lua/pomo/notifiers/system.lua index 58c1ce5..3405209 100644 --- a/lua/pomo/notifiers/system.lua +++ b/lua/pomo/notifiers/system.lua @@ -38,6 +38,7 @@ SystemNotifier.done = function(self) ---@diagnostic disable-line: unused-local repetitions_str = string.format(" [%d/%d]", self.timer.repetitions + 1, self.timer.max_repetitions) end + -- macOS Notification if util.get_os() == util.OS.Darwin then os.execute( string.format( @@ -48,6 +49,7 @@ SystemNotifier.done = function(self) ---@diagnostic disable-line: unused-local repetitions_str ) ) + -- Linux Notification elseif util.get_os() == util.OS.Linux then os.execute( string.format( @@ -58,6 +60,24 @@ SystemNotifier.done = function(self) ---@diagnostic disable-line: unused-local repetitions_str ) ) + -- 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 + ) + ) else return log.error("SystemNotifier is not implemented for your OS (%s)", util.get_os()) end From 5a0b8e84a09ba9df5c4fae1fd365d7234aef5024 Mon Sep 17 00:00:00 2001 From: jmartinn Date: Fri, 17 May 2024 13:20:28 +0200 Subject: [PATCH 2/4] updated readme to clarify the OSs supported by the notifier --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b98cb6d..8726b47 100644 --- a/README.md +++ b/README.md @@ -118,8 +118,7 @@ This is a complete list of all of the options that can be passed to `require("po }, -- The "System" notifier sends a system notification when the timer is finished. - -- Available on MacOS natively and Linux via the `libnotify-bin` package. - -- Tracking: https://github.com/epwalsh/pomo.nvim/issues/3 + -- Available on MacOS and Windows natively and on Linux via the `libnotify-bin` package. { name = "System" }, -- You can also define custom notifiers by providing an "init" function instead of a name. From 7cf4db2d461272db4b60b7b17f61f4beb67a9b39 Mon Sep 17 00:00:00 2001 From: jmartinn Date: Fri, 17 May 2024 13:27:57 +0200 Subject: [PATCH 3/4] updated docs in addition to the readme regarding notifier --- doc/pomo.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/pomo.txt b/doc/pomo.txt index e8a10e3..6cfd12c 100644 --- a/doc/pomo.txt +++ b/doc/pomo.txt @@ -138,8 +138,7 @@ read each option carefully and customize it to your needs: }, -- The "System" notifier sends a system notification when the timer is finished. - -- Available on MacOS natively and Linux via the `libnotify-bin` package. - -- Tracking: https://github.com/epwalsh/pomo.nvim/issues/3 + -- Available on MacOS and Windows natively and on Linux via the `libnotify-bin` package. { name = "System" }, -- You can also define custom notifiers by providing an "init" function instead of a name. From dfe3350e41de0a784eb8cc7e4f7ab2d4e727e72b Mon Sep 17 00:00:00 2001 From: epwalsh Date: Fri, 17 May 2024 09:46:40 -0700 Subject: [PATCH 4/4] clean up CHANGELOG --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dc5070..8bced8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## Unreleased ### Added -Added Windows support for System notifications. + +- Added Windows support for System notifications. ## [v0.6.0](https://github.com/epwalsh/pomo.nvim/releases/tag/v0.6.0) - 2024-04-02