Skip to content

Commit 5a618d1

Browse files
committed
- Fixing player_params_file and schedule_file when XDG compliance is ON
- Updating docs broken links
1 parent 9ea7a80 commit 5a618d1

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ Finally, include the file produced in your report.
184184

185185
## Packaging PyRadio
186186

187-
If you are a packager and would like to produce a package for your distribution please do follow [this mini guide](docs/packagers-info.md).
187+
If you are a packager and would like to produce a package for your distribution please do follow [this mini guide](docs/packaging.md).
188188

189189
## TODO
190190

docs/packaging.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h3 id="pyradio__pycache__">pyradio/__pycache__</h3>
123123
<h2 id="recordings-directory">Recordings Directory <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
124124
<p>Parameter <strong>recording_dir</strong> in the config will point to the directory to save recorded files.</p>
125125
<p>It may seem like a good idea to change it to something meaningful but there is a catch.</p>
126-
<p><strong>PyRadio 0.9.3</strong> (and newer) will nornaly use the <em>default</em> location, which is <em><sub>/pyradio-recordings<em>. Furthermore, it will move the pre-0.9.3 default recordings dir (~/.config/pyradio/recordings) and titles log (from </em></sub>/.config/pyradio</em>) to this new default location.</p>
126+
<p><strong>PyRadio 0.9.3</strong> (and newer) will nornaly use the <em>default</em> location, which is <em><sub>/pyradio-recordings<em>. Furthermore, it will move the pre-0.9.3 default recordings dir, i.e. </em></sub>/.config/pyradio/recordings</em> and titles log(from <em>~/.config/pyradio</em>, to this new default location.</p>
127127
<p>If you, the packager, provide a different default <strong>recording_dir</strong> in the package config file, your users will probably end up in the following situation:</p>
128128
<ol type="1">
129129
<li><p>Pro existing recordings and titles logs will end up in <em>~/pyradio-recordings</em>.</p></li>

docs/packaging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ Parameter **recording_dir** in the config will point to the directory to save re
133133

134134
It may seem like a good idea to change it to something meaningful but there is a catch.
135135

136-
**PyRadio 0.9.3** (and newer) will nornaly use the *default* location, which is *~/pyradio-recordings*. Furthermore, it will move the pre-0.9.3 default recordings dir (~/.config/pyradio/recordings) and titles log (from *~/.config/pyradio*) to this new default location.
136+
**PyRadio 0.9.3** (and newer) will nornaly use the *default* location, which is *~/pyradio-recordings*. Furthermore, it will move the pre-0.9.3 default recordings dir, i.e. *~/.config/pyradio/recordings* and titles log(from *~/.config/pyradio*, to this new default location.
137137

138138
If you, the packager, provide a different default **recording_dir** in the package config file, your users will probably end up in the following situation:
139139

pyradio/config.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ def __init__(self, stationFile='', user_config_dir=None):
179179
self.xdg.build_paths()
180180
self.xdg.ensure_paths_exist()
181181
self.root_path = path.join(path.dirname(__file__), 'stations.csv')
182-
self.player_params_file = path.join(self.data_dir, 'player-params.json')
183-
self.schedule_file = path.join(self.data_dir, 'schedule.json')
184182
self.themes_dir = path.join(self.stations_dir, 'themes')
185183
self.favorites_path = path.join(self.stations_dir, 'favorites.csv')
186184
try:
@@ -2393,6 +2391,22 @@ def _read_config(self, distro_config=False):
23932391
self.opts['dirty_config'][1] = True
23942392

23952393
self._make_sure_dirs_exist()
2394+
''' detect previous XDG Base installation '''
2395+
if not platform.startswith('win') and \
2396+
self._user_config_dir is None and \
2397+
not self.xdg_compliant and \
2398+
distro_config:
2399+
# d_dir = path.join(XdgDirs.get_xdg_dir('XDG_DATA_HOME'), 'pyradio')
2400+
# s_dir = path.join(XdgDirs.get_xdg_dir('XDG_STATE_HOME'), 'pyradio')
2401+
d_dir = XdgDirs.get_xdg_dir('XDG_DATA_HOME')
2402+
s_dir = XdgDirs.get_xdg_dir('XDG_STATE_HOME')
2403+
if path.exists(d_dir) and path.exists(s_dir):
2404+
print('[magenta]XDG Dirs[/magenta] found; enabling [magenta]XDG Base compliant[/magenta] operation')
2405+
self.xdg_compliant = True
2406+
self.need_to_fix_desktop_file_icon = True
2407+
2408+
# do this here to get proper extra parameters config filepath if XDG is on
2409+
self.player_params_file = path.join(self.data_dir, 'player-params.json')
23962410
if not distro_config:
23972411
if path.exists(self.player_params_file + '.restore'):
23982412
try:
@@ -2406,20 +2420,11 @@ def _read_config(self, distro_config=False):
24062420
except:
24072421
pass
24082422
self._first_read = False
2423+
logger.error('\n\nfile = {0}\nplayer extra params = {1}\n\n'.format(self.player_params_file, self.params))
2424+
2425+
# do this here to get proper schedule config filepath if XDG is on
2426+
self.schedule_file = path.join(self.data_dir, 'schedule.json')
24092427

2410-
''' detect previous XDG Base installation '''
2411-
if not platform.startswith('win') and \
2412-
self._user_config_dir is None and \
2413-
not self.xdg_compliant and \
2414-
distro_config:
2415-
# d_dir = path.join(XdgDirs.get_xdg_dir('XDG_DATA_HOME'), 'pyradio')
2416-
# s_dir = path.join(XdgDirs.get_xdg_dir('XDG_STATE_HOME'), 'pyradio')
2417-
d_dir = XdgDirs.get_xdg_dir('XDG_DATA_HOME')
2418-
s_dir = XdgDirs.get_xdg_dir('XDG_STATE_HOME')
2419-
if path.exists(d_dir) and path.exists(s_dir):
2420-
print('[magenta]XDG Dirs[/magenta] found; enabling [magenta]XDG Base compliant[/magenta] operation')
2421-
self.xdg_compliant = True
2422-
self.need_to_fix_desktop_file_icon = True
24232428

24242429
def _make_sure_dirs_exist(self):
24252430
if self.opts['recording_dir'][1] == '':

0 commit comments

Comments
 (0)