Use Notification To Show Playing Music Title Of mps-youtube On Mac OS XFri, 2 Jun 2017 16:47:00 +0800         Sentoz Lin
"mps-youtube", which is, according to the official description:
"a Terminal based YouTube player and downloader!"
That means you can play your favourite Youtube music without leaving the terminal! Unlike using other music streaming provider like Spotify、Apple Music、 KKBox, that need to switch back and forth between your different applications , and consume precious resource because their beautiful GUI; otherwise, you can just stick with terminal, which I think will drastically improve your productivity if you are a developer whose developement environment based on terminal like me!
(The above image shows mps-youtube running inside iTerm2 Hotkey mode("option + t" to toggle iTerm2 window, when iTerm2 hide, your music are just like playing in the background!))
But there is a problem, if I want to know what song is now playing,I need to press "option + t" to open Hotkey iTerm2 window to see it.That means Ihave to interrupt what I am doing right now, distract you from important work. What if when songs change, it can automatically display a notification to tell me which song is now playing; luckily, ops-youtube prodvide a config option to let you send music title info to notifier which will stimulate system's Notification.But which notifier to use? I guess you ask,well, we will use a tool called "terminal-notifier", which let you
"Send User Notifications on macOS from the command-line".
Ok, enough background talking, let's go straight toward to the solutions.
Step 1: Install terminal-notifier
I assume that you are already familiar with Homebrew(a package manager for Mac OS X), if you don't, go checkout Homebrew to get more info.Next issue the following command in your terminal
>> brew install terminal-notifier
Step 2: Set mys-youtube's notifier
>> set notifier terminal-notifier -sound Frog -title "🎵" -group Mpsyt -sender mpsyt -message
- -sound: sound effect when notification show, here I use the built-in Frog sound on mac
- -title: the title of notification, here I use the emoji symbol, you can use whatever character that is valid
- -group: make all the message sent from mys-youtube to as a group called Mpsyt
- -sender: tell Notification center where the message come from
- -messge: the message you want to see in notification, here is the music title which will set by mys-youtube
We are done! Congratulations!
Let's see it in action!