Giter Club home page Giter Club logo

Comments (1)

rrpegasus avatar rrpegasus commented on May 29, 2024 1

Consider the following PowerShell script workaround for Windows.

# PowerShell 5.1 Win10
# @(#)baralga_reminder 211025
#--------------------------------------------------------------------------
function Notify([string]$title,[string]$text,[int]$exp_sec) {
 $notif_tag="PS_script"
 [Windows.UI.Notifications.ToastNotificationManager,Windows.UI.Notifications,ContentType=WindowsRuntime] > $null
 $tt02tpl=[Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText02)
 $toast_xml=[xml]$tt02tpl.GetXml()
 ($toast_xml.toast.visual.binding.text | where {$_.id -eq "1"}).AppendChild($toast_xml.CreateTextNode($title)) > $null
 ($toast_xml.toast.visual.binding.text | where {$_.id -eq "2"}).AppendChild($toast_xml.CreateTextNode($text)) > $null
 $xmldoc=New-Object Windows.Data.Xml.Dom.XmlDocument
 $xmldoc.LoadXml($toast_xml.OuterXml)
 $toast=[Windows.UI.Notifications.ToastNotification]::new($xmldoc)
 $toast.Tag="__"
 $toast.Group="__"
 $toast.ExpirationTime=[DateTimeOffset]::Now.AddSeconds($exp_sec)
 $notifier=[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($notif_tag)
 $notifier.Show($toast);
}
#--------------------------------------------------------------------------
$dur_sec=60
$stw=New-Object System.Diagnostics.Stopwatch

$host.ui.RawUI.WindowTitle="Baralga reminder"
$host.UI.RawUI.WindowSize=New-Object System.Management.Automation.Host.size(76,8)
$host.UI.RawUI.BufferSize=New-Object System.Management.Automation.Host.size(76,8)

$stw.Start()
while($true) {
 $n=[int]($stw.Elapsed.TotalSeconds/$dur_sec*100)
 if($n -ge 100) {
  Notify "Baralga" "What are you doing now?" 5
  $dur_sec=60*(Get-Random -Minimum 10 -Maximum 50)
  $stw.Reset()
  $stw.Restart()
 } else {
  Write-Progress -Activity "Stopwatch.Elapsed" -Status "time $n % elapsed" -PercentComplete $n
  Start-Sleep -Seconds 10
 }
}
# $stw.Reset()
#--------------------------------------------------------------------------

from baralga.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.