summarylogtreecommitdiffstats
path: root/hypryou.install
blob: fe90527f88d1cbc6acecb87a0ee1891f97081663 (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
post_install() {
    echo ":: Updating font cache..."
    fc-cache -f > /dev/null
    echo ":: Enabling NetworkManager service"
    sudo systemctl enable NetworkManager
    echo ":: Reboot your pc!"
}

post_upgrade() {
    echo ":: Removing styles cache for all users"
    for user_home in /home/*; do
        if [ -d "$user_home/.cache/hypryou" ]; then
            rm -f "$user_home/.cache/hypryou/style.css"
        fi
    done

    echo ":: Trying to reload hypryou and hyprland"
    users=$(ps -C Hyprland -o user= 2>/dev/null | sort -u)
    users+=" $(ps -C hyprland -o user= 2>/dev/null | sort -u)"
    users=$(echo "$users" | xargs -n1 | sort -u)

    for user in $users; do
        json=$(sudo -u "$user" hyprctl instances -j 2>/dev/null)
        if jq empty >/dev/null 2>&1 <<<"$json"; then
            instances=$(jq -r '.[].instance' <<<"$json" 2>/dev/null)
            for inst in $instances; do
                sudo -u "$user" hyprctl --instance "$inst" reload >/dev/null 2>&1 || true
                sudo -u "$user" hyprctl --instance "$inst" dispatch exec hypryouctl reload >/dev/null 2>&1 || true
            done
        fi
    done
    echo ":: Updating font cache..."
    fc-cache -f > /dev/null
}

post_remove() {
    echo ":: Updating font cache..."
    fc-cache -f > /dev/null
}