Skip to content

Commit eb7f5c9

Browse files
committed
- adding PyRadioResourceOpener class, the window to insert a linux
resource opener - fixing #237 - updating docs
1 parent d70ea98 commit eb7f5c9

File tree

13 files changed

+529
-37
lines changed

13 files changed

+529
-37
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ and much more...
9696
- python-dateutil
9797
- netifaces (optional)
9898
* MPV, MPlayer or VLC installed and in your path
99-
* MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional)
99+
* MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional, if MPV or VLC is to be used, but mandatory in the case of MPlayer)
100100

101-
Linux users will have to install the "**xdg-utils**" package (may be named differently in your distro) which will provide "**xdg-open**", the utility to open directories, html pages, etc.
102-
103-
Linux and macOS users will have to have installed a font that supports the "**Unicode Geometric Shapes Block**". Any font mentioned in the [Font Support for Unicode Block 'Geometric Shapes'](https://www.fileformat.info/info/unicode/block/geometric_shapes/fontsupport.htm) page will do; as you can see these include **DejaVu**, **FreeMono**, **Unifont**, etc, some of which will fopefully be installed by default.
101+
Linux users will have to install a [resource opener](https://wiki.archlinux.org/title/default_applications#Resource_openers) package, a utility to open directories, html pages, etc. **PyRadio** will look for *xdg-open*, *gio*, *mimeopen*, *mimeo* or *handlr*, in that order of detection. If a different *resource opener* is used, one can declare it in the **Configuration Window**.
104102

105103
<!-- Changelog -->
106104

docs/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,9 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
199199
<li>netifaces</li>
200200
</ul></li>
201201
<li>MPV, MPlayer or VLC installed and in your path</li>
202-
<li>MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional)</li>
202+
<li>MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional, if MPV or VLC is to be used, but mandatory in the case of MPlayer)</li>
203203
</ul>
204-
<p>Linux users will have to install the “<strong>xdg-utils</strong>” package (may be named differently in your distro) which will provide “<strong>xdg-open</strong>”, the utility to open directories, html pages, etc.</p>
205-
<p>Linux and macOS users will have to have installed a font that supports the “<strong>Unicode Geometric Shapes Block</strong>”. Any font mentioned in the <a target="_blank" href="https://www.fileformat.info/info/unicode/block/geometric_shapes/fontsupport.htm">Font Support for Unicode Block ‘Geometric Shapes’</a> page will do; as you can see these include <strong>DejaVu</strong>, <strong>FreeMono</strong>, <strong>Unifont</strong>, etc, some of which will fopefully be installed by default.</p>
204+
<p>Linux users will have to install a <a target="_blank" href="https://wiki.archlinux.org/title/default_applications#Resource_openers">resource opener</a> package, a utility to open directories, html pages, etc. <strong>PyRadio</strong> will look for <em>xdg-open</em>, <em>gio</em>, <em>mimeopen</em>, <em>mimeo</em> or <em>handlr</em>, in that order of detection. If a different <em>resource opener</em> is used, one can declare it in the <strong>Configuration Window</strong>.</p>
206205
<!-- Changelog -->
207206
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
208207
<pre style="height: 200px;">

docs/index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,9 @@ and much more...
145145
- python-dateutil
146146
- netifaces
147147
* MPV, MPlayer or VLC installed and in your path
148-
* MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional)
148+
* MKVToolNix (cli files) to insert tags, chapters and cover to recordings (optional, if MPV or VLC is to be used, but mandatory in the case of MPlayer)
149149

150-
Linux users will have to install the "**xdg-utils**" package (may be named differently in your distro) which will provide "**xdg-open**", the utility to open directories, html pages, etc.
151-
152-
Linux and macOS users will have to have installed a font that supports the "**Unicode Geometric Shapes Block**". Any font mentioned in the [Font Support for Unicode Block 'Geometric Shapes'](https://www.fileformat.info/info/unicode/block/geometric_shapes/fontsupport.htm) page will do; as you can see these include **DejaVu**, **FreeMono**, **Unifont**, etc, some of which will fopefully be installed by default.
150+
Linux users will have to install a [resource opener](https://wiki.archlinux.org/title/default_applications#Resource_openers) package, a utility to open directories, html pages, etc. **PyRadio** will look for *xdg-open*, *gio*, *mimeopen*, *mimeo* or *handlr*, in that order of detection. If a different *resource opener* is used, one can declare it in the **Configuration Window**.
153151

154152
<!-- Changelog -->
155153

pyradio/config

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ recording_dir = default
5252
# Default value is "auto", in which case, PyRadio will try to use xdg-open,
5353
# gio, mimeopen, mimeo or handlr, in that order of detection. If none if found,
5454
# the requested file will simply not open.
55-
# To set a custom Opener, insert the absolute path to its executable, followed
56-
# by any parameter required, for example: "/usr/bin/gio open".
55+
# To set a custom Opener, insert its name (either absolute path to its executable
56+
# or its name, if it is in your PATH), followedi by any parameter required,
57+
# for example: "/usr/bin/gio open", "mimeopen -n".
5758
resource_opener = auto
5859

5960
# Desktop notifications

pyradio/config.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,6 +1716,10 @@ def remote_control_server_port(self):
17161716
def remote_control_server_auto_start(self):
17171717
return self.opts['remote_control_server_auto_start'][1]
17181718

1719+
@property
1720+
def resource_opener(self):
1721+
return self.opts['resource_opener'][1]
1722+
17191723
@property
17201724
def recording_dir(self):
17211725
return self.opts['recording_dir'][1]
@@ -2054,7 +2058,6 @@ def _read_config(self, distro_config=False):
20542058
self._make_sure_dirs_exist()
20552059
self._first_read = False
20562060
return
2057-
self._linux_resource_opener = None
20582061
lines = []
20592062
try:
20602063
with open(file_to_read, 'r', encoding='utf-8') as cfgfile:
@@ -2228,13 +2231,15 @@ def _read_config(self, distro_config=False):
22282231
sp[1].lower() == 'true':
22292232
self.xdg_compliant = True
22302233
elif sp[0] == 'resource_opener' and \
2231-
not platform.startswith('win'):
2232-
if self.opts['resource_opener'][1] != 'auto':
2233-
tmp = self.opts['resource_opener'][1].split(' ')
2234+
not (platform.startswith('win') or \
2235+
platform.startswith('dar')):
2236+
if sp[1] != 'auto':
2237+
tmp = sp[1].split(' ')
22342238
prog = validate_resource_opener_path(tmp[0])
22352239
if prog is not None:
22362240
tmp[0] = prog
22372241
self._linux_resource_opener = ' '.join(tmp)
2242+
self.opts['resource_opener'][1] = sp[1]
22382243

22392244
# logger.error('\n\nself.params{}\n\n'.format(self.params))
22402245
''' read distro from package config file '''
@@ -2657,6 +2662,7 @@ def save_config(self, from_command_line=False):
26572662
logger.info('Config saved')
26582663
self.dirty_config = False
26592664
self.params_changed = False
2665+
self._linux_resource_opener = self.resource_opener
26602666
return 0
26612667

26622668
def read_playlist_file(

pyradio/config_window.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ def keypress(self, char):
728728
if char in self._global_functions.keys():
729729
self._global_functions[char]()
730730

731+
elif val[0] == 'resource_opener':
732+
return self.n_u.INSERT_RESOURCE_OPENER, []
733+
731734
elif val[0] == 'recording_dir':
732735
return self.n_u.INSERT_RECORDINGS_DIR_MODE, []
733736

0 commit comments

Comments
 (0)