#!/bin/sh
#
# live-budgie: budgie-specific setup for livesys
# SPDX-License-Identifier: GPL-3.0-or-later
#

# disable gnome-software automatically downloading updates
cat >> /usr/share/glib-2.0/schemas/org.gnome.software.gschema.override << FOE
[org.gnome.software]
allow-updates=false
download-updates=false
FOE

# don't autostart gnome-software session service
rm -f /etc/xdg/autostart/org.gnome.Software.desktop

# make the installer show up
if [ -f /usr/share/applications/liveinst.desktop ]; then
  # Show harddisk install in Budgie Menu
  sed -i -e 's/NoDisplay=true/NoDisplay=false/' /usr/share/applications/liveinst.desktop
  # show up on budgie desktop view
  mkdir /home/liveuser/Desktop
  cp /usr/share/applications/liveinst.desktop /home/liveuser/Desktop
  chmod +x /home/liveuser/Desktop/liveinst.desktop

  cat >> /usr/share/glib-2.0/schemas/com.solus-project.icon-tasklist.gschema.override << FOE
[com.solus-project.icon-tasklist]
pinned-launchers=['liveinst.desktop', 'nemo.desktop', 'org.mozilla.firefox.desktop', 'org.gnome.Rhythmbox3.desktop', 'org.gnome.Software.desktop', 'org.xfce.Parole.desktop']
FOE

  cat >> /usr/share/glib-2.0/schemas/org.buddiesofbudgie.budgie-desktop-view.gschema.override << FOE
[org.buddiesofbudgie.budgie-desktop-view]
show=true
show-home-folder=false
FOE

  # Copy Anaconda branding in place
  if [ -d /usr/share/lorax/product/usr/share/anaconda ]; then
    cp -a /usr/share/lorax/product/* /
  fi
fi

# set up lightdm autologin
sed -i 's/^#autologin-user=.*/autologin-user=liveuser/' /etc/lightdm/lightdm.conf
sed -i 's/^#autologin-user-timeout=.*/autologin-user-timeout=0/' /etc/lightdm/lightdm.conf

# set Budgie as default session, otherwise login will fail
sed -i 's/^#user-session=.*/user-session=budgie-desktop/' /etc/lightdm/lightdm.conf

# rebuild schema cache with any overrides we installed
glib-compile-schemas /usr/share/glib-2.0/schemas

# Turn off PackageKit-command-not-found while uninstalled
if [ -f /etc/PackageKit/CommandNotFound.conf ]; then
  sed -i -e 's/^SoftwareSourceSearch=true/SoftwareSourceSearch=false/' /etc/PackageKit/CommandNotFound.conf
fi
