#!/usr/bin/env bash

# Add repository configuration with signing key
cat <<-EOF | sudo tee /etc/apt/sources.list-available/phosh-nightly.source
Types: deb
URIs: http://deb.phosh.mobi/nightly/
Suites: trixie-nightly
Components: main
Signed-By:
  -----BEGIN PGP PUBLIC KEY BLOCK-----
 
  mQINBGXoHOYBEAC/893ifemxPCa3l+46Vtpjiew4Eu+c3kXEj6sEOQZS8+ZvJ93O
  So3cEe7tqPM8AjqPjO6GsBjqr86swk5bbZ70GIqo1H2p9JdBaiQWqTDXxXRDvel5
  0SaxbUQvLm880pjS/gcsBezRv8vb9dxDsPMzap6GuJnF5QqagfOX8B1aQKCywJNo
  QoFc3RL7c3j2hLRpI4kdfcjo2j3GtjKb+ojWja9dng/gsMlrHYEqS+aWg+eVFnLM
  XkwJXS/4AQjooH9qC+swtVNYYzt7wQdCm1mNFfrXDHSLse0ugyESqZ8AN5d9bUlB
  fAae7xv/lV3QfozSolFODvXlBjNaCDYb1r8Rag01eM83b1Wv/R23enFO18p/UW9k
  +/wk+kOqUfEd+0NBkXdRQiCrvwxHs51IqMFH5aAhM9lHmaHYmdPjETdeYPeKlA22
  CYLCkApEazGNPZGt6Kv7XeBwiI+6DScbHxr+j9S/j9+7BuMs6MItE4J9EtavkFtr
  aw/ijGsifCKJWpkD28uZ3h83qi8diUwRde0zrX4SJAUi/T2UXPywep1z6bQ70Vaf
  YrciSOndw5zWiTYMUDl6q7iZR6vloiZMoGf7psLx1y0Vg4Sq8DPldXAMpaNPh8+Z
  UhqD94pBGg+iVaYII8MeWHaqtHc0ewQAKAq121rulOuZgaRbl/5LuQp8rQARAQAB
  tD1QaG9zaCBEZWJpYW4gUGFja2FnZXMgKEFyY2hpdmUgU2lnbmluZyBLZXkpIDxk
  ZWJzQHBob3NoLm1vYmk+iQJUBBMBCgA+AhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4B
  AheAFiEEeHJPmfZ/wlY1lpbHLf0ViOUfQ7IFAmXoV34FCQlmPBgACgkQLf0ViOUf
  Q7JWNxAApMQeEKSto6LGZkdqoKXCZgaXg//2UeAnkhK9+Z1hZ2Do7RYhoOW994yi
  FqtZ92WVMqzbK0EqfEnFX8yVzM1cXo3PgouCDCgTy060YmH0OV2XxThr8fJ4uZfW
  vib9HE+W4o/dgoMSy3BlPtpB1y/gevgJGoHAtQbV6Ex4bRL89i8pOQJYPYRx5Xj0
  4SADUWWjOnY9AZbykUlMuRFSOMBWITn8yqUCYPpw8bGbtFignfvK1iRcW5LIkrtY
  XsOlQCK5+ttNAMUkCeI93LGYhSZUqbpt87tdkbCP5qfV7o7Vkv8iObKw8fxKh2o1
  oijY8S6ZqEl/CZjDtKcdvsQrEvY3Z1KX0xUNn01PFrHGzRiTn7eieXF4O3PCM2zJ
  1TGva0gliKUgdN4y8W6Ul1H74T3rhZWpNO10rotfnvyX6AP/bLlkdMdSpL85mcqt
  PfSROQGcKOU6WmF1G2MvwzBY6sjP3IN95qqnaBKa1IJGBPFt5IsY8eoqdNuNkeRT
  W3OFcBQas+1RQdDzOZ7svJIX9fNBubebtnB20mRYIwESkhQMO2VpjyrBPzUP+bum
  kg/7Lx/Gr+OdH2SzNfeTr+28foyKExf2wdhbICErm+eRq1Bh4dFe6ljN/YBUVdEq
  MHjCZ4GQaiw5Uq+5sQTUWYkFeb/j3NeRadmSTshinPgTISGNYBo=
  =lIij
  -----END PGP PUBLIC KEY BLOCK-----
EOF

# Create symbolic link to enable the repository
sudo ln -sf /etc/apt/sources.list-available/phosh-nightly.source \
	/etc/apt/sources.list.d/phosh-nightly.source

# Update package lists
sudo apt update

# phosh-osk-stevia phosh.osk-stub

# Define packages to install
PACKAGES=(
    phoc                    # Wayland compositor
    phosh                   # Main shell
    phosh-wallpapers        # Wallpapers
    phosh-mobile-settings   # Settings application
    phrog                   # Image viewer
    squeekboard            # On-screen keyboard
    xdg-desktop-portal-phosh # Desktop portal
    chatty                  # Chat application
    cellbroadcastd         # Cell broadcast receiver
    feedbackd              # Haptic feedback daemon
    feedbackd-device-themes # Feedback themes
    gnome-calls            # Phone call application
    gnome-clocks           # Clock application
    gnome-screenshot       # Screenshot utility
)

# Install packages from nightly repository
sudo apt-get install -y -t trixie-nightly ${PACKAGES}

# Undo with:
# for PACKAGE in ${PACKAGES}; do
#   apt-get install -y ${PACKAGE}/trixie
# done
