<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Ruslan&#39;s Tech Blog</title>
    <link>https://blog.bekenev.net/tags/wsl-windows.html</link>
    <description>Software development related stuff</description>
    <language>en-us</language>
    <lastBuildDate>Mon, 14 Jan 2019 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://blog.bekenev.net/tags/wsl-windows/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Reminders with WSL</title>
      <link>https://blog.bekenev.net/2019/01/14/reminders-with-wsl.html</link>
      <pubDate>Mon, 14 Jan 2019 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2019/01/14/reminders-with-wsl.html</guid>
      <description>&lt;p&gt;Hi everyone,&lt;/p&gt;&#xA;&lt;p&gt;I was looking for an app that should allow me to set a quick reminder&#xA;without any additional functionality.&lt;/p&gt;&#xA;&lt;p&gt;The one was found, it is &lt;code&gt;at&lt;/code&gt; binary which is available by default on most (if not all) Linux&#xA;distributions (checkout &lt;code&gt;man at&lt;/code&gt;).&#xA;Shortly, the &lt;code&gt;at&lt;/code&gt; command allows you to specify a command and time you want to run that command at.&lt;/p&gt;&#xA;&lt;h1 id=&#34;my-current-setup&#34;&gt;My current setup&lt;/h1&gt;&#xA;&lt;p&gt;What I want, is to get a notification at some special time.&#xA;For notifications we can use &lt;code&gt;notify-send&lt;/code&gt;,&#xA;but since I&amp;rsquo;m currently on Windows and use WSL, we will use my &lt;code&gt;wsl-notify&lt;/code&gt; script&#xA;(checkout for &lt;a href=&#34;https://blog.bekenev.net/2019/01/13/wsl-windows-toast.html&#34;&gt;notify-send replacement for WSL&lt;/a&gt; post)&lt;/p&gt;&#xA;&lt;h1 id=&#34;complete-remind-script&#34;&gt;Complete remind script&lt;/h1&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve added a function to my zshrc and called it &lt;code&gt;remind&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Here is its code:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;remind&lt;span style=&#34;color:#f92672&#34;&gt;()&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  echo &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;/path/to/wsl-notify \&amp;#34;&lt;/span&gt;$1&lt;span style=&#34;color:#e6db74&#34;&gt;\&amp;#34;&amp;#34;&lt;/span&gt; | at &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;$2&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The usage is next:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;$ remind &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;call mom&amp;#39;&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;1:00pm&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And at 1:00pm I will get the native windows notification which I can even snooze. Brilliant.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>notify-send replacement for WSL</title>
      <link>https://blog.bekenev.net/2019/01/13/wsl-windows-toast.html</link>
      <pubDate>Sun, 13 Jan 2019 00:00:00 +0000</pubDate>
      <guid>https://blog.bekenev.net/2019/01/13/wsl-windows-toast.html</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;&#xA;&lt;p&gt;Unfortunately there is no way currently to make brilliant &lt;code&gt;notify-send&lt;/code&gt; work on WSL.&lt;/p&gt;&#xA;&lt;h2 id=&#34;solution&#34;&gt;Solution&lt;/h2&gt;&#xA;&lt;p&gt;The workaround is to install &lt;a href=&#34;https://github.com/Windos/BurntToast&#34;&gt;BurntToast&lt;/a&gt; which is&#xA;&lt;code&gt;powershell&lt;/code&gt; module (or command) that allows you to show native notifications.&#xA;After it&amp;rsquo;s installed we can write a script that can execute PowerShell &amp;ldquo;cmdlet&amp;rdquo; from within WSL.&lt;/p&gt;&#xA;&lt;h2 id=&#34;details&#34;&gt;Details&lt;/h2&gt;&#xA;&lt;p&gt;So when &lt;strong&gt;BurntToast&lt;/strong&gt; is installed let&amp;rsquo;s create a super simple bash script (name it like &lt;code&gt;wsl-notify&lt;/code&gt;)&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;#!/usr/bin/env -bash&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#75715e&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;powershell.exe &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;New-BurntToastNotification -Text \&amp;#34;&lt;/span&gt;$1&lt;span style=&#34;color:#e6db74&#34;&gt;\&amp;#34;&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Give our &lt;code&gt;wsl-notify&lt;/code&gt; execution rights (with &lt;code&gt;chmod +x wsl-notify&lt;/code&gt;) and move it to &lt;code&gt;/usr/bin&lt;/code&gt; folder with &lt;code&gt;mv wsl-notify /usr/bin/&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;That&amp;rsquo;s it, now we can call &lt;code&gt;wsl-notify &#39;The Notification Text&#39;&lt;/code&gt; and we will get native notification in Windows.&#xA;Make sure to wrap all the text into single or double quotes to make all the text to be considered as a first argument to our &lt;code&gt;wsl-notify&lt;/code&gt; script.&lt;/p&gt;&#xA;&lt;h2 id=&#34;troubleshooting&#34;&gt;Troubleshooting&lt;/h2&gt;&#xA;&lt;p&gt;When &lt;strong&gt;BurntToast&lt;/strong&gt;  is installed you have to make sure it works, just fire up your PowerShell and type &lt;code&gt;New-BurntToastNotification&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;If you see error saying something about import module, then you have to import the module.&#xA;Just type &lt;code&gt;Import-Module BurntToast&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In case you&amp;rsquo;ve got error during the import process,&#xA;it&amp;rsquo;s probably because third-party scripts execution is not allowed on your system&#xA;which can be fix with this command:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;Set-ExecutionPolicy RemoteSigned -Scope CurrentUser&lt;/code&gt; - (checkout more about it &lt;a href=&#34;https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-6&#34;&gt;here&lt;/a&gt;)&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
