<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel Herman</title>
    <description>The latest articles on DEV Community by Daniel Herman (@detrin).</description>
    <link>https://dev.to/detrin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F236082%2F2f99b1a1-b70e-4585-9529-4d2758e6347c.jpeg</url>
      <title>DEV Community: Daniel Herman</title>
      <link>https://dev.to/detrin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/detrin"/>
    <language>en</language>
    <item>
      <title>Run commands with notification after finishing</title>
      <dc:creator>Daniel Herman</dc:creator>
      <pubDate>Sat, 20 Jun 2020 22:33:45 +0000</pubDate>
      <link>https://dev.to/detrin/run-tests-with-notification-after-they-finish-1p7p</link>
      <guid>https://dev.to/detrin/run-tests-with-notification-after-they-finish-1p7p</guid>
      <description>&lt;p&gt;Have you ever wondered how to execute scripts with some notification after they finish on your local or remote machine? As a physics student, I run many simulations on remote servers or lab PCs. These days I contribute to my supervisor’s package &lt;a href="https://github.com/tmancal74/quantarhei"&gt;quantarhei&lt;/a&gt; (also we need developers) and I need to run package tests on a regular basis. Since these tests take approximately 5 min, that is a reasonable time indeed, but our school lab can do a bit better. I don’t want to wait all this time staring at unit test output and I would like to continue in package development! So what do I do?&lt;/p&gt;

&lt;p&gt;I tried to solve this inconvenience. Because I had VPS, I created my own Rest API, with MongoDB database and telegram bot. This way I had smartphone notifications and desktop notification with the telegram web app. This solution, however, created many different problems (which I had fun solving). I was searching for some online tools but didn’t find anything for a reasonable price or for free.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Y0DI6KyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kefe5uk979u8vwknn7g2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y0DI6KyL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kefe5uk979u8vwknn7g2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For my local machine I use sound notification, with these aliases in &lt;code&gt;.zshrc&lt;/code&gt; (or &lt;code&gt;.bashrc&lt;/code&gt; if you don’t use zsh)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;sn1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mpg123 ~/Music/never.mp3 &amp;gt; /dev/null 2&amp;gt;&amp;amp;1"&lt;/span&gt; 
&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;sn2&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"spd-say 'Yo'"&lt;/span&gt;
&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;sn3&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mpg123 ~/Music/doot_doot_mr_skeletal.mp3 &amp;gt; /dev/null 2&amp;gt;&amp;amp;1"&lt;/span&gt; 
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then simply run the following&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sleep &lt;/span&gt;5&lt;span class="p"&gt;;&lt;/span&gt; sn2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What about remote machines? I use Pushbullet together with ntfy &lt;a href="https://github.com/dschep/ntfy"&gt;ntfy&lt;/a&gt; utility! Ntfy also supports Pushover, but they do not support older versions of Android OS. You have to go to the Pushbullet website and get Access Token in the settings. Then create ntfy config file &lt;code&gt;~/.config/ntfy/ntfy.yml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;backends&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pushbullet&lt;/span&gt;
&lt;span class="na"&gt;pushover&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;user_key&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;YOUR_ACCESS_TOKEN&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set your alias in &lt;code&gt;.zsrhc&lt;/code&gt; (or &lt;code&gt;.bashrc&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;msg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ntfy send"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you do not have rights to change files outside your home folder you can also execute ntfy directly with the token&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;msg&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ntfy -b pushbullet -o access_token YOUR_ACCESS_TOKEN send"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Enjoy your notifications!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;msg “ARE YOU READY?”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
      <category>git</category>
      <category>github</category>
    </item>
  </channel>
</rss>
