Last active
March 24, 2022 11:54
-
-
Save tech-otaku/25ad16394106085d46d88abb7a4203c4 to your computer and use it in GitHub Desktop.
Ubuntu Desktop Configuration on MacBook Pro
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
#!/usr/bin/env bash | |
# Note: LOGIN SCREEN SCALE (200%), LOGIN SCREEN SIZE (1152x864) and DISPLAY SCALE (200%) below are dependant on | |
# Virtual Machine > Settings > Display > 'Use full resolution for Retina display' in VMware Fusion being checked | |
# (gui.fitGuestUsingNativeDisplayResolution = "TRUE" in .vmx file) | |
# Get the installed Ubuntu version e.g. 20, 18, 16 etc. | |
VERSION=$(lsb_release -r | awk '{print $2}' | cut -d '.' -f 1) | |
# Get the installed GNOME Desktop version | |
GD_MAJOR=$(cat /usr/share/gnome/gnome-version.xml | sed -n 's/^.*<platform>//p' | sed -n 's/<\/platform>//p') | |
GD_MINOR=$(cat /usr/share/gnome/gnome-version.xml | sed -n 's/^.*<minor>//p' | sed -n 's/<\/minor>//p') | |
GD_MICRO=$(cat /usr/share/gnome/gnome-version.xml | sed -n 's/^.*<micro>//p' | sed -n 's/<\/micro>//p') | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# AUTHENTICATION AS ROOT | |
# | |
# Ask for the administrator password upfront | |
sudo -v | |
# Keep-alive: update existing `sudo` time stamp until `userconf.sh` has finished | |
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null & | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# FORCE DISPLAY OF GRUB MENU AT BOOT | |
# | |
# SOURCE: https://askubuntu.com/a/1078723 | |
# | |
# GRUB_TIMEOUT_STYLE=menu | |
# GRUB_HIDDEN_TIMEOUT= | |
# GRUB_TIMEOUT=5 | |
#sudo sed -i 's/GRUB_TIMEOUT_STYLE=hidden/GRUB_TIMEOUT_STYLE=menu\nGRUB_HIDDEN_TIMEOUT=/g' /etc/default/grub | |
#sudo sed -i 's/GRUB_TIMEOUT=0/GRUB_TIMEOUT=5/g' /etc/default/grub | |
#sudo update-grub | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SET LOGIN SCREEN SCALE (200%) | |
# | |
# SOURCE: https://askubuntu.com/a/1126769 | |
#sudo tee /usr/share/glib-2.0/schemas/93_hidpi.gschema.override <<EOF | |
#[org.gnome.desktop.interface] | |
#scaling-factor=2 | |
#text-scaling-factor=0.9 | |
#EOF | |
#sudo glib-compile-schemas /usr/share/glib-2.0/schemas | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SET LOGIN SCREEN SIZE (1152x864) | |
# | |
# SOURCE: https://askubuntu.com/a/1041697 and https://askubuntu.com/a/54068 | |
# | |
# #GRUB_GFXMODE=640x480 | |
# GRUB_GFXMODE=1152x864x32 | |
# GRUB_GFXPAYLOAD_LINUX=keep | |
# #GRUB_CMDLINE_LINUX_DEFAULT="nomodeset" | |
#sudo sed -i 's/#GRUB_GFXMODE=640x480/#GRUB_GFXMODE=640x480\nGRUB_GFXMODE=1152x864x32\nGRUB_GFXPAYLOAD_LINUX=keep\n#GRUB_CMDLINE_LINUX_DEFAULT="nomodeset"/g' /etc/default/grub | |
#sudo update-grub | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SET DISPLAY SCALE (200%) | |
# | |
# SOURCE: https://ubuntuforums.org/showthread.php?t=2384128&p=13736478#post13736478 | |
#gsettings set org.gnome.desktop.interface scaling-factor 2 | |
#dconf write /org/gnome/desktop/interface/scaling-factor "uint32 2" | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# DISPLAY | |
# | |
# | |
# Disable Automatic Brightness | |
gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false | |
#dconf write /org/gnome/settings-daemon/plugins/power/ambient-enabled | |
# Set Brightness | |
echo 100 | sudo tee /sys/class/backlight/intel_backlight/brightness | |
# Disable automatic screen lock | |
gsettings set org.gnome.desktop.screensaver lock-enabled false | |
#dconf write /org/gnome/desktop/screensaver/lock-enabled false | |
# Enable automatic screen lock | |
#gsettings set org.gnome.desktop.screensaver lock-enabled true | |
#dconf write /org/gnome/desktop/screensaver/lock-enabled true | |
# Lock screen after 30 minutes | |
#gsettings set org.gnome.desktop.screensaver lock-delay 1800 | |
#dconf write /org/gnome/desktop/screensaver/lock-delay "uint32 1800" # Unsigned 32-bit integer | |
# Blank screen after 1 minute (60 seconds) | |
gsettings set org.gnome.desktop.session idle-delay 60 | |
#dconf write /org/gnome/desktop/session/idle-delay "uint32 60" # Unsigned 32-bit integer | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# DESKTOP ICONS | |
# | |
# | |
# Hide Trash Folder | |
gsettings set org.gnome.shell.extensions.desktop-icons show-trash false | |
#dconf write /org/gnome/shell/extensions/desktop-icons/show-trash false | |
# Hide Home Folder | |
gsettings set org.gnome.shell.extensions.desktop-icons show-home false | |
#dconf write /org/gnome/shell/extensions/desktop-icons/show-home false | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SET VOLUME | |
# | |
# | |
amixer cset iface=MIXER,name="Master Playback Volume" 25 >/dev/null | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SOFTWARE UPDATE | |
# | |
# | |
# Software Updater > Settings & Livepatch > Updates > Automatically check for updates: | |
# Never | |
sudo sed -r -i 's/(Update-Package-Lists).*;/\1 "0";/' /etc/apt/apt.conf.d/20auto-upgrades | |
# Do not display a notification when updates are available. | |
gsettings set com.ubuntu.update-notifier no-show-notifications true | |
#dconf write /com/ubuntu/update-notifier/no-show-notifications true | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# EDIT USER'S .BASHRC | |
# | |
# | |
tee -a ~/.bashrc <<EOF | |
# Set keyboard model and layout | |
#setxkbmap -model apple -layout gb | |
# Message to display for each new Terminal window | |
printf "Use right-alt-3 for # character\n\n" | |
EOF | |
tee -a ~/.bashrc <<EOF | |
alias update='sudo -- sh -c "apt update; apt upgrade -y; apt dist-upgrade -y; apt autoremove -y; apt autoclean -y"; if [ -f /var/run/reboot-required ]; then echo -e "\n* * * REBOOT REQUIRED * * *\n"; else echo -e "\n* * * No reboot required * * *\n"; fi' | |
EOF | |
#gsettings set org.gnome.desktop.input-sources sources "[('xkb', 'gb'), ('xkb', 'gb+mac')]" | |
#dconf write /org/gnome/desktop/input-sources/sources "[('xkb', 'gb'), ('xkb', 'gb+mac')]" | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# FILES APP CONFIGURATION | |
# | |
# | |
# Show hidden files | |
gsettings set org.gtk.Settings.FileChooser show-hidden true | |
#dconf write /org/gtk/settings/file-chooser/show-hidden true # Note difference in case and schema name compared to gsettings | |
# Set default to 'List' view | |
gsettings set org.gnome.nautilus.preferences default-folder-viewer list-view | |
#dconf write /org/gnome/nautilus/preferences/default-folder-viewer "'list-view'" | |
# Limit 'List' view columns | |
gsettings set org.gnome.nautilus.list-view default-visible-columns "['name', 'size', 'date_modified']" | |
#dconf write /org/gnome/nautilus/list-view/default-visible-columns "['name', 'size', 'date_modified']" | |
# Use Tree view | |
gsettings set org.gnome.nautilus.list-view use-tree-view true | |
#dconf write /org/gnome/nautilus/list-view/use-tree-view true | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# MOUSE | |
# | |
# | |
# Mouse scroll direction | |
gsettings set org.gnome.desktop.peripherals.mouse natural-scroll false | |
#dconf write /org/gnome/desktop/peripherals/mouse/natural-scroll false | |
# Mouse pointer speed | |
gsettings set org.gnome.desktop.peripherals.mouse speed -0.75 | |
#dconf write /org/gnome/desktop/peripherals/mouse/speed -0.75 | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# KEYBOARD SHORTCUTS | |
# | |
# | |
# Change keyboard shortcut to open Terminal | |
#if [ $VERSION -ge 20 ]; then | |
# option-command-t on macOS | |
# gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "['<Alt><Super>t']" | |
#dconf write /org/gnome/settings-daemon/plugins/media-keys/terminal "['<Alt><Super>t']" | |
# control-option-t on macOS. Conflicts with Magnet's 'Right Two Thirds' option | |
#gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "['<Primary><Alt>t']" | |
#dconf write /org/gnome/settings-daemon/plugins/media-keys/terminal "['<Primary><Alt>t']" | |
#else | |
# option-command-t on macOS | |
# gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "'<Alt><Super>t'" | |
#dconf write /org/gnome/settings-daemon/plugins/media-keys/terminal "'<Alt><Super>t'" | |
# control-option-t on macOS. Conflicts with Magnet's 'Right Two Thirds' option | |
#gsettings set org.gnome.settings-daemon.plugins.media-keys terminal "'<Primary><Alt>t'" | |
#dconf write /org/gnome/settings-daemon/plugins/media-keys/terminal "'<Primary><Alt>t'" | |
#fi | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# DOCK CONFIGURATION | |
# | |
# Since 18.04 LTS the default Desktop environment is GNOME 3 (GNOME 40 | |
# starting with 21.10) whose dash has been transformed in to a dock by | |
# a fork of the 'dash-to-dock' GNOME Shell extension named 'ubuntu-dock'. | |
# 'gnome-extensions list' shows this as '[email protected]'. A good | |
# explanation of the differences between dash and dock can be found at | |
# https://askubuntu.com/a/1332625 | |
gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false # Centres the Dock | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/extend-height false | |
gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/dock-position "'BOTTOM'" | |
gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED # Default value | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/transparency-mode "'FIXED'" | |
gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 48 # Signed 32-bit integer. Default value | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/dash-max-icon-size "48" | |
gsettings set org.gnome.shell.extensions.dash-to-dock dock-fixed false # Autohide the Dock | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/dock-fixed false | |
if [ $GD_MAJOR -lt 40 ]; then | |
# Setting this appears to cause issues with GNOME 40 and Ubuntu 21.10 where only the Applications Overview grid is displayed in the dock and may also result in crashing the GNOME shell. | |
gsettings set org.gnome.shell.extensions.dash-to-dock unity-backlit-items true | |
#dconf write /org/gnome/shell/extensions/dash-to-dock/unity-backlit-items true | |
fi | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# COPY HOST SSH CONFIGURATION TO GUEST OS | |
# | |
# | |
# Mount shared host folders | |
#sudo mkdir /mnt/hgfs | |
#sudo vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other -o uid=1000 | |
# Copy host's SSH configuration | |
#[ ! -d /home/$USER/.ssh ] && mkdir /home/$USER/.ssh | |
#cp -r /mnt/hgfs/.ssh/ids /home/$USER/.ssh/ids | |
#tee /home/$USER/.ssh/config <<EOF | |
# http://www.kelvinwong.ca/2011/03/30/multiple-ssh-private-keys-identityfile/ | |
#IdentityFile ~/.ssh/ids/%h/%r/id_ed25519 | |
#EOF | |
#sudo vmware-toolbox-cmd script shutdown enable | |
#sudo vmware-toolbox-cmd script shutdown set /etc/vmware-tools/poweroff-custom.sh | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# FONTS | |
# | |
# | |
# Download and install 'Source Code Pro' | |
pushd /tmp | |
wget https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip | |
unzip 1.050R-it.zip | |
FONTPATH="${XDG_DATA_HOME:-$HOME/.local/share}"/fonts | |
mkdir -p $FONTPATH | |
cp source-code-pro-*-it/OTF/*.otf $FONTPATH | |
fc-cache -f -v | |
popd | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# INSTALL PACKAGES | |
# | |
# | |
sudo apt update | |
# Chromium | |
if [ $VERSION -ge 20 ]; then | |
# installs '/var/lib/snapd/desktop/applications/chromium_chromium.desktop' | |
sudo snap install chromium | |
else | |
# installs '/usr/share/applications/chromium-browser.desktop' | |
sudo apt install -y chromium-browser | |
fi | |
# Dconf Editor | |
sudo apt install -y dconf-editor | |
# numlockx | |
sudo apt install -y numlockx | |
# Samba | |
sudo apt install -y samba | |
# OpenSSH Server | |
sudo apt install -y openssh-server | |
# Thunderbird | |
sudo snap install thunderbird | |
# VS Codium | |
sudo snap install codium --classic | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# CONFIGURE FAVORITES | |
# | |
# | |
if [ $VERSION -ge 20 ]; then | |
CHROMIUM="'chromium_chromium.desktop'" | |
SWUPDATE="'snap-store_ubuntu-software.desktop'" | |
else | |
CHROMIUM="'chromium-browser.desktop'" | |
SWUPDATE="'org.gnome.Software.desktop'" | |
fi | |
gsettings set org.gnome.shell favorite-apps "['org.gnome.Terminal.desktop', $CHROMIUM, 'codium_codium.desktop', 'thunderbird_thunderbird.desktop', 'org.gnome.Nautilus.desktop', 'update-manager.desktop', $SWUPDATE, 'gnome-control-center.desktop', 'yelp.desktop']" | |
#dconf write /org/gnome/shell/favorite-apps "['org.gnome.Terminal.desktop', $CHROMIUM, 'codium_codium.desktop', 'thunderbird_thunderbird.desktop', 'org.gnome.Nautilus.desktop', 'update-manager.desktop', $SWUPDATE, 'gnome-control-center.desktop', 'yelp.desktop']" | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# TERMINAL CONFIGURATION | |
# | |
# | |
# Get the default Terminal profile | |
PROFILE=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d "'") | |
#PROFILE=$(dconf list /org/gnome/terminal/legacy/profiles:/ | tr -d ":/" | grep "\S" | head -n 1) | |
# Set the default Terminal profile name | |
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE/ visible-name 'My Default' | |
#dconf write /org/gnome/terminal/legacy/profiles:/:$PROFILE/visible-name "'My Default'" | |
# Set the default Terminal font | |
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE/ font 'Source Code Pro 11' | |
#dconf write /org/gnome/terminal/legacy/profiles:/:$PROFILE/font "'Source Code Pro 12'" | |
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE/ use-system-font false | |
#dconf write /org/gnome/terminal/legacy/profiles:/:$PROFILE/use-system-font false | |
# Set the default size for new Terminal windows | |
# The default is 80 cols x 24 rows (80 cols * 0.3 = 24 rows) | |
# Columns | |
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE/ default-size-columns 90 # Signed 32-bit integer | |
#dconf write /org/gnome/terminal/legacy/profiles:/:$PROFILE/default-size-columns "90" # Signed 32-bit integer | |
# Rows (90 cols * 0.3 = 27 rows ) | |
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE/ default-size-rows 27 # Signed 32-bit integer | |
#dconf write /org/gnome/terminal/legacy/profiles:/:$PROFILE/default-size-rows "27" # Signed 32-bit integer | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# NUM LOCK | |
# | |
# | |
[ ! -d $HOME/.config/autostart ] && mkdir $HOME/.config/autostart | |
tee -a $HOME/.config/autostart/numlock.desktop <<EOF | |
[Desktop Entry] | |
Name=Numlockx | |
Exec=numlockx on | |
Type=Application | |
Comment[en_GB]=Turn Num Lock on | |
Comment=Turn Num Lock on | |
EOF | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# FIREWALL | |
# | |
# | |
sudo ufw enable | |
# Allow SSH connections from any other device on the same network | |
sudo ufw allow from 192.168.1.0/24 to any port ssh | |
# Allow Samba connections from any other device on the same network | |
sudo ufw allow from 192.168.1.0/24 to any port 139 | |
sudo ufw allow from 192.168.1.0/24 to any port 445 | |
# Allow VNC connections from any other device on the same network | |
sudo ufw allow from 192.168.1.0/24 to any port 5900 | |
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # | |
# SAMBA | |
# | |
# | |
sudo tee -a /etc/samba/smb.conf <<EOF | |
[Ubuntu MacBook]] | |
comment = Samba on Linux | |
path = /home/steve | |
read only = no | |
# guest ok = yes | |
browsable = yes | |
EOF | |
sudo systemctl restart smbd | |
sudo smbpasswd -a steve | |
clear | |
read -p "Press enter to restart" | |
shutdown -r now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment