aboutsummaryrefslogtreecommitdiff
path: root/programs/cwal/components/labwc.sh
blob: 183f6eb2479ea14455695d1f415b325126295dad (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
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
# Copyright (C) 2026 deltegui
# SPDX-License-Identifier: GPL-3.0-or-later

set -euo pipefail

component_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
source "$component_dir/common.sh"

CWAL_COMPONENT=labwc
export CWAL_COMPONENT

template="$CWAL_TEMPLATES_DIR/labwc.themerc"
destination="$HOME/.config/labwc/themerc-override"

case ${1:-} in
detect)
    component_available labwc "$destination"
    ;;
prepare)
    require_readable 'Labwc template' "$template"
    require_destination_directory Labwc "$destination"
    ;;
generate)
    component_render theme "$destination" "$template"
    ;;
validate)
    temporary=$(component_temp_path theme)
    if grep -Fq '${' "$temporary"; then
        printf 'apply-theme: unresolved template placeholder in Labwc theme\n' >&2
        exit 1
    fi
    ;;
install)
    component_install theme "$destination"
    ;;
reload)
    reload_status=not\ reloaded
    if [[ ${LABWC_PID:-} =~ ^[0-9]+$ ]] && kill -0 "$LABWC_PID" 2>/dev/null; then
        if labwc --reconfigure >/dev/null 2>&1; then
            reload_status=reloaded
        else
            printf 'apply-theme: could not reload Labwc\n' >&2
            reload_status=reload\ failed
        fi
    fi
    component_set_status reload "$reload_status"
    ;;
summary)
    printf '  Labwc:  %s (%s)\n' "$destination" "$(component_get_status reload)"
    ;;
*)
    printf 'Usage: %s {detect|prepare|generate|validate|install|reload|summary}\n' \
        "${0##*/}" >&2
    exit 2
    ;;
esac