aboutsummaryrefslogtreecommitdiff
path: root/.local/bin/font-cache-refresh
blob: 6e448b8894025817709ba517d38e4b3720c168d4 (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
#!/bin/sh

send_notification() {
    if command -v notify-send >/dev/null 2>&1; then
        notify-send -t 10000 "$1" "$2"
    fi
}

send_critical_notification() {
    if command -v notify-send >/dev/null 2>&1; then
        notify-send -u critical -t 10000 "$1" "$2"
    fi
}

if ! command -v fc-cache >/dev/null 2>&1; then
    send_critical_notification "Font Cache Error" "fc-cache command not found."
    exit 1
fi

if ! command -v pkexec >/dev/null 2>&1; then
    send_critical_notification "Font Cache Error" "pkexec command not found."
    exit 1
fi

if pkexec fc-cache -rfv; then
    send_notification "Font Cache Refresh" "Successfully refreshed font cache for root user"
else
    send_critical_notification "Font Cache Error" "Failed to refresh font cache for root user"
    exit 1
fi

if fc-cache -rfv; then
    send_notification "Font Cache Refresh" "Successfully refreshed font cache for current user"
else
    send_critical_notification "Font Cache Error" "Failed to refresh font cache for current user"
    exit 1
fi