Skip to content

Commit c85d25f

Browse files
committed
- detecting forced XDG compliance will not alter the configuration
file, just check for XDG_DATA_HOME and XDG_STATE_HOME - fixing typos
1 parent 84d3abb commit c85d25f

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

devel/fix_pyradio_desktop_file

+9-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ the terminal \"my_term\" is \"-S\", execute as follows:
4646
}
4747

4848
function get_data_dir(){
49+
local CHK_XDG_DATA_DIR
50+
local CHK_XDG_STATE_DIR
4951
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
5052
CFG_FILE=$(dirname $"$SCRIPT_DIR")"/pyradio/config"
5153
if [ -e "$CFG_FILE" ]
@@ -54,14 +56,18 @@ function get_data_dir(){
5456
fi
5557
if [ -z "$XDG" ]
5658
then
57-
XDG="$(sed 's/[A-Z]/\l&/' "${XDG_CONFIG_HOME-"$HOME"/.config}"/pyradio/config | grep 'xdg_compliant = true')"
59+
CHK_XDG_DATA_DIR=${XDG_DATA_HOME-"$HOME"/.local/share/pyradio}
60+
CHK_XDG_STATE_DIR=${XDG_DATA_HOME-"$HOME"/.local/state/pyradio}
61+
if [ -e ${CHK_XDG_DATA_DIR} ] && [ -e "${CHK_XDG_STATE_DIR}" ]
62+
then
63+
XDG=true
64+
fi
5865
fi
5966
if [ -z "$XDG" ]
6067
then
6168
DATA_DIR=~/.config/pyradio/data
6269
else
63-
DATA_DIR="$XDG_DATA_HOME"
64-
[ -z "$DATA_DIR" ] && DATA_DIR=~/.local/share/pyradio
70+
DATA_DIR="${XDG_DATA_HOME-"$HOME"/.local/share/pyradio}"
6571
fi
6672
mkdir -p "$DATA_DIR" 2>/dev/null
6773
}

pyradio/config.py

-9
Original file line numberDiff line numberDiff line change
@@ -2362,15 +2362,6 @@ def _read_config(self, distro_config=False):
23622362
self.xdg_compliant = True
23632363
self.need_to_fix_desktop_file_icon = True
23642364

2365-
if self.need_to_fix_desktop_file_icon and \
2366-
not distro_config and \
2367-
not xdg_compliant_read_from_file:
2368-
with open(file_to_read, 'a', encoding='utf-8') as f:
2369-
f.write('\n')
2370-
f.write('# Both XDG_DATA_HOME and XDG_STATE_HOME exist\n')
2371-
f.write('# This will only be read by fix_pyradio_desktop_file\n')
2372-
f.write('xdg_compliant = True')
2373-
23742365
def _make_sure_dirs_exist(self):
23752366
if self.opts['recording_dir'][1] == '':
23762367
self.opts['recording_dir'][1] = path.join(path.expanduser('~'), 'pyradio-recordings')

pyradio/config_window.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class PyRadioConfigWindow(object):
5252
_help_text = []
5353
_help_text.append(None)
5454
_help_text.append(['Specify the player to use with PyRadio, or the player detection order.', '|',
55-
'This is the eqivelant to the -u , --use-player command line option.', '|',
55+
'This is the equivalent to the -u , --use-player command line option.', '|',
5656
'Example:', ' player = vlc', 'or', ' player = vlc,mpv, mplayer', '|',
5757
'Default value: mpv,mplayer,vlc'])
58-
_help_text.append([r'If this option is enabled, the last local playlist loaded before terminating, will be automatically opened the next time PyRadio is executed. Furthermore, playback will resume, if it was on when PyRadio exited. Otherwise, station selection will be restored.', '|', 'This option will take precedence over the "Def. playlist" configuration option and the "-s" command line option.', '|', 'It can also be toggled on the fly by perssing \l while on Main mode.', '|', 'Default value: False'])
58+
_help_text.append([r'If this option is enabled, the last local playlist loaded before terminating, will be automatically opened the next time PyRadio is executed. Furthermore, playback will resume, if it was on when PyRadio exited. Otherwise, station selection will be restored.', '|', 'This option will take precedence over the "Def. playlist" configuration option and the "-s" command line option.', '|', 'It can also be toggled on the fly by pressing \l while on Main mode.', '|', 'Default value: False'])
5959
_help_text.append(['This is the playlist to open at start up, if none is specified and "Open last playlist" is not set.', '|',
6060
'This is the equivalent to the -s, --stations command line option.', '|',
6161
'Default value: stations'])
@@ -87,7 +87,7 @@ class PyRadioConfigWindow(object):
8787
_help_text.append(['This option will work when a theme\'s transparency value is set to 2 (Obey config setting), the default. Otherwise, it\'s up to the theme to handle transparency.', '|', 'If False, theme colors will be used.', '|',
8888
"If True and a compositor is running, the stations' window background will be transparent.", '|', "If True and a compositor is not running, the terminal's background color will be used.", '|', 'Default value: False'])
8989
_help_text.append(['This option, when enabled, will make all themes behave as if their transparency setting was set to 2 (Obey config setting), in which case the windows\'s transparency will depend entirely on the value of the "Use transparency" setting (the option above this one).', '|', 'Default value: False'])
90-
_help_text.append(['Pyradio can calculate and use an alternative color for secondary windows.', '|', 'This option will determine if this color will be used (value > 0) or not (value = 0), provided that the theme used does not already provide it.', '|', 'The value of this option is actually the factor to darken or lighten the main (stations) background color.', '|', 'You can get more info on this at https://github.com/coderholic/pyradio#secondary-windows-background', '|', 'Valid Values: 0-0.2', 'Default value: 0'])
90+
_help_text.append(['Pyradio can calculate and use an alternative color for secondary windows.', '|', 'This option will determine if this color will be used (value > 0) or not (value = 0), provided that the theme used does not already provide it.', '|', 'The value of this option is actually the factor to darken or lighten the main (stations) background color.', '|', 'Valid Values: 0-0.2', 'Default value: 0'])
9191
_help_text.append(['The console theme is the one used when PyRadio is executed either from the Linux Virtual Console or the terminal used does not support color changes.', '|', 'This change will take effect after PyRadio is restarted.', '|', 'Default value: dark'])
9292
_help_text.append(None)
9393
_help_text.append(['Specify whether you will be asked to confirm every station deletion action.',
@@ -99,9 +99,9 @@ class PyRadioConfigWindow(object):
9999
_help_text.append(['This is the IP for the Remote Control Server.', '|', 'Available options:', '- localhost : PyRadio will be accessible from within the current system only.', '- lan : PyRadio will be accessible from any computer in the local network.', '- IP : In case the system has more than one interfaces.', '|', 'Use "Space", "Enter", "l/Right" to change the value.','|', 'Default value: localhost'])
100100
_help_text.append(
101101
['This is the port used by the Remote Control Server (the port the server is listening to).', '|', 'Please make sure that a "free" port is specified here, to avoid any conflicts with existing services and daemons.', '|', 'If an invalid port number is inserted, the cursor will not move to another field.', '|', 'Valid values: 1025-65535', 'Default value: 9998'])
102-
_help_text.append(['If set to True, the Server wiil be automatically started when PyRadio starts.', r'If set to False, one can start the Server using the "\s" command from the Main program window.', '|', 'Default value: False'])
102+
_help_text.append(['If set to True, the Server will be automatically started when PyRadio starts.', '|', r'If set to False, one can start the Server using the "\s" command from the Main program window.', '|', 'Default value: False'])
103103
_help_text.append(None)
104-
_help_text.append(['This options will open the configuration window for the RadioBrowser Online Stations Directory.', '|', "In order to use RadioBrowser, python's requests module must be installed."])
104+
_help_text.append(['This options will open the configuration window for the RadioBrowser Online Stations Directory.',])
105105

106106
_config_options = None
107107

pyradio/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def shell():
389389
import subprocess
390390
r = None
391391
script = None
392-
#script = '/home/spiros/projects/my-gits/pyradio/devel/fix_pyradio_desktop_file'
392+
# script = '/home/spiros/projects/my-gits/pyradio/devel/fix_pyradio_desktop_file'
393393
if script is None:
394394
try:
395395
from urllib.request import urlretrieve

0 commit comments

Comments
 (0)