archweather / install.shmain
▤ install.sh4227 bytes
#!/usr/bin/env bash
# User-level installation. Do NOT run with sudo.
set -euo pipefail
if [[ ${EUID:-$(id -u)} -eq 0 ]]; then
echo 'Voer ./install.sh uit als normale gebruiker, niet met sudo.' >&2
exit 1
fi
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
AUTOSTART=1
START_NOW=1
for arg in "$@"; do
case "$arg" in
--autostart) AUTOSTART=1 ;;
--no-autostart) AUTOSTART=0 ;;
--no-start) START_NOW=0 ;;
*) echo 'Opties: --autostart, --no-autostart, --no-start' >&2; exit 2 ;;
esac
done
if ! command -v python >/dev/null || ! python -m venv --help >/dev/null 2>&1; then
echo 'Benodigd: sudo pacman -S --needed python python-pip' >&2
exit 1
fi
if ! command -v konsole >/dev/null; then
echo 'Konsole ontbreekt. Installeer eerst: sudo pacman -S --needed konsole' >&2
exit 1
fi
if ! python -c 'from PySide6.QtWidgets import QSystemTrayIcon' >/dev/null 2>&1; then
echo 'PySide6 ontbreekt. Installeer eerst: sudo pacman -S --needed pyside6' >&2
exit 1
fi
BASE="${XDG_DATA_HOME:-$HOME/.local/share}"
CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"
DEST="$BASE/archweather/venv"
BIN="$HOME/.local/bin"
APPS="$BASE/applications"
ICONS="$BASE/icons/hicolor/scalable/apps"
AUTODIR="$CONFIG/autostart"
mkdir -p "$BIN" "$APPS" "$ICONS" "$AUTODIR" "$(dirname "$DEST")"
# Allows venv to import PySide6 supplied by Arch pacman, not a second huge pip Qt runtime.
python -m venv --system-site-packages "$DEST"
if ! "$DEST/bin/python" -c 'from PySide6.QtWidgets import QSystemTrayIcon' >/dev/null 2>&1; then
echo 'Kan PySide6 niet in virtuele omgeving laden. Controleer pacman pyside6 en Python-versie.' >&2
exit 1
fi
"$DEST/bin/python" -m pip install --upgrade pip
"$DEST/bin/python" -m pip install --upgrade "$ROOT"
cat > "$BIN/archweather" <<EOF
#!/usr/bin/env bash
exec "$DEST/bin/archweather" "\$@"
EOF
cat > "$BIN/archweather-open" <<EOF
#!/usr/bin/env bash
exec konsole -e "$BIN/archweather" "\$@"
EOF
cat > "$BIN/archweather-tray" <<EOF
#!/usr/bin/env bash
exec "$BIN/archweather" tray "\$@"
EOF
chmod +x "$BIN/archweather" "$BIN/archweather-open" "$BIN/archweather-tray"
cp "$ROOT/archweather/icon.svg" "$ICONS/archweather.svg"
cat > "$APPS/archweather.desktop" <<EOF
[Desktop Entry]
Type=Application
Version=1.0
Name=ArchWeather Live
GenericName=Weerdashboard voor KDE Plasma
Comment=Interactief live weer met Arch Linux-terminal
Exec=$BIN/archweather-open
TryExec=$BIN/archweather-open
Icon=archweather
Terminal=false
Categories=Utility;Education;
Keywords=weather;weer;forecast;terminal;arch;plasma;kde;
StartupNotify=false
Actions=Tray;
[Desktop Action Tray]
Name=Weer in systeemvak starten
Exec=$BIN/archweather-tray
EOF
cat > "$APPS/archweather-tray.desktop" <<EOF
[Desktop Entry]
Type=Application
Version=1.0
Name=ArchWeather Live Systeemvak
Comment=KDE Plasma weerindicator op de achtergrond
Exec=$BIN/archweather-tray
TryExec=$BIN/archweather-tray
Icon=archweather
Terminal=false
OnlyShowIn=KDE;
Categories=Utility;
Keywords=weather;weer;tray;systemtray;kde;
StartupNotify=false
EOF
# Remove legacy v2 autostart to avoid opening a duplicate terminal at login.
rm -f "$AUTODIR/archweather.desktop"
if [[ "$AUTOSTART" -eq 1 ]]; then
cp "$APPS/archweather-tray.desktop" "$AUTODIR/archweather-tray.desktop"
else
rm -f "$AUTODIR/archweather-tray.desktop"
fi
if command -v kbuildsycoca6 >/dev/null; then
kbuildsycoca6 >/dev/null 2>&1 || true
fi
if [[ "$START_NOW" -eq 1 ]] && [[ -n "${DISPLAY:-}${WAYLAND_DISPLAY:-}" ]]; then
mkdir -p "${XDG_CACHE_HOME:-$HOME/.cache}/archweather"
nohup "$BIN/archweather-tray" >"${XDG_CACHE_HOME:-$HOME/.cache}/archweather/tray.log" 2>&1 </dev/null &
disown 2>/dev/null || true
fi
printf '\n✓ ArchWeather Live v2.2 KDE geïnstalleerd.\n'
printf 'Zoek "ArchWeather Live" in de KDE Application Launcher / KRunner.\n'
if [[ "$AUTOSTART" -eq 1 ]]; then
printf '✓ KDE autostart: weericoon verschijnt automatisch na aanmelden.\n'
else
printf 'KDE autostart: uitgeschakeld.\n'
fi
printf 'Klik op het systeemvakicoon voor het compacte weerpaneel; rechtsklik voor opties.\n'
printf 'Beheer autostart ook via KDE Systeeminstellingen → Autostart.\n'
printf "Tip: meld je na een upgrade één keer af en aan om de vernieuwde systeemvakapp te laden.\n"