summaryrefslogtreecommitdiffstats
path: root/.local/bin/pacify-pulseaudio
blob: 18d6ee5dd13d4382ac2ae4ada9ccec248ed6a808 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/sh

# Copyright (c) 2024 Amin Bandali <bandali@kelar.org>
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without any warranty.

# pulseaudio is trash and insists on using machine-id as a prefix for
# its database filenames under ~/.config/pulse.  So, on systems with
# randomized machine-ids like Devuan GNU/Linux it shits the bed and
# can't find its own database files.  So we do its job for it and
# rename its database files on each boot.  Ditto for libcanberra's
# event sound cache database.

cur_id_path=/var/lib/dbus/machine-id
prev_id_path="$XDG_CACHE_HOME/tmp-prevmid"
cur_id="$(cat $cur_id_path)"
prev_id="$(cat $prev_id_path)"

for f in $XDG_CONFIG_HOME/pulse/$prev_id-* \
             $XDG_CACHE_HOME/event-sound-cache.tdb.$prev_id.*; do
    fnew="$(echo $f | sed "s/$prev_id/$cur_id/")"
    mv $f $fnew
done

cp -p $cur_id_path $prev_id_path