Merge lp:~johndrinkwater/anoise/xdg-support into lp:anoise

Proposed by John Drinkwater
Status: Needs review
Proposed branch: lp:~johndrinkwater/anoise/xdg-support
Merge into: lp:anoise
Diff against target: 54 lines (+10/-2)
2 files modified
anoise/preferences.py (+2/-1)
anoise/utils.py (+8/-1)
To merge this branch: bzr merge lp:~johndrinkwater/anoise/xdg-support
Reviewer Review Type Date Requested Status
costales Pending
Review via email: mp+351348@code.launchpad.net

Commit message

Use the xdg package to discover current XDG paths

Patches support for custom $XDG_CONFIG_HOME locations, while also falling back to ~/.config/
Adds new variable Noise.DATA_DIR, this adds support for the path $XDG_DATA_HOME/anoise/ to host further audio files.
Corrected support for writing autostart files to the user’s autostart location.

To post a comment you must log in.

Unmerged revisions

57. By John Drinkwater

Use the xdg package to discover current XDG paths

Patches support for custom $XDG_CONFIG_HOME locations, while also falling back
to ~/.config/
Adds new variable Noise.DATA_DIR, this adds support for the path
$XDG_DATA_HOME/anoise/ to host further audio files.
Corrected support for writing autostart files to the user’s autostart location.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'anoise/preferences.py'
2--- anoise/preferences.py 2017-06-20 20:48:37 +0000
3+++ anoise/preferences.py 2018-07-26 12:29:04 +0000
4@@ -17,6 +17,7 @@
5 # for more information.
6
7 import gi, os, shutil, webbrowser, subprocess
8+from xdg import BaseDirectory
9 from datetime import datetime, timedelta
10 gi.require_version('Gtk', '3.0')
11 gi.require_version('WebKit', '3.0')
12@@ -30,7 +31,7 @@
13 class Preferences:
14 """This will be for DE as MATE 14.10+ which hasn't sound indicator with Gtk3"""
15 def __init__(self, player):
16- self.AUTOSTART = os.path.join(os.getenv('HOME'), '.config', 'autostart', 'anoise.desktop')
17+ self.AUTOSTART = os.path.join(BaseDirectory.xdg_config_home, 'autostart', 'anoise.desktop')
18 self.DESKTOP = '/usr/share/applications/anoise.desktop'
19
20 self.player = player
21
22=== modified file 'anoise/utils.py'
23--- anoise/utils.py 2017-06-20 20:48:37 +0000
24+++ anoise/utils.py 2018-07-26 12:29:04 +0000
25@@ -17,6 +17,7 @@
26 # for more information.
27
28 import os, glob, sys, socket, operator
29+from xdg import BaseDirectory
30 # i18n
31 import gettext
32 gettext.textdomain('anoise')
33@@ -43,7 +44,8 @@
34 class Noise:
35 """Manage access to noises"""
36 def __init__(self):
37- self.CFG_DIR = os.path.join(os.getenv('HOME'), '.config', 'anoise')
38+ self.CFG_DIR = os.path.join(BaseDirectory.xdg_config_home, 'anoise')
39+ self.DATA_DIR = os.path.join(BaseDirectory.xdg_data_home, 'anoise')
40 self.CFG_FILE = os.path.join(self.CFG_DIR, 'anoise.cfg')
41 if not os.path.exists(self.CFG_DIR):
42 try:
43@@ -65,6 +67,11 @@
44 if sound[-4:].lower() in '.ogg.mp3.wav':
45 all_files.append(sound)
46 # Local
47+ sound_files = os.path.join(self.DATA_DIR, '*.*')
48+ available_sounds = glob.glob(sound_files)
49+ for sound in available_sounds:
50+ if sound[-4:].lower() in '.ogg.mp3.wav':
51+ all_files.append(sound)
52 sound_files = os.path.join(os.getenv('HOME'), 'ANoise', '*.*')
53 available_sounds = glob.glob(sound_files)
54 for sound in available_sounds:

Subscribers

People subscribed via source and target branches

to all changes: