Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afdd812f2f | ||
|
|
e2cbcb0ac4 |
@@ -84,6 +84,11 @@ b2sums=(
|
||||
'SKIP'
|
||||
)
|
||||
|
||||
prepare() {
|
||||
cd cthulhu
|
||||
git checkout testing
|
||||
}
|
||||
|
||||
pkgver() {
|
||||
cd cthulhu
|
||||
grep "^version = " src/cthulhu/cthulhuVersion.py | sed 's/version = "\(.*\)"/\1/'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
project('cthulhu',
|
||||
version: '2025.12.31-master',
|
||||
version: '2025.12.31-testing',
|
||||
meson_version: '>= 1.0.0',
|
||||
)
|
||||
|
||||
|
||||
@@ -1,7 +1,26 @@
|
||||
# Install sound theme files
|
||||
# Themes are installed to: {datadir}/cthulhu/sounds/{theme_name}/
|
||||
|
||||
install_subdir(
|
||||
'default',
|
||||
install_dir: get_option('datadir') / 'cthulhu' / 'sounds'
|
||||
# Use explicit install_data for better compatibility across Meson versions
|
||||
default_theme_sounds = files(
|
||||
'default/browse_mode.wav',
|
||||
'default/button.wav',
|
||||
'default/checkbox_checked.wav',
|
||||
'default/checkbox_mixed.wav',
|
||||
'default/checkbox_unchecked.wav',
|
||||
'default/combobox.wav',
|
||||
'default/focus_mode.wav',
|
||||
'default/radiobutton_checked.wav',
|
||||
'default/radiobutton_unchecked.wav',
|
||||
'default/start.wav',
|
||||
'default/stop.wav',
|
||||
'default/switch_off.wav',
|
||||
'default/switch_on.wav',
|
||||
'default/togglebutton_checked.wav',
|
||||
'default/togglebutton_unchecked.wav',
|
||||
)
|
||||
|
||||
install_data(
|
||||
default_theme_sounds,
|
||||
install_dir: get_option('datadir') / 'cthulhu' / 'sounds' / 'default'
|
||||
)
|
||||
|
||||
@@ -24,4 +24,4 @@
|
||||
# Cthulhu project: https://git.stormux.org/storm/cthulhu
|
||||
|
||||
version = "2025.12.31"
|
||||
codeName = "master"
|
||||
codeName = "testing"
|
||||
|
||||
@@ -99,14 +99,59 @@ class SoundThemeManager:
|
||||
self._systemSoundsDir = None
|
||||
self._userSoundsDir = None
|
||||
|
||||
def _deriveDatadirFromModulePath(self):
|
||||
"""Derive the datadir from where this module is actually installed.
|
||||
|
||||
If module is at /usr/local/lib/python3.x/site-packages/cthulhu/,
|
||||
then datadir should be /usr/local/share.
|
||||
"""
|
||||
try:
|
||||
modulePath = os.path.dirname(os.path.abspath(__file__))
|
||||
# Walk up looking for lib/python* pattern
|
||||
currentPath = modulePath
|
||||
for _ in range(10): # Limit iterations to avoid infinite loop
|
||||
parent = os.path.dirname(currentPath)
|
||||
if parent == currentPath:
|
||||
break
|
||||
dirName = os.path.basename(currentPath)
|
||||
# Check if we're in a lib directory
|
||||
if dirName == 'lib' or dirName.startswith('lib64'):
|
||||
# Parent of lib is the prefix
|
||||
prefix = parent
|
||||
datadir = os.path.join(prefix, 'share')
|
||||
if os.path.isdir(datadir):
|
||||
return datadir
|
||||
currentPath = parent
|
||||
except Exception:
|
||||
pass
|
||||
return None
|
||||
|
||||
def getSystemSoundsDir(self):
|
||||
"""Get system sounds directory from platform settings."""
|
||||
"""Get system sounds directory from platform settings.
|
||||
|
||||
First tries cthulhu_platform.datadir, then derives from module location.
|
||||
"""
|
||||
if self._systemSoundsDir is None:
|
||||
datadir = None
|
||||
|
||||
# First try the configured datadir from cthulhu_platform
|
||||
try:
|
||||
from . import cthulhu_platform
|
||||
datadir = getattr(cthulhu_platform, 'datadir', '/usr/share')
|
||||
datadir = getattr(cthulhu_platform, 'datadir', None)
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
# If datadir points to user home, it's likely wrong - try to derive it
|
||||
if datadir and (datadir.startswith(os.path.expanduser('~')) or
|
||||
'/home/' in datadir):
|
||||
derivedDatadir = self._deriveDatadirFromModulePath()
|
||||
if derivedDatadir:
|
||||
datadir = derivedDatadir
|
||||
|
||||
# Fallback to /usr/share if nothing else works
|
||||
if not datadir:
|
||||
datadir = '/usr/share'
|
||||
|
||||
self._systemSoundsDir = os.path.join(datadir, 'cthulhu', 'sounds')
|
||||
return self._systemSoundsDir
|
||||
|
||||
@@ -123,10 +168,20 @@ class SoundThemeManager:
|
||||
|
||||
Returns list of theme names (folder names) from both system and user dirs.
|
||||
User themes with same name as system themes will override system themes.
|
||||
Also checks standard fallback paths.
|
||||
"""
|
||||
themes = set()
|
||||
|
||||
for baseDir in [self.getSystemSoundsDir(), self.getUserSoundsDir()]:
|
||||
# Check configured paths plus standard fallback locations
|
||||
# /usr/share is standard, /usr/local/share is non-standard
|
||||
searchDirs = [
|
||||
self.getUserSoundsDir(),
|
||||
self.getSystemSoundsDir(),
|
||||
'/usr/share/cthulhu/sounds',
|
||||
'/usr/local/share/cthulhu/sounds',
|
||||
]
|
||||
|
||||
for baseDir in searchDirs:
|
||||
if os.path.isdir(baseDir):
|
||||
try:
|
||||
for entry in os.listdir(baseDir):
|
||||
@@ -143,15 +198,30 @@ class SoundThemeManager:
|
||||
"""Get the path to a theme directory.
|
||||
|
||||
User themes take precedence over system themes.
|
||||
Checks multiple standard locations as fallbacks.
|
||||
"""
|
||||
# Check user directory first
|
||||
userPath = os.path.join(self.getUserSoundsDir(), themeName)
|
||||
if os.path.isdir(userPath):
|
||||
return userPath
|
||||
|
||||
# Check the configured system directory
|
||||
systemPath = os.path.join(self.getSystemSoundsDir(), themeName)
|
||||
if os.path.isdir(systemPath):
|
||||
return systemPath
|
||||
|
||||
# Fallback: check standard system paths in case cthulhu_platform.datadir
|
||||
# doesn't match where sounds are actually installed
|
||||
# Check /usr/share first (standard), then /usr/local/share (non-standard)
|
||||
fallbackPaths = [
|
||||
'/usr/share/cthulhu/sounds',
|
||||
'/usr/local/share/cthulhu/sounds',
|
||||
]
|
||||
for fallbackDir in fallbackPaths:
|
||||
fallbackPath = os.path.join(fallbackDir, themeName)
|
||||
if os.path.isdir(fallbackPath):
|
||||
return fallbackPath
|
||||
|
||||
return None
|
||||
|
||||
def getSoundPath(self, themeName, soundName):
|
||||
|
||||
Reference in New Issue
Block a user