Skip to content

Commit 9ce85bf

Browse files
committed
- finalizing session locking
- update notification will happen every 10 days - added "M" command - docs updated - done a bit of refactoring
1 parent fc4beaf commit 9ce85bf

File tree

6 files changed

+212
-133
lines changed

6 files changed

+212
-133
lines changed

Changelog

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
2019-06-21
1+
2019-06-23 s-n-g
22
* mpv now uses a dedicated socket file. This way multiple instances of
33
PyRadio can be executed.
4-
* Introducing session locking.
4+
* Introducing session locking.
55
* Added the "--unlock" command line parameter, to force sessions' unlock.
6+
* Added "M" command, which will jump to the middle of the list.
67
* PyRadio can load external theme files.
78
* Three more themes added. These are system themes (actual files).
89
* Theme selection window reworked - themes are separated by location,
910
theme selection is remembered when resizing, and loading default or
1011
saved theme (in config window).
1112
* PyRadio will check and report when a new release is available.
1213
* Added good bye message.
13-
* Theme editor implementation started (disabled for this release).
14+
* Theme editor implementation started (disabled for this release).
1415
* Minor other fixes.
1516

16-
2019-06-06
17+
2019-06-06 s-n-g
1718
* Verion 0.7.6.2
1819
This is a BUG FIX release, fixing config status (indicating whether
1920
config is modified or not)
2021

21-
2019-06-02
22+
2019-06-02 s-n-g
2223
* Version 0.7.6.1
2324
This is a BUG FIX release, fixing regression: config not saved when
2425
changing themes

README.html

+11-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ <h2 id="table-of-contents">Table of contents</h2>
4040
<li><a href="#player-detection-selection">Player detection / selection</a></li>
4141
<li><a href="#player-default-volume-level">Player default volume level</a></li>
4242
<li><a href="#pyradio-themes">PyRadio Themes</a></li>
43+
<li><a href="#session-locking">Session Locking</a></li>
44+
<li><a href="#update-notification">Update notification</a></li>
4345
<li><a href="#debug-mode">Debug mode</a></li>
4446
</ul>
4547
<h2 id="requirements">Requirements</h2>
@@ -112,7 +114,7 @@ <h2 id="controls">Controls</h2>
112114
Esc/q Quit - -
113115
Esc/q/Left/h - Cancel / close window Cancel / close window</pre>
114116
<p>The same logic applies to all <strong>PyRadio</strong> windows.</p>
115-
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> All windows support changing the volume and muting / unmuting the player (provided that it is actually connected to a station).</p>
117+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> All windows support changing the volume and muting / unmuting the player (provided that <strong>PyRadio</strong> is actually connected to a station).</p>
116118
<h2 id="config-file">Config file</h2>
117119
<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>
118120
<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>
@@ -244,6 +246,14 @@ <h3 id="using-transparency">Using transparency</h3>
244246
<p>Pressing “<strong>T</strong>” will toggle the transparency setting and save this state in <strong>PyRadio</strong>’s configuration file (transparency is off by default).</p>
245247
<p>Setting transparency on, will actually force <strong>PyRadio</strong> to not use its own background color, effectively making it to display whatever is on the terminal (color/picture/transparency). The visual result depends on terminal settings and whether a compositor is running.</p>
246248
<p>When the <em>Theme selection window</em> is visible, a “<strong>[T]</strong>” string displayed at its bottom right corner will indicate that transparency is <em>on</em>.</p>
249+
<h2 id="session-locking">Session Locking</h2>
250+
<p><strong>PyRadio</strong> uses session locking, which actually means that only the first instance executed within a given session will be able to write to the configuration file.</p>
251+
<p>Subsequent instances will be “<em>locked</em>”. This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will <strong>not</strong> be recorded in the configuration file.</p>
252+
<h3 id="seeeion-unlocking">Seeeion unlocking</h3>
253+
<p>If for any reason <strong>PyRadio</strong> always starts in <em>locked mode</em>, one can <strong>unclock</strong> the session, using the “<em>–unlock</em>” command line paremater.</p>
254+
<h2 id="update-notification">Update notification</h2>
255+
<p><strong>PyRadio</strong> will periodically (once every 10 days) check whether a new version has been released.</p>
256+
<p>If so, a notification message will be displayed, informing the user about it.</p>
247257
<h2 id="debug-mode">Debug mode</h2>
248258
<p>Adding the <strong><em>-d</em></strong> option to the command line will instruct <strong>PyRadio</strong> to enter <em>Debug mode</em>, which means that it will print debug messages to a file. This file will always reside in the user’s home directory and will be named <em>pyradio.log</em>.</p>
249259
<p>In case of a bug or a glitch, please include this file to the issue you will <a href="https://github.com/coderholic/pyradio/issues">open in github</a>.</p>

README.md

+19-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
1616
* [Player detection / selection](#player-detection-selection)
1717
* [Player default volume level](#player-default-volume-level)
1818
* [PyRadio Themes](#pyradio-themes)
19+
* [Session Locking](#session-locking)
20+
* [Update notification](#update-notification)
1921
* [Debug mode](#debug-mode)
2022

2123
## Requirements
@@ -100,7 +102,7 @@ Esc/q/Left/h - Cancel / close windo
100102

101103
The same logic applies to all **PyRadio** windows.
102104

103-
**Note:** All windows support changing the volume and muting / unmuting the player (provided that it is actually connected to a station).
105+
**Note:** All windows support changing the volume and muting / unmuting the player (provided that **PyRadio** is actually connected to a station).
104106

105107

106108
## Config file
@@ -354,6 +356,22 @@ Setting transparency on, will actually force **PyRadio** to not use its own back
354356

355357
When the *Theme selection window* is visible, a "**[T]**" string displayed at its bottom right corner will indicate that transparency is *on*.
356358

359+
## Session Locking
360+
361+
**PyRadio** uses session locking, which actually means that only the first instance executed within a given session will be able to write to the configuration file.
362+
363+
Subsequent instances will be "*locked*". This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will **not** be recorded in the configuration file.
364+
365+
### Seeeion unlocking
366+
367+
If for any reason **PyRadio** always starts in *locked mode*, one can **unclock** the session, using the "*--unlock*" command line paremater.
368+
369+
## Update notification
370+
371+
**PyRadio** will periodically (once every 10 days) check whether a new version has been released.
372+
373+
If so, a notification message will be displayed, informing the user about it.
374+
357375
## Debug mode
358376

359377
Adding the ***-d*** option to the command line will instruct **PyRadio** to enter *Debug mode*, which means that it will print debug messages to a file. This file will always reside in the user's home directory and will be named *pyradio.log*.

pyradio.1

+16
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,22 @@ Setting transparency on, will actually force \fBpyradio\fR to not use its own ba
384384

385385
When the \fITheme selection window\fR is visible, a "\fI[T]\fR" string displayed at its bottom right corner will indicate that transparency is \fIon\fR.
386386

387+
.SH SESSION LOCKING
388+
389+
\fBpyradio\fR uses session locking, which actually means that only the first instance executed within a given session will be able to write to the configuration file.
390+
391+
Subsequent instances will be "\fIlocked\fR. This means that the user can still play stations, load and edit playlists, load and test themes, but any changes will \fBnot\fR be recorded in the configuration file.
392+
393+
\fBSeeeion unlocking\fR
394+
395+
If for any reason \fBpyradio\fR always starts in \fIlocked mode\fR, one can \fBunclock\fR the session, using the "\fB--unlock\fR" command line paremater.
396+
397+
.SH UPDATE NOTIFICATION
398+
.PP
399+
\fBpyradio\fR will periodically (once every 10 days) check whether a new version has been released.
400+
401+
If so, a notification message will be displayed, informing the user about it.
402+
387403
.SH DEBUG MODE
388404
.PP
389405
Adding the \fB-d\fR option to the command line will instruct \fBpyradio\fR to enter \fBDebug mode\fR, which means that it will print debug messages to a file. This file will always reside in the user's home directory and will be named \fIpyradio.log\fR.

pyradio/common.py

+72-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,78 @@
4444
CONFIG_SAVE_ERROR_MODE = 303
4545
THEME_MODE = 400
4646
UPDATE_NOTIFICATION_MODE = 1000
47-
NOT_IMPLEMENTED_YET_MODE = 1001
47+
SESSION_LOCKED_MODE = 1001
48+
NOT_IMPLEMENTED_YET_MODE = 1002
49+
50+
MODE_NAMES = {
51+
NO_PLAYER_ERROR_MODE: 'NO_PLAYER_ERROR_MODE',
52+
NORMAL_MODE: 'NORMAL_MODE',
53+
PLAYLIST_MODE: 'PLAYLIST_MODE',
54+
SEARCH_NORMAL_MODE: 'SEARCH_NORMAL_MODE',
55+
SEARCH_PLAYLIST_MODE: 'SEARCH_PLAYLIST_MODE',
56+
CONFIG_MODE: 'CONFIG_MODE',
57+
SELECT_PLAYER_MODE: 'SELECT_PLAYER_MODE',
58+
SELECT_ENCODING_MODE: 'SELECT_ENCODING_MODE',
59+
SELECT_PLAYLIST_MODE: 'SELECT_PLAYLIST_MODE',
60+
SELECT_STATION_MODE: 'SELECT_STATION_MODE',
61+
SELECT_STATION_ENCODING_MODE: 'SELECT_STATION_ENCODING_MODE',
62+
NEW_THEME_MODE: 'NEW_THEME_MODE',
63+
EDIT_THEME_MODE: 'EDIT_THEME_MODE',
64+
REMOVE_STATION_MODE: 'REMOVE_STATION_MODE',
65+
SAVE_PLAYLIST_MODE: 'SAVE_PLAYLIST_MODE',
66+
ASK_TO_SAVE_PLAYLIST_WHEN_OPENING_PLAYLIST_MODE: 'ASK_TO_SAVE_PLAYLIST_WHEN_OPENING_PLAYLIST_MODE',
67+
ASK_TO_SAVE_PLAYLIST_WHEN_EXITING_MODE: 'ASK_TO_SAVE_PLAYLIST_WHEN_EXITING_MODE',
68+
MAIN_HELP_MODE: 'MAIN_HELP_MODE',
69+
PLAYLIST_HELP_MODE: 'PLAYLIST_HELP_MODE',
70+
CONFIG_HELP_MODE: 'CONFIG_HELP_MODE',
71+
THEME_HELP_MODE: 'THEME_HELP_MODE',
72+
SELECT_PLAYER_HELP_MODE: 'SELECT_PLAYER_HELP_MODE',
73+
SELECT_ENCODING_HELP_MODE: 'SELECT_ENCODING_HELP_MODE',
74+
SELECT_PLAYLIST_HELP_MODE: 'SELECT_PLAYLIST_HELP_MODE',
75+
SELECT_STATION_HELP_MODE: 'SELECT_STATION_HELP_MODE',
76+
NEW_THEME_HELP_MODE: 'NEW_THEME_HELP_MODE',
77+
EDIT_THEME_HELP_MODE: 'EDIT_THEME_HELP_MODE',
78+
ASK_TO_CREATE_NEW_THEME_MODE: 'ASK_TO_CREATE_NEW_THEME_MODE',
79+
PLAYLIST_RECOVERY_ERROR_MODE: 'PLAYLIST_RECOVERY_ERROR_MODE',
80+
PLAYLIST_NOT_FOUND_ERROR_MODE: 'PLAYLIST_NOT_FOUND_ERROR_MODE',
81+
PLAYLIST_LOAD_ERROR_MODE: 'PLAYLIST_LOAD_ERROR_MODE',
82+
PLAYLIST_RELOAD_ERROR_MODE: 'PLAYLIST_RELOAD_ERROR_MODE',
83+
PLAYLIST_RELOAD_CONFIRM_MODE: 'PLAYLIST_RELOAD_CONFIRM_MODE',
84+
PLAYLIST_DIRTY_RELOAD_CONFIRM_MODE: 'PLAYLIST_DIRTY_RELOAD_CONFIRM_MODE',
85+
PLAYLIST_SCAN_ERROR_MODE: 'PLAYLIST_SCAN_ERROR_MODE',
86+
SAVE_PLAYLIST_ERROR_1_MODE: 'SAVE_PLAYLIST_ERROR_1_MODE',
87+
SAVE_PLAYLIST_ERROR_2_MODE: 'SAVE_PLAYLIST_ERROR_2_MODE',
88+
FOREIGN_PLAYLIST_ASK_MODE: 'FOREIGN_PLAYLIST_ASK_MODE',
89+
FOREIGN_PLAYLIST_MESSAGE_MODE: 'FOREIGN_PLAYLIST_MESSAGE_MODE',
90+
FOREIGN_PLAYLIST_COPY_ERROR_MODE: 'FOREIGN_PLAYLIST_COPY_ERROR_MODE',
91+
CONFIG_SAVE_ERROR_MODE: 'CONFIG_SAVE_ERROR_MODE',
92+
THEME_MODE: 'THEME_MODE',
93+
UPDATE_NOTIFICATION_MODE: 'UPDATE_NOTIFICATION_MODE',
94+
SESSION_LOCKED_MODE: 'SESSION_LOCKED_MODE',
95+
NOT_IMPLEMENTED_YET_MODE: 'NOT_IMPLEMENTED_YET_MODE',
96+
}
97+
98+
''' When PASSIVE_WINDOWS target is one of them,
99+
also set window_mode '''
100+
MAIN_MODES = ( NORMAL_MODE, PLAYLIST_MODE, CONFIG_MODE )
101+
102+
PASSIVE_WINDOWS = {
103+
SESSION_LOCKED_MODE: NORMAL_MODE,
104+
UPDATE_NOTIFICATION_MODE: NORMAL_MODE,
105+
MAIN_HELP_MODE: NORMAL_MODE,
106+
CONFIG_HELP_MODE: CONFIG_MODE,
107+
SELECT_PLAYER_HELP_MODE: SELECT_PLAYER_MODE,
108+
SELECT_PLAYLIST_HELP_MODE: SELECT_PLAYLIST_MODE,
109+
SELECT_STATION_HELP_MODE: SELECT_STATION_MODE,
110+
PLAYLIST_RELOAD_ERROR_MODE: NORMAL_MODE,
111+
SAVE_PLAYLIST_ERROR_1_MODE: NORMAL_MODE,
112+
SAVE_PLAYLIST_ERROR_2_MODE: NORMAL_MODE,
113+
FOREIGN_PLAYLIST_MESSAGE_MODE: NORMAL_MODE,
114+
FOREIGN_PLAYLIST_COPY_ERROR_MODE: NORMAL_MODE,
115+
PLAYLIST_HELP_MODE: PLAYLIST_MODE,
116+
PLAYLIST_LOAD_ERROR_MODE: PLAYLIST_MODE,
117+
PLAYLIST_NOT_FOUND_ERROR_MODE: PLAYLIST_MODE,
118+
}
48119

49120
""" Theming constants """
50121
def FOREGROUND(): return 0

0 commit comments

Comments
 (0)