Created
January 23, 2022 19:39
-
-
Save rasschaert/96f4f79e4fbd8c0d895d3230f3094d7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ "$EUID" -ne 0 ]]; then | |
echo "ERROR: Please run this script as root." >&2 | |
exit 1 | |
fi | |
export DEBIAN_FRONTEND=noninteractive | |
export DEBCONF_NONINTERACTIVE_SEEN=true | |
# Get latest metadata from mirrors. | |
apt update | |
# Install the prefered display manager for KDE. | |
apt install -y sddm | |
# Normally it would interactively prompt you via an ncurses ui to select the default display manager... but this is a script. | |
echo "/usr/bin/sddm" > /etc/X11/default-display-manager | |
dpkg-reconfigure sddm | |
echo "set shared/default-x-display-manager sddm" | debconf-communicate | |
# Install the KDE meta package for Parrot OS, and the KDE Config Module for SDDM. | |
apt install -y parrot-kde kde-config-sddm | |
# Remove the MATE metapackage. | |
apt purge -y --auto-remove mate-desktop | |
# Automatic login | |
mkdir -p /etc/sddm.conf.d | |
cat <<- "EOF" >/etc/sddm.conf.d/autologin.conf | |
[Autologin] | |
User=user | |
Session=plasma | |
EOF | |
# Test if we're running inside a KVM/QEMU VM. If so, install the appropriate guest stuff. | |
if dmidecode | grep -q "Manufacturer: QEMU"; then | |
# Get the spice and QEMU guest stuff. | |
apt install -y spice-vdagent qemu-guest-agent | |
# Remove the Virtualbox guest stuff. | |
apt purge -y virtualbox-guest-x11 virtualbox-guest-utils | |
# Auto-resizing doesn't work at the moment, without giving it a little push. | |
# The VM window (spice) resize event is seen by udev, so register a script that needs to run when it happens. | |
# REMEMBER TO ENABLE AUTO-RESIZE IN VIRT-MANAGER: VIEW-> SCALE DISPLAY -> AUTO RESIZE VM WITH WINDOW | |
echo 'ACTION=="change", KERNEL=="card0", SUBSYSTEM=="drm", RUN+="/usr/local/bin/x-resize"' > /etc/udev/rules.d/50-x-resize.rules | |
# Create the script that tells xrandr to do the right thing. | |
cat <<- "EOF" >/usr/local/bin/x-resize | |
#!/bin/sh | |
PATH=/usr/bin | |
desktopuser=$(/bin/ps -ef | /bin/grep -oP '^\w+ (?=.*vdagent( |$))') || exit 0 | |
export DISPLAY=:0 | |
export XAUTHORITY=$(eval echo "~$desktopuser")/.Xauthority | |
xrandr --output $(xrandr | awk '/ connected/{print $1; exit; }') --auto | |
EOF | |
# Make the script executable. | |
chmod +x /usr/local/bin/x-resize | |
fi | |
# Install latest things. | |
apt dist-upgrade -y | |
# Remove unwanted things. | |
apt autoremove -y | |
# Clean up default junk from the desktop. | |
rm -f /home/user/Desktop/{PASSWORD.txt,README.license} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment