aboutsummaryrefslogtreecommitdiff
path: root/programs/cwal/components/dwm.sh
blob: 10627476f9443454ddc102f8acd905b1038d3bff (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
#!/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=dwm
export CWAL_COMPONENT

template="$CWAL_TEMPLATES_DIR/dwm.h"
destination="$HOME/.config/dwm/config.h"

case ${1:-} in
detect)
    component_available dwm "$destination"
    ;;
prepare)
    require_readable 'dwm template' "$template"
    require_destination_directory dwm "$destination"
    ;;
generate)
    component_render config "$destination" "$template"
    ;;
validate)
    # dwm's config.h can only be compiled inside a dwm source tree.
    [[ -s $(component_temp_path config) ]]
    ;;
install)
    component_install config "$destination"
    ;;
reload)
    ;;
summary)
    printf '  dwm:    %s (rebuild dwm to apply)\n' "$destination"
    ;;
*)
    printf 'Usage: %s {detect|prepare|generate|validate|install|reload|summary}\n' \
        "${0##*/}" >&2
    exit 2
    ;;
esac