@dotpi/tools 1.3.3 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorbackup/NOTES.md~ +974 -0
- package/.editorbackup/PIPEWIRE.md~ +42 -0
- package/.editorbackup/README.md~ +335 -0
- package/BACKUP-SANDO.command +61 -0
- package/BACKUP-SISIDO.command +61 -0
- package/NOTES.md +41 -1
- package/README.md +3 -13
- package/dotpi_root/bin/dotpi +1 -0
- package/dotpi_root/bin/dotpi_prepare_sd_card +34 -22
- package/dotpi_root/bin/dotpi_prepare_system +113 -68
- package/dotpi_root/bin/package.json +6 -0
- package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor.service +1 -5
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_install +21 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/dotpi_uninstall +17 -0
- package/dotpi_root/dist/@dotpi/avahi_monitor/package.json +10 -0
- package/dotpi_root/dist/@dotpi/javascript/bash.js +103 -0
- package/dotpi_root/dist/@dotpi/javascript/echo.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/filesystem.js +25 -0
- package/dotpi_root/dist/@dotpi/javascript/package.json +12 -0
- package/dotpi_root/dist/@dotpi/javascript/service.js +49 -0
- package/dotpi_root/dist/@dotpi/javascript/system.js +36 -0
- package/dotpi_root/dist/@dotpi/javascript/template.js +13 -0
- package/dotpi_root/dist/@dotpi/javascript/user.js +32 -0
- package/dotpi_root/dist/@dotpi/module/LICENSE +28 -0
- package/dotpi_root/dist/@dotpi/module/bin/dotpi_module +13 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_install +52 -0
- package/dotpi_root/dist/@dotpi/module/dotpi_uninstall +50 -0
- package/dotpi_root/dist/@dotpi/module/package.json +22 -0
- package/dotpi_root/dist/@dotpi/module/src/configuration.js +43 -0
- package/dotpi_root/dist/@dotpi/module/src/createConfig.js +108 -0
- package/dotpi_root/dist/@dotpi/module/src/definition.js +7 -0
- package/dotpi_root/dist/@dotpi/module/src/index.js +0 -0
- package/dotpi_root/dist/@dotpi/module/src/install.js +145 -0
- package/dotpi_root/dist/@dotpi/module/src/uninstall.js +180 -0
- package/dotpi_root/etc/dotpi_environment_default.bash +16 -0
- package/dotpi_root/etc/dotpi_init.d/.gitkeep +0 -0
- package/dotpi_root/etc/dotpi_modules.json +8 -0
- package/dotpi_root/lib/package.json +6 -0
- package/dotpi_root/share/dotpi_audio_bluetooth/dotpi_audio_pipewire_relink +7 -6
- package/dotpi_root/share/dotpi_audio_bluetooth/package.json +6 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_audio_device.bash +12 -26
- package/dotpi_root/share/dotpi_functions/dotpi_functions_configuration.bash +2 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_service.bash +6 -2
- package/dotpi_root/share/dotpi_functions/dotpi_functions_system.bash +11 -0
- package/dotpi_root/share/dotpi_functions/dotpi_functions_user.bash +28 -0
- package/dotpi_root/share/dotpi_functions.bash +4 -4
- package/dotpi_root/share/dotpi_init.bash +10 -1
- package/dotpi_root/share/dotpi_pipewire/bin/dotpi_pipewire_relink +86 -0
- package/dotpi_root/share/dotpi_pipewire/dotpi_install +24 -0
- package/dotpi_root/share/dotpi_pipewire/package.json +9 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire.service +22 -0
- package/dotpi_root/share/dotpi_pipewire/systemd/dotpi_pipewire_command +29 -0
- package/dotpi_root/share/limits/zzz_dotpi_audio.conf +2 -6
- package/dotpi_root/share/wireplumber/wireplumber.conf.d/dotpi-wireplumber-config.conf +8 -0
- package/lerna.json +4 -0
- package/package.json +12 -2
- package/projects/asterismes.tgz +0 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_001.bash~ +4 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_instance_002.bash~ +3 -0
- package/projects/example-bluetooth/configuration/.editorbackup/dotpi_project.bash~ +46 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_001.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_instance_002.bash +3 -0
- package/projects/example-bluetooth/configuration/dotpi_project.bash +48 -0
- package/projects/example-development/configuration/.editorbackup/dotpi_project.bash~ +59 -0
- package/projects/example-development/configuration/dotpi_instance_114.bash +4 -0
- package/projects/example-headphones/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_instance_012.bash~ +4 -0
- package/projects/example-hifiberry/configuration/.editorbackup/dotpi_project.bash~ +18 -0
- package/projects/example-network/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/led-test/.dotpi +3 -0
- package/projects/led-test/README.md +16 -0
- package/projects/led-test/dotpi_project.bash +29 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bad/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bad/.editorbackup/dotpi_project.bash~ +33 -0
- package/projects/old/bad/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bad/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bad/dotpi_project.bash +20 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/bluetooth/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/bluetooth/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/bluetooth/dotpi_project.bash +29 -0
- package/projects/old/dev.zip +0 -0
- package/projects/old/example/.editorbackup/dotpi_environment_instance.bash~ +1 -0
- package/projects/old/example/.editorbackup/dotpi_environment_project.bash~ +26 -0
- package/projects/old/example/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/.editorbackup/dotpi_tmp.bash~ +3 -0
- package/projects/old/example/.editorbackup/wpa_supplicant.conf~ +37 -0
- package/projects/old/example/configuration/.editorbackup/dotpi_project.bash~ +21 -0
- package/projects/old/example/configuration/dotpi_project.bash +21 -0
- package/projects/qsddsqsd/.dotpi +3 -0
- package/projects/qsddsqsd/README.md +16 -0
- package/projects/qsddsqsd/dotpi_project.bash +29 -0
- package/src/constants.js +4 -4
- package/src/create-project.js +124 -56
- package/src/templates/dotpi_project.bash +5 -7
- package/src/utils.js +2 -2
- package/test/create-project.test.js +0 -1
- package/dotpi_root/share/jackd/dotpi_jackd_bluetooth.bash +0 -18
- package/dotpi_root/share/jackd/dotpi_jackd_command +0 -26
- package/dotpi_root/share/jackd/dotpi_jackd_headphones.bash +0 -21
- package/dotpi_root/share/jackd/dotpi_jackd_hifiberry.bash +0 -17
- package/dotpi_root/share/jackd/jackd.service +0 -22
- /package/dotpi_root/{share/dotpi_avahi_monitor → dist/@dotpi/avahi_monitor}/dotpi_avahi_monitor_command +0 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { $ } from 'execa';
|
|
5
|
+
import { globby } from 'globby';
|
|
6
|
+
|
|
7
|
+
import * as echo from '@dotpi/javascript/echo.js';
|
|
8
|
+
|
|
9
|
+
import { dotpiConfigurationGet } from './configuration.js';
|
|
10
|
+
import { definitionGet } from './definition.js';
|
|
11
|
+
|
|
12
|
+
export async function uninstallCommandDefine({program}) {
|
|
13
|
+
program
|
|
14
|
+
.command('uninstall [modules...]')
|
|
15
|
+
.summary('uninstall a list of modules')
|
|
16
|
+
.description('Uninstall a list of modules separated by space.')
|
|
17
|
+
.option('-r, --dotpi-root <path>', 'dotpi root path, to initialise environment')
|
|
18
|
+
.option('-p, --prefix <path>', 'install modules in this directory')
|
|
19
|
+
.option('-v, --verbose [full]', 'print verbose output [full]')
|
|
20
|
+
.action((modules, options, command) => uninstall(modules, { ...options, command }));
|
|
21
|
+
;
|
|
22
|
+
return program;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function uninstallScriptRun(module, {
|
|
26
|
+
verbose = 'short',
|
|
27
|
+
} = {}) {
|
|
28
|
+
try {
|
|
29
|
+
|
|
30
|
+
const cwd = module;
|
|
31
|
+
const output = await $({
|
|
32
|
+
cwd,
|
|
33
|
+
})`npm --prefix ${cwd}
|
|
34
|
+
run --json
|
|
35
|
+
`;
|
|
36
|
+
const uninstallScript = JSON.parse(output.stdout).preuninstall;
|
|
37
|
+
|
|
38
|
+
if (uninstallScript) {
|
|
39
|
+
// npm does not automatically run preuninstall script
|
|
40
|
+
|
|
41
|
+
if(verbose !== 'none') {
|
|
42
|
+
echo.info(`Running uninstall script for ${module}`);
|
|
43
|
+
}
|
|
44
|
+
await $({
|
|
45
|
+
cwd,
|
|
46
|
+
env: { FORCE_COLOR: 'true' }, // do not remove colors
|
|
47
|
+
verbose: (verbose === 'full' ? 'full' : 'none'),
|
|
48
|
+
})`npm --prefix ${cwd}
|
|
49
|
+
run preuninstall
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return output;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
echo.error(`Failed to run uninstall script for ${module}: ${error.message}`);
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function uninstall(modules = [], {
|
|
61
|
+
dotpiRoot,
|
|
62
|
+
prefix,
|
|
63
|
+
verbose = 'short',
|
|
64
|
+
} = {}) {
|
|
65
|
+
if (typeof modules === 'string') {
|
|
66
|
+
modules = [modules];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
switch (verbose) {
|
|
70
|
+
case '0':
|
|
71
|
+
case 'false':
|
|
72
|
+
case false:
|
|
73
|
+
verbose = 'none';
|
|
74
|
+
break;
|
|
75
|
+
|
|
76
|
+
case '1':
|
|
77
|
+
case 'true':
|
|
78
|
+
case true:
|
|
79
|
+
verbose = 'short';
|
|
80
|
+
break;
|
|
81
|
+
|
|
82
|
+
case '2':
|
|
83
|
+
verbose = 'full';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
let dotpiModulesDestination;
|
|
88
|
+
let dotpiModulesConfiguration;
|
|
89
|
+
try {
|
|
90
|
+
({
|
|
91
|
+
modulesPath: dotpiModulesDestination,
|
|
92
|
+
modulesConfiguration: dotpiModulesConfiguration,
|
|
93
|
+
} = await dotpiConfigurationGet({ dotpiRoot, prefix }));
|
|
94
|
+
} catch (error) {
|
|
95
|
+
echo.error(`Failed to get dotpi configuration: ${error.message}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// no parallelisation to uninstall modules
|
|
100
|
+
let moduleToUninstall;
|
|
101
|
+
for (const module of modules) {
|
|
102
|
+
try {
|
|
103
|
+
const moduleRegistered = dotpiModulesConfiguration.moduleSource[module];
|
|
104
|
+
if (moduleRegistered) {
|
|
105
|
+
if(verbose !== 'none') {
|
|
106
|
+
echo.info(`Module '${module}' is registered as '${moduleRegistered}'`);
|
|
107
|
+
}
|
|
108
|
+
moduleToUninstall = moduleRegistered;
|
|
109
|
+
} else {
|
|
110
|
+
moduleToUninstall = module;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
let output;
|
|
114
|
+
let cwd;
|
|
115
|
+
|
|
116
|
+
if(verbose === 'full') {
|
|
117
|
+
console.log(`Getting '${moduleToUninstall}' definition`);
|
|
118
|
+
}
|
|
119
|
+
const moduleDefinition = await definitionGet(moduleToUninstall);
|
|
120
|
+
const { name: moduleName } = moduleDefinition;
|
|
121
|
+
|
|
122
|
+
// uninstall actually installed module
|
|
123
|
+
moduleToUninstall = moduleName;
|
|
124
|
+
|
|
125
|
+
if(verbose !== 'none') {
|
|
126
|
+
echo.info(`Uninstalling module '${moduleToUninstall}' in '${dotpiModulesDestination}'`);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
cwd = path.resolve(dotpiModulesDestination, 'node_modules', moduleName);
|
|
130
|
+
|
|
131
|
+
// throw error if module is not installed, caught to continue with next module
|
|
132
|
+
await fs.access(cwd);
|
|
133
|
+
|
|
134
|
+
// First, uninstall dependencies manually,
|
|
135
|
+
// as npm doest not execute {pre,post}uninstall scripts since version 7
|
|
136
|
+
|
|
137
|
+
const dependencies = await globby(
|
|
138
|
+
// globby needs a posix path
|
|
139
|
+
`${path.posix.resolve(cwd)}/**/node_modules/*`
|
|
140
|
+
);
|
|
141
|
+
for(const dependency of dependencies) {
|
|
142
|
+
try {
|
|
143
|
+
await uninstallScriptRun(dependency, { verbose });
|
|
144
|
+
} catch (error) {
|
|
145
|
+
// continue with other dependencies
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
output = await uninstallScriptRun(cwd, { verbose });
|
|
150
|
+
|
|
151
|
+
if(verbose !== 'none') {
|
|
152
|
+
echo.info(`Uninstalling ${moduleToUninstall}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
cwd = dotpiModulesDestination;
|
|
156
|
+
output = await $({
|
|
157
|
+
cwd,
|
|
158
|
+
env: { FORCE_COLOR: 'true' }, // do not remove colors
|
|
159
|
+
verbose: (verbose === 'full' ? 'full' : 'none'),
|
|
160
|
+
})`
|
|
161
|
+
npm --prefix ${cwd}
|
|
162
|
+
uninstall
|
|
163
|
+
--save
|
|
164
|
+
--
|
|
165
|
+
${moduleName}
|
|
166
|
+
`;
|
|
167
|
+
|
|
168
|
+
} catch (error) {
|
|
169
|
+
if (error.code === 'ENOENT') {
|
|
170
|
+
echo.warning(`Module ${moduleToUninstall} is not installed`);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// give up for other errors
|
|
175
|
+
echo.error(`Failed to uninstall ${moduleToUninstall}: ${error.message}`);
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
} // for (const module of modules)
|
|
180
|
+
}
|
|
@@ -66,4 +66,20 @@ dotpi_apt_install_default=(
|
|
|
66
66
|
# user-defined, use +=(package1 package2) to add packages to list
|
|
67
67
|
dotpi_apt_install=()
|
|
68
68
|
|
|
69
|
+
# system default
|
|
70
|
+
dotpi_module_uninstall_default=()
|
|
71
|
+
|
|
72
|
+
# user-defined, use +=(package1 package2) to add packages to list
|
|
73
|
+
dotpi_module_uninstall=()
|
|
74
|
+
|
|
75
|
+
# system default
|
|
76
|
+
dotpi_module_install_default=(
|
|
77
|
+
# '@dotpi/module' is already installed to bootstrap
|
|
78
|
+
# '@dotpi/manager'
|
|
79
|
+
'@dotpi/avahi_monitor'
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
# user-defined, use +=(package1 package2) to add packages to list
|
|
83
|
+
dotpi_module_install=()
|
|
84
|
+
|
|
69
85
|
dotpi_node_version='lts'
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"moduleSource": {
|
|
3
|
+
|
|
4
|
+
"_example_git": "git+https://github.com/ircam-ismm/dotpi-led#feat-dotpi-module",
|
|
5
|
+
"_example_local": "file:///opt/dotpi/dist/@dotpi/avhi_monitor",
|
|
6
|
+
"_see_npm_doc": "https://docs.npmjs.com/cli/v10/configuring-npm/package-json#dependencies"
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
#!/usr/bin/node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// @TODO: use a proper pipewire lua script that automatically runs
|
|
4
4
|
// whenever the default audio output is restored
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import util from 'node:util';
|
|
7
|
+
import child_process from 'node:child_process';
|
|
8
|
+
const exec = util.promisify(child_process.exec);
|
|
8
9
|
|
|
9
10
|
let pipewireData = null;
|
|
10
11
|
async function pipewireRelink() {
|
|
@@ -102,11 +103,11 @@ async function pipewireRelink() {
|
|
|
102
103
|
|
|
103
104
|
for(let p = 0; p < playbackNodes.length; ++p) {
|
|
104
105
|
for(let o = 0; o < outputNodes.length; ++o) {
|
|
105
|
-
playbackIndex = playbackNodes[p].id;
|
|
106
|
-
outputIndex = outputNodes[o].id;
|
|
106
|
+
const playbackIndex = playbackNodes[p].id;
|
|
107
|
+
const outputIndex = outputNodes[o].id;
|
|
107
108
|
const commandString = `pw-link ${playbackIndex} ${outputIndex}`;
|
|
108
109
|
try {
|
|
109
|
-
console.log(commandString);
|
|
110
|
+
// console.log(commandString);
|
|
110
111
|
const {stdout, stderr} = await exec(commandString);
|
|
111
112
|
// console.log('pw-link stdout:', stdout);
|
|
112
113
|
if(stderr) {
|
|
@@ -36,6 +36,18 @@ dotpi_audio_device_supported=(
|
|
|
36
36
|
'ue megaboom 3'
|
|
37
37
|
)
|
|
38
38
|
|
|
39
|
+
dotpi_audio_device_is_analog() {
|
|
40
|
+
audio_device="${1:-$dotpi_audio_device}"
|
|
41
|
+
case "$audio_device" in
|
|
42
|
+
'headphones')
|
|
43
|
+
return 0
|
|
44
|
+
;;
|
|
45
|
+
*)
|
|
46
|
+
return 1
|
|
47
|
+
;;
|
|
48
|
+
esac
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
_dotpi_audio_device_get_options() {
|
|
40
52
|
|
|
41
53
|
_echo_empty_option_error() {
|
|
@@ -284,24 +296,6 @@ dotpi_audio_device_select() (
|
|
|
284
296
|
--value \""${model_value}"\"
|
|
285
297
|
)
|
|
286
298
|
|
|
287
|
-
_dotpi_audio_device_jackd_set_configuration() (
|
|
288
|
-
model="$1"
|
|
289
|
-
(cd "${DOTPI_ROOT}/share/jackd" && ln -s -f "dotpi_jackd_${model}.bash" 'dotpi_jackd.bash') || {
|
|
290
|
-
dotpi_echo_error "Unable to change jackd configuration to ${model}"
|
|
291
|
-
return 1
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
# we can change audio device in a temporary file-system, too
|
|
295
|
-
if dotpi_system_is_raspberry_pi ; then
|
|
296
|
-
dotpi_echo_warning "Restart jackd service"
|
|
297
|
-
service='jackd'
|
|
298
|
-
systemctl is-active "$service" > /dev/null 2>&1 \
|
|
299
|
-
&& systemctl restart "$service" || {
|
|
300
|
-
dotpi_echo_warning "systemctl unable to restart service ${service}"
|
|
301
|
-
}
|
|
302
|
-
fi
|
|
303
|
-
)
|
|
304
|
-
|
|
305
299
|
_dotpi_audio_device_disable_all() (
|
|
306
300
|
exception_family="$1"
|
|
307
301
|
|
|
@@ -338,14 +332,10 @@ _dotpi_audio_device_select_headphones() (
|
|
|
338
332
|
# (setting at the end the the file fails)
|
|
339
333
|
pattern="$(dotpi_configuration_get_pattern --prefix "# dtparam=audio")"
|
|
340
334
|
perl -pe "s/${pattern}/"'dtparam=audio=on/' -i -- "$config_file"
|
|
341
|
-
|
|
342
|
-
_dotpi_audio_device_jackd_set_configuration "headphones"
|
|
343
335
|
)
|
|
344
336
|
|
|
345
337
|
_dotpi_audio_device_select_bluetooth() (
|
|
346
338
|
_dotpi_audio_device_disable_all bluetooth
|
|
347
|
-
|
|
348
|
-
_dotpi_audio_device_jackd_set_configuration "bluetooth"
|
|
349
339
|
)
|
|
350
340
|
|
|
351
341
|
_dotpi_audio_device_select_raspberry_pi() (
|
|
@@ -360,8 +350,6 @@ _dotpi_audio_device_select_raspberry_pi() (
|
|
|
360
350
|
dtoverlay=${dtoverlay}
|
|
361
351
|
|
|
362
352
|
EOF
|
|
363
|
-
|
|
364
|
-
_dotpi_audio_device_jackd_set_configuration "hifiberry"
|
|
365
353
|
)
|
|
366
354
|
|
|
367
355
|
|
|
@@ -377,8 +365,6 @@ _dotpi_audio_device_select_hifiberry() (
|
|
|
377
365
|
dtoverlay=${dtoverlay}
|
|
378
366
|
|
|
379
367
|
EOF
|
|
380
|
-
|
|
381
|
-
_dotpi_audio_device_jackd_set_configuration "hifiberry"
|
|
382
368
|
)
|
|
383
369
|
|
|
384
370
|
_dotpi_audio_device_disable_headphones() (
|
|
@@ -93,8 +93,8 @@ _dotpi_configuration_get_options() {
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
dotpi_configuration_escape_string() (
|
|
96
|
-
# escape
|
|
97
|
-
echo
|
|
96
|
+
# escape all for regexp
|
|
97
|
+
echo -n "$1" | perl -ne 'print quotemeta($_)'
|
|
98
98
|
)
|
|
99
99
|
|
|
100
100
|
dotpi_configuration_get_pattern() (
|
|
@@ -44,8 +44,10 @@ dotpi_service_install() (
|
|
|
44
44
|
ln -s -f "$(dotpi readlink_follow "${service_file}")" "${service_destination}"
|
|
45
45
|
|
|
46
46
|
if (( user_service )); then
|
|
47
|
+
regular_user_name="$(dotpi_regular_user_get_name)"
|
|
48
|
+
|
|
47
49
|
# drop sudo, with a proper session, including XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS
|
|
48
|
-
command_prefix=(systemctl --machine="${
|
|
50
|
+
command_prefix=(systemctl --machine="${regular_user_name}@")
|
|
49
51
|
else
|
|
50
52
|
command_prefix=(systemctl)
|
|
51
53
|
fi
|
|
@@ -99,8 +101,10 @@ dotpi_service_uninstall() (
|
|
|
99
101
|
rm -f "${service_destination}/${service_name}"
|
|
100
102
|
|
|
101
103
|
if (( user_service )); then
|
|
104
|
+
regular_user_name="$(dotpi_regular_user_get_name)"
|
|
105
|
+
|
|
102
106
|
# drop sudo, with a proper session, including XDG_RUNTIME_DIR and DBUS_SESSION_BUS_ADDRESS
|
|
103
|
-
command_prefix=(systemctl --machine="${
|
|
107
|
+
command_prefix=(systemctl --machine="${regular_user_name}@")
|
|
104
108
|
else
|
|
105
109
|
command_prefix=(systemctl)
|
|
106
110
|
fi
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
2
|
|
|
3
|
+
dotpi_root_get() (
|
|
4
|
+
dotpi_root="${DOTPI_ROOT}"
|
|
5
|
+
|
|
6
|
+
if [[ -z "$dotpi_root" ]] ; then
|
|
7
|
+
local_file="$(dotpi_readlink_follow "${BASH_SOURCE[0]}")"
|
|
8
|
+
dotpi_root="$(dirname -- "$(dirname -- "$local_file")")"
|
|
9
|
+
fi
|
|
10
|
+
|
|
11
|
+
echo "$dotpi_root"
|
|
12
|
+
)
|
|
13
|
+
|
|
3
14
|
# echo 'raspberry' or 'other'
|
|
4
15
|
dotpi_system_is_raspberry_pi() (
|
|
5
16
|
model='other'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
dotpi_regular_user_get_id() (
|
|
4
|
+
regular_user_id="${SUDO_UID:-1000}"
|
|
5
|
+
if (( regular_user_id == 0 )) ; then
|
|
6
|
+
regular_user_id=1000
|
|
7
|
+
fi
|
|
8
|
+
|
|
9
|
+
echo "$regular_user_id"
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
dotpi_regular_user_get_name() (
|
|
13
|
+
regular_user_id="$(dotpi_regular_user_get_id)"
|
|
14
|
+
regular_user_name="$(getent passwd "$regular_user_id" | cut -d: -f1)"
|
|
15
|
+
echo "$regular_user_name"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
dotpi_regular_user_get_gid() (
|
|
19
|
+
regular_user_id="$(dotpi_regular_user_get_id)"
|
|
20
|
+
regular_user_name="$(getent passwd "$regular_user_id" | cut -d: -f3)"
|
|
21
|
+
echo "$regular_user_name"
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
dotpi_regular_user_get_home() (
|
|
25
|
+
regular_user_id="$(dotpi_regular_user_get_id)"
|
|
26
|
+
regular_user_home="$(getent passwd "$regular_user_id" | cut -d: -f6)"
|
|
27
|
+
echo "$regular_user_home"
|
|
28
|
+
)
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
#### default functions
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
while IFS= read -r -d '' source_file ; do
|
|
6
6
|
# continue on error
|
|
7
|
-
source "$
|
|
8
|
-
done
|
|
7
|
+
source "$source_file" || true
|
|
8
|
+
done < <( find "${DOTPI_ROOT}/share/dotpi_functions" -name '*.bash' -type f -print0 )
|
|
9
9
|
|
|
10
|
-
#### dotpi-manager
|
|
11
10
|
|
|
11
|
+
# @TODO remove after migration to dotpi modules
|
|
12
12
|
# continue on error
|
|
13
13
|
dotpi_source_if_available "${DOTPI_ROOT}/share/dotpi-manager/dotpi-manager.bash" || true
|
|
14
14
|
dotpi_source_if_available "${DOTPI_ROOT}/share/dotpi-led/dotpi-led.bash" || true
|
|
@@ -13,6 +13,15 @@ _local_path="$(cd -- "$(dirname -- "${_local_file}")" && pwd)"
|
|
|
13
13
|
DOTPI_ROOT="$(cd -- "${_local_path}/.." && pwd)"
|
|
14
14
|
export DOTPI_ROOT
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
export PATH="${PATH}:${DOTPI_ROOT}/usr/bin"
|
|
17
|
+
export PATH="${PATH}:${DOTPI_ROOT}/bin"
|
|
17
18
|
|
|
19
|
+
source "${DOTPI_ROOT}/share/dotpi_functions.bash"
|
|
18
20
|
source "${DOTPI_ROOT}/share/dotpi_environment.bash"
|
|
21
|
+
|
|
22
|
+
#### installed modules
|
|
23
|
+
|
|
24
|
+
while IFS= read -r -d '' source_file ; do
|
|
25
|
+
# continue on error
|
|
26
|
+
source "$source_file" || true
|
|
27
|
+
done < <( find "${DOTPI_ROOT}/etc/dotpi_init.d" -name '*.bash' -type f -print0 )
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// @TODO: use a proper pipewire lua script that automatically runs
|
|
4
|
+
// whenever the default audio output is restored
|
|
5
|
+
|
|
6
|
+
import util from 'node:util';
|
|
7
|
+
import child_process from 'node:child_process';
|
|
8
|
+
const exec = util.promisify(child_process.exec);
|
|
9
|
+
|
|
10
|
+
let pipewireData = null;
|
|
11
|
+
async function pipewireRelink() {
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const { stdout, stderr } = await exec('pw-dump');
|
|
15
|
+
// console.log('pw-dump stdout:', stdout);
|
|
16
|
+
if(stderr) {
|
|
17
|
+
console.warn('pw-dump stderr:', stderr);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
pipewireData = JSON.parse(stdout);
|
|
21
|
+
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error('Error with pw-dump:', error.message, error);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
const playbackNodes = pipewireData.filter( (e) => {
|
|
27
|
+
return e.type === "PipeWire:Interface:Node"
|
|
28
|
+
&& e.info
|
|
29
|
+
&& e.info.props
|
|
30
|
+
&& typeof e.info.props['client.id'] !== 'undefined'
|
|
31
|
+
&& e.info.props['media.type'] === 'Audio'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (playbackNodes.length === 0) {
|
|
35
|
+
// console.warn('pipewireRelink: no playback node');
|
|
36
|
+
// no error
|
|
37
|
+
process.exit(0);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const outputNodes = pipewireData.filter( (e) => {
|
|
41
|
+
return e.type === "PipeWire:Interface:Node"
|
|
42
|
+
&& e.info
|
|
43
|
+
// && e.info['max-input-ports'] > 1
|
|
44
|
+
&& e.info.props
|
|
45
|
+
&& e.info.props['media.class'] === 'Audio/Sink';
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
if (outputNodes.length === 0) {
|
|
49
|
+
console.warn('pipewireRelink: no output node');
|
|
50
|
+
// no error
|
|
51
|
+
process.exit(0);
|
|
52
|
+
}
|
|
53
|
+
else if (outputNodes.length > 1) {
|
|
54
|
+
console.warn('pipewireRelink: multiple output nodes');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
for(let p = 0; p < playbackNodes.length; ++p) {
|
|
58
|
+
for(let o = 0; o < outputNodes.length; ++o) {
|
|
59
|
+
const playbackIndex = playbackNodes[p].id;
|
|
60
|
+
const outputIndex = outputNodes[o].id;
|
|
61
|
+
const commandString = `pw-link ${playbackIndex} ${outputIndex}`;
|
|
62
|
+
try {
|
|
63
|
+
// console.log(commandString);
|
|
64
|
+
const {stdout, stderr} = await exec(commandString);
|
|
65
|
+
// console.log('pw-link stdout:', stdout);
|
|
66
|
+
if(stderr) {
|
|
67
|
+
console.warn('pw-link stderr:', stderr);
|
|
68
|
+
}
|
|
69
|
+
} catch(error) {
|
|
70
|
+
// error when linking nodes instead of ports: ignore
|
|
71
|
+
// console.error( `Error with ${commandString}:`, error.message, error);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
process.exit(0);
|
|
78
|
+
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
pipewireRelink();
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# drop sudo privileges
|
|
4
|
+
if [[ "$USER" == "root" ]]; then
|
|
5
|
+
if [[ -n "$SUDO_USER" ]] ; then
|
|
6
|
+
user="$SUDO_USER"
|
|
7
|
+
else
|
|
8
|
+
FIRSTUSER="$(getent passwd 1000 | cut -d: -f1)"
|
|
9
|
+
user="${FIRSTUSER:-pi}"
|
|
10
|
+
fi
|
|
11
|
+
sudo -u "${user}" "$0" "$@"
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
local_file="$(dotpi readlink_follow "$0")"
|
|
15
|
+
local_path="$(dirname -- "$local_file")"
|
|
16
|
+
|
|
17
|
+
sudo dotpi service_install --user "${local_path}/systemd/dotpi_pipewire.service"
|
|
18
|
+
|
|
19
|
+
source_path="${local_path}/bin"
|
|
20
|
+
destination_path="${DOTPI_ROOT}/bin"
|
|
21
|
+
sudo mkdir -p -- "$destination_path"
|
|
22
|
+
for executable in "${source_path}/"* ; do
|
|
23
|
+
sudo ln -s -f -- "$executable" "${destination_path}/$(basename -- "$executable")"
|
|
24
|
+
done
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[Unit]
|
|
2
|
+
Description=dotpi pipewire audio daemon
|
|
3
|
+
Requires=pipewire.service
|
|
4
|
+
After=pipewire.service
|
|
5
|
+
|
|
6
|
+
# TODO: stop on system stop
|
|
7
|
+
|
|
8
|
+
[Service]
|
|
9
|
+
Type=exec
|
|
10
|
+
|
|
11
|
+
ExecStart=/opt/dotpi/share/dotpi_pipewire/systemd/dotpi_pipewire_command
|
|
12
|
+
|
|
13
|
+
Restart=always
|
|
14
|
+
|
|
15
|
+
# wait before restarting
|
|
16
|
+
RestartSec=10s
|
|
17
|
+
|
|
18
|
+
# Do not stop to try restarting service
|
|
19
|
+
StartLimitBurst=0
|
|
20
|
+
|
|
21
|
+
[Install]
|
|
22
|
+
WantedBy=pipewire.service
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
if [[ "$USER" == "root" ]] ; then
|
|
4
|
+
dotpi echo_error "This script MUST NOT be executed by root (or via sudo)"
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
|
|
8
|
+
local_file="$(dotpi readlink_follow "$0")"
|
|
9
|
+
local_path="$(dirname -- "$local_file")"
|
|
10
|
+
|
|
11
|
+
(( trial_count_max = 10 ))
|
|
12
|
+
while true ; do
|
|
13
|
+
if systemctl --user is-active "pipewire" > /dev/null 2>&1 ; then
|
|
14
|
+
(
|
|
15
|
+
(( trial_count = 0 ))
|
|
16
|
+
while (( trial_count < trial_count_max )) ; do
|
|
17
|
+
"${local_path}/../bin/dotpi_pipewire_relink" && exit 0
|
|
18
|
+
sleep 3
|
|
19
|
+
(( ++trial_count ))
|
|
20
|
+
done
|
|
21
|
+
dotpi echo_error "Failed to relink pipewire outputs ${trial_count_max} times."
|
|
22
|
+
dotpi echo_warning "Rebooting system."
|
|
23
|
+
sudo reboot
|
|
24
|
+
)
|
|
25
|
+
fi
|
|
26
|
+
sleep 10
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
# Provided by the jackd package.
|
|
2
|
-
#
|
|
3
1
|
# Changes to this file will be preserved.
|
|
4
2
|
#
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# dpkg-reconfigure -p high jackd2
|
|
3
|
+
# (Settings taken from jackd package)
|
|
8
4
|
|
|
9
5
|
@audio - rtprio 95
|
|
10
6
|
@audio - memlock unlimited
|
|
11
|
-
|
|
7
|
+
# @audio - nice -19
|
package/lerna.json
ADDED