Skip to content

Commit fc3f55e

Browse files
committed
Implementing "Save Config"
1 parent 0713f90 commit fc3f55e

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

Changelog

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
2019-03-30 s-n-g
1+
2019-04-16 s-n-g
22
* Minimum python version supported changed. Now it's 2.7+/3.5+
3+
* Added configuration window (opens with "c").
34

45
2019-02-14 s-n-g
56

README.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,16 @@ <h2 id="controls">Controls</h2>
106106
o s R Open / Save / Reload playlist - -
107107
DEL,x Delete selected station - -
108108
t T Load theme / Toggle transparency [Valid] [Valid]
109+
c Open Configuration window. - -
109110
? Show keys help [Valid] [Valid]
110111
# Redraw window [Valid] [Valid]
111112
Esc/q Quit - -
112113
Esc/q/Left/h - Cancel / close window Cancel / close window</pre>
113114
<h2 id="config-file">Config file</h2>
114115
<p><strong>PyRadio</strong> upon its execution tries to read its configuration file (i.e. <em>~/.config/pyradio/config</em>). If this file is not found, it will be created. If an error occurs while parsing it, an error message will be displayed and <strong><em>PyRadio</em></strong> will terminate.</p>
115116
<p>The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented (as you can see <a href="pyradio/config">here</a>), so that manual editing is really easy. The best practice to manually edit this file is executing <strong><em>PyRadio</em></strong> with the <strong>-ocd</strong> command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.</p>
116-
<p>The file can also be altered while <strong>PyRadio</strong> is running. This process is transparent to the user; <strong>PyRadio</strong> will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).</p>
117+
<p>The file can also be altered while <strong>PyRadio</strong> is running by pressing “<strong><em>c</em></strong>”, which will open the “<strong><em>Configuration window</em></strong>”. This window presents all <strong>PyRadio</strong> options and provide the way to change them.</p>
118+
<p>In any case, <strong>PyRadio</strong> will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).</p>
117119
<h2 id="about-playlist-files">About Playlist files</h2>
118120
<p><strong>PyRadio</strong> reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.</p>
119121
<p>Optionally, a third column can be inserted, stating the encoding used by the station (more on this at <a href="#specifying-stations-encoding">Specifying stations’ encoding</a>).</p>

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ v Save volume (not applicable for vlc) [Valid]
9191
o s R Open / Save / Reload playlist - -
9292
DEL,x Delete selected station - -
9393
t T Load theme / Toggle transparency [Valid] [Valid]
94+
c Open Configuration window. - -
9495
? Show keys help [Valid] [Valid]
9596
# Redraw window [Valid] [Valid]
9697
Esc/q Quit - -
@@ -103,7 +104,9 @@ Esc/q/Left/h - Cancel / close windo
103104

104105
The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented (as you can see [here](pyradio/config)), so that manual editing is really easy. The best practice to manually edit this file is executing ***PyRadio*** with the **-ocd** command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.
105106

106-
The file can also be altered while **PyRadio** is running. This process is transparent to the user; **PyRadio** will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
107+
The file can also be altered while **PyRadio** is running by pressing "***c***", which will open the "***Configuration window***". This window presents all **PyRadio** options and provide the way to change them.
108+
109+
In any case, **PyRadio** will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
107110

108111
## About Playlist files
109112

pyradio.1

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.\" Copyright (C) 2011 Ben Dowling <http://www.coderholic.com/pyradio>
22
.\" This manual is freely distributable under the terms of the GPL.
33
.\"
4-
.TH PYRADIO 1 "March 2019"
4+
.TH PYRADIO 1 "April 2019"
55

66
.SH NAME
77
.PP
@@ -86,7 +86,9 @@ Quit
8686

8787
The file contains parameters such as the player to use, the playlist to load etc. It is heavily commented, so that manual editing is really easy. The best practice to manually edit this file is executing \fBpyradio\fR with the \fB-ocd\fR command line option, which will open the configuration directory in your file manager, and then edit it using your preferable text editor.
8888

89-
The file can also be altered while \fBpyradio\fR is running. This process is transparent to the user; \fBpyradio\fR will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
89+
The file can also be altered while \fBpyradio\fR is running, by pressing "\fIc\fR", which will open the "\fIConfiguration window\fR". This window presents all \fBpyradio\fR options and provide the way to change them.
90+
91+
In any case, \fBpyradio\fR will save the file before exiting (or in case Ctrl-C is pressed) if needed (e.g. if a config parameter has been changed during its execution).
9092

9193
.SH ABOUT PLAYLIST FILES
9294
.PP

pyradio/config_window.py

+4
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def keypress(self, char):
295295
""" ESCAPE """
296296
return 1, []
297297
elif char in (ord('s'), ):
298+
self._saved_config_options = deepcopy(self._config_options)
299+
if self._cnf.opts != self._saved_config_options:
300+
self._cnf.opts = deepcopy(self._config_options)
301+
self._cnf.dirty_config = True
298302
# save and exit
299303
return 0, [1]
300304
elif char in (curses.KEY_ENTER, ord('\n'),

pyradio/radio.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ def _print_help(self):
828828
o s R ||O|pen / |S|ave / |R|eload playlist.
829829
DEL|,|x |Delete selected station.
830830
t T |Load |t|heme / |T|oggle transparency.
831-
c |Configuration.
831+
c |Open Configuration window.
832832
Esc|/|q |Quit. """
833833
self._show_help(txt)
834834
if logger.isEnabledFor(logging.DEBUG):
@@ -1414,6 +1414,7 @@ def keypress(self, char):
14141414
self.bodyWin.box()
14151415
self._print_body_header()
14161416
self.refreshBody()
1417+
self.cnf._save_config()
14171418
# clean up
14181419
self._player_select_win = None
14191420
self._encoding_select_win = None

0 commit comments

Comments
 (0)