summaryrefslogtreecommitdiff
path: root/raveos-plasma-theme/raveos-plasma-apply.sh
blob: 2e7854e2d16073fd739397bf26bf6b331f191075 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash

set -euo pipefail

PAYLOAD="/usr/share/raveos/plasma-theme/theme-data"
wallpaper_dst="/usr/share/backgrounds/raveos/raveos-main-bg.jpeg"

if [[ ! -d "$PAYLOAD" ]]; then
    echo "Hiba: hiányzó payload: $PAYLOAD" >&2
    exit 1
fi

if [[ ${EUID} -ne 0 ]]; then
    echo "Root jogosultság szükséges." >&2
    exit 1
fi

ensure_bashrc_hook() {
    local bashrc_path="$1"
    local hook_line='[[ -f /etc/profile.d/raveos-fastfetch.sh ]] && source /etc/profile.d/raveos-fastfetch.sh'
    touch "$bashrc_path"
    if ! grep -Fqx "$hook_line" "$bashrc_path" 2>/dev/null; then
        printf '\n%s\n' "$hook_line" >> "$bashrc_path"
    fi
}

disable_kmix_autostart() {
    local target_home="$1"
    mkdir -p "${target_home}/.config/autostart"
    cat > "${target_home}/.config/autostart/kmix_autostart.desktop" <<'KMEOF'
[Desktop Entry]
Hidden=true
KMEOF
}

write_konsolerc() {
    local target_home="$1"
    cat > "${target_home}/.config/konsolerc" <<'KSEOF'
[Desktop Entry]
DefaultProfile=RaveOS.profile

[General]
ConfigVersion=1

[UiSettings]
ColorScheme=RaveOS
KSEOF
}

write_kscreenlockerrc() {
    local target_home="$1"
    mkdir -p "${target_home}/.config"
    cat > "${target_home}/.config/kscreenlockerrc" <<KLEOF
[Greeter][Wallpaper][org.kde.image][General]
FillMode=2
Image=file://${wallpaper_dst}
KLEOF
}

write_ksplashrc() {
    local target_home="$1"
    mkdir -p "${target_home}/.config"
    cat > "${target_home}/.config/ksplashrc" <<'SPLEOF'
[KSplash]
Engine=KSplashQML
Theme=org.kde.raveos.desktop
SPLEOF
}

write_kdeglobals() {
    local target_home="$1"
    mkdir -p "${target_home}/.config"
    cat > "${target_home}/.config/kdeglobals" <<'GLBEOF'
[General]
ColorScheme=BreezeDark

[Icons]
Theme=breeze-dark

[KDE]
widgetStyle=Breeze
GLBEOF
}

# skel konfiguráció új felhasználóknak
mkdir -p \
    /etc/skel/.config/kitty \
    /etc/skel/.config/fastfetch \
    /etc/skel/.config/autostart \
    /etc/skel/.config/raveos \
    /etc/skel/.local/share/konsole

[[ -f "${PAYLOAD}/background" ]] && \
    install -Dm644 "${PAYLOAD}/background" /etc/skel/.config/background

[[ -f "${PAYLOAD}/kitty/kitty.conf" ]] && \
    install -Dm644 "${PAYLOAD}/kitty/kitty.conf" /etc/skel/.config/kitty/kitty.conf

for f in config.jsonc config-kitty.jsonc raveos-logo.png raveos-logo.txt; do
    [[ -f "${PAYLOAD}/fastfetch/${f}" ]] && \
        install -Dm644 "${PAYLOAD}/fastfetch/${f}" "/etc/skel/.config/fastfetch/${f}"
done

[[ -f "${PAYLOAD}/konsole/RaveOS.colorscheme" ]] && \
    install -Dm644 "${PAYLOAD}/konsole/RaveOS.colorscheme" /etc/skel/.local/share/konsole/RaveOS.colorscheme
[[ -f "${PAYLOAD}/konsole/RaveOS.profile" ]] && \
    install -Dm644 "${PAYLOAD}/konsole/RaveOS.profile" /etc/skel/.local/share/konsole/RaveOS.profile

write_konsolerc /etc/skel
write_kscreenlockerrc /etc/skel
write_ksplashrc /etc/skel
write_kdeglobals /etc/skel
disable_kmix_autostart /etc/skel
ensure_bashrc_hook /etc/skel/.bashrc
echo "1" > /etc/skel/.config/raveos/plasma-migrated

# meglévő felhasználók frissítése
while IFS=: read -r user _ uid gid _ home shell; do
    [[ "$uid" -ge 1000 ]] || continue
    [[ -d "$home" ]] || continue
    [[ "$shell" != "/usr/bin/nologin" && "$shell" != "/bin/false" ]] || continue

    mkdir -p \
        "${home}/.config/kitty" \
        "${home}/.config/fastfetch" \
        "${home}/.config/autostart" \
        "${home}/.config/raveos" \
        "${home}/.local/share/konsole"

    if [[ ! -f "${home}/.config/kitty/kitty.conf" && -f "${PAYLOAD}/kitty/kitty.conf" ]]; then
        install -Dm644 "${PAYLOAD}/kitty/kitty.conf" "${home}/.config/kitty/kitty.conf"
    fi

    for f in config.jsonc config-kitty.jsonc raveos-logo.png raveos-logo.txt; do
        if [[ ! -f "${home}/.config/fastfetch/${f}" && -f "${PAYLOAD}/fastfetch/${f}" ]]; then
            install -Dm644 "${PAYLOAD}/fastfetch/${f}" "${home}/.config/fastfetch/${f}"
        fi
    done

    if [[ ! -f "${home}/.local/share/konsole/RaveOS.colorscheme" && -f "${PAYLOAD}/konsole/RaveOS.colorscheme" ]]; then
        install -Dm644 "${PAYLOAD}/konsole/RaveOS.colorscheme" "${home}/.local/share/konsole/RaveOS.colorscheme"
    fi

    if [[ ! -f "${home}/.local/share/konsole/RaveOS.profile" && -f "${PAYLOAD}/konsole/RaveOS.profile" ]]; then
        install -Dm644 "${PAYLOAD}/konsole/RaveOS.profile" "${home}/.local/share/konsole/RaveOS.profile"
    fi

    if [[ ! -f "${home}/.config/konsolerc" ]]; then
        write_konsolerc "${home}"
    fi

    if [[ ! -f "${home}/.config/autostart/kmix_autostart.desktop" ]]; then
        disable_kmix_autostart "${home}"
    fi

    ensure_bashrc_hook "${home}/.bashrc"
    echo "1" > "${home}/.config/raveos/plasma-migrated"

    chown "${uid}:${gid}" "${home}/.config" "${home}/.local" 2>/dev/null || true
    chown -R "${uid}:${gid}" \
        "${home}/.config/kitty" \
        "${home}/.config/fastfetch" \
        "${home}/.config/autostart" \
        "${home}/.config/raveos" \
        "${home}/.local/share/konsole" \
        "${home}/.bashrc" 2>/dev/null || true

done < /etc/passwd

echo "RaveOS Plasma beállítás sikeresen alkalmazva."