Skip to content

Commit 8e13f66

Browse files
committed
- file notification is used for custom commands only
- updating docs
1 parent d84c0d0 commit 8e13f66

File tree

4 files changed

+221
-177
lines changed

4 files changed

+221
-177
lines changed

desktop-notification.html

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ <h1 style="color: SaddleBrown" id="pyradio-desktop-notification">PyRadio Desktop
4444
<h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
4545
<!-- vim-markdown-toc Marked -->
4646
<ul>
47-
<li><a href="#introduction">Introduction</a></li>
48-
<li><a href="#on-linux">On Linux</a>
47+
<li><a href="#introduction">Introduction</a>
4948
<ul>
50-
<li><a href="#packagers-info">Packagers info</a></li>
49+
<li><a href="#configuration">Configuration</a></li>
5150
</ul></li>
51+
<li><a href="#on-linux">On Linux</a></li>
5252
<li><a href="#on-macos">On MacOS</a></li>
5353
<li><a href="#on-windows">On Windows</a>
5454
<ul>
@@ -59,77 +59,76 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
5959
<!-- vim-markdown-toc -->
6060
<p><a href="README.html">[Return to main doc]</a></p>
6161
<h2 id="introduction">Introduction <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
62-
<p><strong>PyRadio</strong> can provide Desktop Notifications when a notification daemon is already present (on Linux and BSD), or throught <strong>Windows Notification Service</strong> (<strong>WNS</strong>).</p>
62+
<p><strong>PyRadio</strong> can provide Desktop Notifications when a notification daemon is already present (on Linux and BSD), or through <strong>Windows Notification Service</strong> (<strong>WNS</strong>).</p>
63+
<p>The behavior and presentation of notifications greatly depends on the daemon/service and command line utility used to trigger a notification.</p>
6364
<p>If enabled, <strong>PyRadio</strong> will display:</p>
6465
<ol type="1">
65-
<li>Song info (as provided by the radio station)<br />
66-
That means that if the radio station does not provide any info, no notification will be issued.</li>
66+
<li>The playlist name, when playback starts.</li>
67+
<li>Song info (as provided by the radio station).</li>
6768
<li>Connection failure messages.</li>
6869
<li>Player crash messages.</li>
6970
</ol>
70-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> If Desktop Notification is enabled by default (in the case of a distro package) users can disable it by creating an empty <strong>~/.config/pyradio/notification</strong> file (Linux only).</p>
71+
<p>Desktop Notifications are disabled by default.</p>
72+
<h3 id="configuration">Configuration</h3>
73+
<p>Desktop Notifications are disabled by default. To enable them, go to <strong>PyRadio</strong> config window and customize the “<em>Enable notifications</em>” option.</p>
74+
<p>Available values are:</p>
75+
<pre> -1: disabled (deault)
76+
0: enabled (no repetition)
77+
x: enabled and repeat every x seconds</pre>
78+
<p><strong>PyRadio</strong> supports notifications repetition, so that even when used with quake or yakuake and the like, you still have some info on what’s going on with it.</p>
79+
<p>Notifications can be set to repeat every “<em>x</em>” seconds, with “<em>x</em>” ranging from 30 to 300 (30 seconds to 5 minutes), in 30 seconds steps.</p>
7180
<h2 id="on-linux">On Linux <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
7281
<p><a href="https://members.hellug.gr/sng/pyradio/pyradio-notif.jpg" target="_blank"><img style="width: 411px" src="https://members.hellug.gr/sng/pyradio/pyradio-notif.jpg" alt="Linux notification" /></a></p>
7382

74-
<p>On Linux (and the BSDs), <strong>PyRadio</strong> uses the <em>notification daemon</em> that’s already present, using whatever command it provides to send notifications to the daemon.</p>
75-
<p>On my linux box, this is done using the <strong>notify-send</strong> command (as it would be with most distros).</p>
76-
<p>This is its help screen.</p>
77-
<pre># notify-send --help
78-
79-
Usage:
80-
notify-send [OPTION…] &lt;SUMMARY&gt; [BODY] - create a notification
81-
82-
Help Options:
83-
-?, --help Show help options
84-
85-
Application Options:
86-
-u, --urgency=LEVEL Specifies the urgency level (low, normal, critical).
87-
-t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification.
88-
-a, --app-name=APP_NAME Specifies the app name for the icon
89-
-i, --icon=ICON Specifies an icon filename or stock icon to display.
90-
-c, --category=TYPE[,TYPE...] Specifies the notification category.
91-
-e, --transient Create a transient notification
92-
-h, --hint=TYPE:NAME:VALUE Specifies basic extra data to pass. Valid types are boolean, int, double, string, byte and variant.
93-
-p, --print-id Print the notification ID.
94-
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
95-
-w, --wait Wait for the notification to be closed before exiting.
96-
-A, --action=[NAME=]Text... Specifies the actions to display to the user. Implies --wait to wait for user input. May be set multiple times. The name of the action is output to stdout. If NAME is not specified, the numerical index of the option is used (starting with 0).
97-
-v, --version Version of the package.</pre>
98-
<p>In order to make <strong>PyRadio</strong> use it, we wil use this help screen to create a valid command, for example:</p>
99-
<pre>notify-send -i ~/.config/pyradio/pyradio.png -t 6000 TITLE MSG</pre>
83+
<p>On Linux (and the BSDs), <strong>PyRadio</strong> uses the <em>notification daemon</em> that’s already present and whatever command line helper program it provides to send notifications to the daemon.</p>
84+
<p>By default, <strong>PyRadio</strong> uses the following command to issue notifications:</p>
85+
<pre>notify-send -i ICON TITLE MSG</pre>
10086
<p>This command will:</p>
10187
<ul>
102-
<li>display an icon (-i)<br />
103-
The icon is already in <strong>PyRadio</strong> config folder; just use the full path to it.</li>
104-
<li>display the notification for 6 seconds (-t)</li>
88+
<li>display the title “<strong>TITLE</strong>” and message “<strong>MSG</strong>”.</li>
89+
<li>display an icon (<strong>-i</strong>).</li>
10590
</ul>
106-
<p>The <strong>TITLE</strong> and <strong>MSG</strong> tokens are just placeholders; <strong>PyRadio</strong> will replace them with real data when issuing the notification.</p>
107-
<p>When the command is ready, we just write it to <strong>~/.config/pyradio/notification</strong>, like so:</p>
108-
<pre>echo &quot;notify-send -i ~/.config/pyradio/pyradio.png -t 6000 TITLE MSG&quot; &gt; ~/.config/pyradio/notification</pre>
109-
<p>Next time <strong>PyRadio</strong> is executed, it will read the above file, and start issuing notifications.</p>
110-
<p>That was just an example to demonstrate the procedure one would follow to enable <strong>PyRadio</strong> Desktop Notifications.</p>
111-
<p>Users can populate the <strong>~/.config/pyradio/notification</strong> files as needed and in accordance with their notification daemon / command.</p>
112-
<h3 id="packagers-info">Packagers info</h3>
113-
<p>Since Desktop Notifications are not enabled by default, packages will have to populate the <strong>notification</strong> file manually (which is originally an empty file in the <strong>pyradio</strong> directory), using the procedure described above.</p>
114-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> The icon will probable by in <strong>/usr/share/icons</strong>.</p>
115-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Individual users can disable the Desktop Notifications enabled by the installed packaged, by creating an empty <strong>~/.config/pyradio/notification</strong> file.</p>
91+
<p>The “<strong>ICON</strong>”, “<strong>TITLE</strong>” and “<strong>MSG</strong>” tokens are just placeholders; <strong>PyRadio</strong> will replace them with real data when issuing the notification.</p>
92+
<p>If that does not work for you, or you want to customize the output, this is what to do:</p>
93+
<ol type="1">
94+
<li>put together a valid command that can be executed on a terminal and produce the desired notification.</li>
95+
<li>create a file called <strong>notification</strong> in <strong>PyRadio</strong> configuration directory.</li>
96+
<li>write the above command in that file and put each field in a different line.</li>
97+
</ol>
98+
<p><strong>Example:</strong></p>
99+
<p>I have this custom command:</p>
100+
<pre>notify-send -i ICON -t 6000 TITLE MSG</pre>
101+
<p>The file I wrote is <strong>~/.config/pyradio/notification</strong>:</p>
102+
<pre>notify-send
103+
-i
104+
ICON
105+
-t
106+
6000
107+
TITLE
108+
MSG</pre>
116109
<h2 id="on-macos">On MacOS <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
117110
<p><a href="https://members.hellug.gr/sng/pyradio/mac-notif.jpg" target="_blank"><img style="width: 411px" src="https://members.hellug.gr/sng/pyradio/mac-notif.jpg" alt="MacOS notification" /></a></p>
118111

119-
<p>MacOS Maverick (and later) provides a standardized way to display notifications, so it’s much more easier to enable them for <strong>PyRadio</strong>.</p>
120-
<p>Just create a non-empty <strong>~/.config/pyradio/notification</strong> file:</p>
121-
<pre>echo YES &gt; ~/.config/pyradio/notification</pre>
122-
<p>To disable notifications, just make it empty:</p>
123-
<pre>echo &gt; ~/.config/pyradio/notification</pre>
112+
<p>MacOS Maverick (and later) provides a scripting service to issue notifications from the command line.</p>
113+
<p>The command <strong>PyRadio</strong> uses is:</p>
114+
<pre>osascript -e &#39;display notification &quot;MSG&quot; with title &quot;TITLE&quot;&#39;
115+
</pre>
116+
<p>If that does not work for you, or you want to display the icon as well, just install terminal-notifier:</p>
117+
<pre>brew install terminal-notifier</pre>
118+
<p>After it is installed, write the following in <strong>~/.config/pyradio/notification</strong>:</p>
119+
<pre>terminal-notifier
120+
-message
121+
MSG
122+
-title
123+
TITLE
124+
-appIcon
125+
ICON</pre>
126+
<p>and you are done!</p>
124127
<h2 id="on-windows">On Windows <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
125128
<p><a href="https://members.hellug.gr/sng/pyradio/win-notif.jpg" target="_blank"><img style="width: 411px" src="https://members.hellug.gr/sng/pyradio/win-notif.jpg" alt="Windows notification" /></a></p>
126129

127130
<p>As already stated <strong>PyRadio</strong> will display notifications throught <strong>Windows Notification Service</strong> (<strong>WNS</strong>).</p>
128-
<p>All that you have to do in install one package, and you are done.</p>
129-
<pre>python -m pip install win10toast</pre>
130-
<p>If you wanto to disable Desktop Notification, just uninstall the package.</p>
131-
<pre>python -m pip uninstall win10toast</pre>
132-
<p>That’s all.</p>
131+
<p>All that you have to do is enable the notifications in the config window.</p>
133132
<h3 id="configuring-notifications">Configuring notifications</h3>
134133
<p>Window will display the program the notification comes from, which in this case is <strong>Python</strong>, not <strong>PyRadio</strong>.</p>
135134
<p>By default, a sound is played when a notification is displayed, which is very annoying when using <strong>PyRadio</strong> to listen to music and such.</p>

desktop-notification.md

Lines changed: 67 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
88
<!-- vim-markdown-toc Marked -->
99

1010
* [Introduction](#introduction)
11+
* [Configuration](#configuration)
1112
* [On Linux](#on-linux)
12-
* [Packagers info](#packagers-info)
1313
* [On MacOS](#on-macos)
1414
* [On Windows](#on-windows)
1515
* [Configuring notifications](#configuring-notifications)
@@ -21,123 +21,119 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
2121

2222
## Introduction
2323

24-
**PyRadio** can provide Desktop Notifications when a notification daemon is already present (on Linux and BSD), or throught **Windows Notification Service** (**WNS**).
24+
**PyRadio** can provide Desktop Notifications when a notification daemon is already present (on Linux and BSD), or through **Windows Notification Service** (**WNS**).
25+
26+
The behavior and presentation of notifications greatly depends on the daemon/service and command line utility used to trigger a notification.
2527

2628
If enabled, **PyRadio** will display:
2729

28-
1. Song info (as provided by the radio station) \
29-
That means that if the radio station does not provide any info, no notification will be issued.
30+
1. The playlist name, when playback starts.
31+
1. Song info (as provided by the radio station).
3032
2. Connection failure messages.
3133
3. Player crash messages.
3234

33-
**Note:** If Desktop Notification is enabled by default (in the case of a distro package) users can disable it by creating an empty **~/.config/pyradio/notification** file (Linux only).
34-
35-
## On Linux
36-
37-
![Linux notification](https://members.hellug.gr/sng/pyradio/pyradio-notif.jpg)
35+
Desktop Notifications are disabled by default.
3836

39-
On Linux (and the BSDs), **PyRadio** uses the *notification daemon* that's already present, using whatever command it provides to send notifications to the daemon.
4037

41-
On my linux box, this is done using the **notify-send** command (as it would be with most distros).
38+
### Configuration
4239

43-
This is its help screen.
40+
Desktop Notifications are disabled by default. To enable them, go to **PyRadio** config window and customize the "*Enable notifications*" option.
4441

42+
Available values are:
4543
```
46-
# notify-send --help
47-
48-
Usage:
49-
notify-send [OPTION…] <SUMMARY> [BODY] - create a notification
50-
51-
Help Options:
52-
-?, --help Show help options
53-
54-
Application Options:
55-
-u, --urgency=LEVEL Specifies the urgency level (low, normal, critical).
56-
-t, --expire-time=TIME Specifies the timeout in milliseconds at which to expire the notification.
57-
-a, --app-name=APP_NAME Specifies the app name for the icon
58-
-i, --icon=ICON Specifies an icon filename or stock icon to display.
59-
-c, --category=TYPE[,TYPE...] Specifies the notification category.
60-
-e, --transient Create a transient notification
61-
-h, --hint=TYPE:NAME:VALUE Specifies basic extra data to pass. Valid types are boolean, int, double, string, byte and variant.
62-
-p, --print-id Print the notification ID.
63-
-r, --replace-id=REPLACE_ID The ID of the notification to replace.
64-
-w, --wait Wait for the notification to be closed before exiting.
65-
-A, --action=[NAME=]Text... Specifies the actions to display to the user. Implies --wait to wait for user input. May be set multiple times. The name of the action is output to stdout. If NAME is not specified, the numerical index of the option is used (starting with 0).
66-
-v, --version Version of the package.
44+
-1: disabled (deault)
45+
0: enabled (no repetition)
46+
x: enabled and repeat every x seconds
6747
```
6848

69-
In order to make **PyRadio** use it, we wil use this help screen to create a valid command, for example:
49+
**PyRadio** supports notifications repetition, so that even when used with `quake` or `yakuake` and the like, you still have some info on what's going on with it.
7050

71-
```
72-
notify-send -i ~/.config/pyradio/pyradio.png -t 6000 TITLE MSG
73-
```
51+
Notifications can be set to repeat every "*x*" seconds, with "*x*" ranging from 30 to 300 (30 seconds to 5 minutes), in 30 seconds steps.
7452

75-
This command will:
53+
## On Linux
7654

77-
- display an icon (-i) \
78-
The icon is already in **PyRadio** config folder; just use the full path to it.
79-
- display the notification for 6 seconds (-t)
55+
![Linux notification](https://members.hellug.gr/sng/pyradio/pyradio-notif.jpg)
8056

81-
The **TITLE** and **MSG** tokens are just placeholders; **PyRadio** will replace them with real data when issuing the notification.
57+
On Linux (and the BSDs), **PyRadio** uses the *notification daemon* that's already present and whatever command line helper program it provides to send notifications to the daemon.
8258

83-
When the command is ready, we just write it to **~/.config/pyradio/notification**, like so:
59+
By default, **PyRadio** uses the following command to issue notifications:
8460

8561
```
86-
echo "notify-send -i ~/.config/pyradio/pyradio.png -t 6000 TITLE MSG" > ~/.config/pyradio/notification
62+
notify-send -i ICON TITLE MSG
8763
```
8864

89-
Next time **PyRadio** is executed, it will read the above file, and start issuing notifications.
90-
91-
That was just an example to demonstrate the procedure one would follow to enable **PyRadio** Desktop Notifications.
92-
93-
Users can populate the **~/.config/pyradio/notification** files as needed and in accordance with their notification daemon / command.
94-
95-
### Packagers info
96-
97-
Since Desktop Notifications are not enabled by default, packages will have to populate the **notification** file manually (which is originally an empty file in the **pyradio** directory), using the procedure described above.
65+
This command will:
9866

99-
**Note:** The icon will probable by in **/usr/share/icons**.
67+
- display the title "**TITLE**" and message "**MSG**".
68+
- display an icon (**-i**).
10069

101-
**Note:** Individual users can disable the Desktop Notifications enabled by the installed packaged, by creating an empty **~/.config/pyradio/notification** file.
70+
The "**ICON**", "**TITLE**" and "**MSG**" tokens are just placeholders; **PyRadio** will replace them with real data when issuing the notification.
10271

103-
## On MacOS
72+
If that does not work for you, or you want to customize the output, this is what to do:
10473

105-
![MacOS notification](https://members.hellug.gr/sng/pyradio/mac-notif.jpg)
74+
1. put together a valid command that can be executed on a terminal and produce the desired notification.
75+
2. create a file called **notification** in **PyRadio** configuration directory.
76+
3. write the above command in that file and put each field in a different line.
10677

107-
MacOS Maverick (and later) provides a standardized way to display notifications, so it's much more easier to enable them for **PyRadio**.
78+
**Example:**
10879

109-
Just create a non-empty **~/.config/pyradio/notification** file:
80+
I have this custom command:
11081

11182
```
112-
echo YES > ~/.config/pyradio/notification
83+
notify-send -i ICON -t 6000 TITLE MSG
11384
```
11485

115-
To disable notifications, just make it empty:
86+
The file I wrote is **~/.config/pyradio/notification**:
11687

11788
```
118-
echo > ~/.config/pyradio/notification
89+
notify-send
90+
-i
91+
ICON
92+
-t
93+
6000
94+
TITLE
95+
MSG
11996
```
12097

121-
## On Windows
98+
## On MacOS
12299

123-
![Windows notification](https://members.hellug.gr/sng/pyradio/win-notif.jpg)
100+
![MacOS notification](https://members.hellug.gr/sng/pyradio/mac-notif.jpg)
124101

125-
As already stated **PyRadio** will display notifications throught **Windows Notification Service** (**WNS**).
102+
MacOS Maverick (and later) provides a scripting service to issue notifications from the command line.
126103

127-
All that you have to do in install one package, and you are done.
104+
The command **PyRadio** uses is:
128105

129106
```
130-
python -m pip install win10toast
107+
osascript -e 'display notification "MSG" with title "TITLE"'
108+
131109
```
132110

111+
If that does not work for you, or you want to display the icon as well, just install `terminal-notifier`:
133112

134-
If you wanto to disable Desktop Notification, just uninstall the package.
113+
```
114+
brew install terminal-notifier
115+
```
116+
After it is installed, write the following in **~/.config/pyradio/notification**:
135117

136118
```
137-
python -m pip uninstall win10toast
119+
terminal-notifier
120+
-message
121+
MSG
122+
-title
123+
TITLE
124+
-appIcon
125+
ICON
138126
```
139127

140-
That's all.
128+
and you are done!
129+
130+
## On Windows
131+
132+
![Windows notification](https://members.hellug.gr/sng/pyradio/win-notif.jpg)
133+
134+
As already stated **PyRadio** will display notifications throught **Windows Notification Service** (**WNS**).
135+
136+
All that you have to do is enable the notifications in the config window.
141137

142138
### Configuring notifications
143139

@@ -170,3 +166,4 @@ If you click on the little tool-like "icon" next to the "X", you get to the "**N
170166
![Windows 7 Nontification Icons](https://members.hellug.gr/sng/pyradio/win7-icons.jpg)
171167

172168
Again, Window considers that the program sending the notifications is **Python**, not **PyRadio**, so that's what you will be changing.
169+

0 commit comments

Comments
 (0)