summarylogtreecommitdiffstats
path: root/linuxmix.install
blob: c31fe98170687c7c34279d8de6f98bdf2e855542 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
ss_vendor_id=1038

post_install() {
    # Reload udev rules
    sudo udevadm control --reload-rules
    sudo udevadm trigger

    # Refresh Systemd
    echo Reloading systemd daemon for real users...
    for U in $(ls /home); do
        sudo usermod -aG audio $U
	    systemctl -M "$U@.host" --user daemon-reload
	    systemctl -M "$U@.host" --user enable --now linuxmix
        
        # Create blacklist file
        mkdir "/home/$U/.config/linuxmix"
        echo "# Enter the node name for each device you wish to blacklist" >> "/home/$U/.config/linuxmix/blacklist.conf"
        echo "# This can be retrieved by entering 'pw-cli ls Node', and searching for the corresponding 'node.name'" >> "/home/$U/.config/linuxmix/blacklist.conf"
        echo "# NOTE: Not all Nodes may correspond to an audio sink, but you should be able to tell." >> "/home/$U/.config/linuxmix/blacklist.conf"
        echo "# If there comes a situation where you *cannot* tell which node corresponds to which device, please open an issue and I'll try to create an alternative" >> "/home/$U/.config/linuxmix/blacklist.conf"
    done
}

post_upgrade() {
    echo Restarting service...
    for U in $(ls /home); do
        systemctl -M "$U@.host" --user daemon-reload
        systemctl -M "$U@.host" --user restart linuxmix
    done
}

post_remove() {
    # Refresh Systemd
    echo Reloading systemd daemon for real users...
    for U in $(ls /home); do
        T_UID=$(id -u $U)

        # Clean-up audio sinks
        sudo -u $U XDG_RUNTIME_DIR="/run/user/$T_UID" pactl unload-module module-loopback
        sudo -u $U XDG_RUNTIME_DIR="/run/user/$T_UID" pw-cli destroy Game
        sudo -u $U XDG_RUNTIME_DIR="/run/user/$T_UID" pw-cli destroy Chat

	    systemctl -M "$U@.host" --user disable --now linuxmix
	    systemctl -M "$U@.host" --user daemon-reload
    done
}