Skip to content

Instantly share code, notes, and snippets.

@HackingGate
Last active June 3, 2025 01:00
Show Gist options
  • Save HackingGate/67f40f1c64c227b2991cc6bc64f9a14c to your computer and use it in GitHub Desktop.
Save HackingGate/67f40f1c64c227b2991cc6bc64f9a14c to your computer and use it in GitHub Desktop.
My Fedora Desktop Setup
#!/bin/bash
set -e
set -o pipefail
# Set system timezone to Tokyo, Japan
sudo timedatectl set-timezone Asia/Tokyo
# Configure hardware clock to use UTC (recommended for Linux)
sudo timedatectl set-local-rtc 0
# Display current time and date settings
timedatectl
# Reference to guide for making Windows 11 use UTC for hardware clock (for dual-boot systems)
# https://gist.github.com/HackingGate/180aafbc6342ad4b1cb31309fa83c91a
# Install essential development tools and utilities
sudo dnf check-update -y
sudo dnf upgrade --refresh
sudo dnf install emacs-nox vim neovim curl wget gh git zsh efibootmgr jq fastfetch htop -y
sudo dnf group install development-tools -y
# Setup git global configuration
git config --global user.name "HackingGate"
git config --global user.email "[email protected]"
git config --global core.editor "emacs"
git config --global init.defaultBranch main
git config --global gpg.format ssh
git config --global commit.gpgSign true
git config --global submodule.recurse true
# Install Oh My Zsh for better terminal experience
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Install Homebrew package manager for Linux
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo >> ~/.zshrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> ~/.zshrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew install gcc
# Install Brave browser from official repository
sudo dnf install dnf-plugins-core -y
sudo dnf config-manager addrepo --from-repofile=https://brave-browser-rpm-release.s3.brave.com/brave-browser.repo
sudo dnf install brave-browser -y
# Debloat Brave browser by disabling certain features
sudo mkdir -p /etc/brave/policies/managed/ && sudo chmod 755 /etc/brave/policies/managed/
sudo tee /etc/brave/policies/managed/00_debloat.json > /dev/null << 'EOF'
{
"TorDisabled": true,
"BraveRewardsDisabled": true,
"BraveWalletDisabled": true,
"BraveVPNDisabled": true,
"BraveAIChatEnabled": false
}
EOF
# Update Flatpak packages
sudo flatpak update -y
# Install GNOME Extensions utility
sudo flatpak install flathub org.gnome.Extensions -y
# Install Thunderbird email client
sudo flatpak install flathub org.mozilla.Thunderbird -y
# Set Firefox as the default web browser
xdg-settings set default-web-browser org.mozilla.firefox.desktop
# Configure Emacs as the default text editor
echo '
# Set default editor to Emacs
export EDITOR="/usr/bin/emacs"
export VISUAL="/usr/bin/emacs"
' >> ~/.zshrc
# Install 1Password password manager and CLI
sudo rpm --import https://downloads.1password.com/linux/keys/1password.asc
sudo tee /etc/yum.repos.d/1password.repo << 'EOF'
[1password]
name=1Password Stable Channel
baseurl=https://downloads.1password.com/linux/rpm/stable/$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://downloads.1password.com/linux/keys/1password.asc
EOF
sudo dnf check-update -y
sudo dnf install 1password-cli 1password -y
op --version
# Auto start 1Password for GNOME Shell
mkdir -p ~/.config/autostart
cat > ~/.config/autostart/1password.desktop << 'EOF'
[Desktop Entry]
Name=1Password
Exec=/usr/bin/1password --silent %U
Terminal=false
Type=Application
Icon=1password
StartupWMClass=1Password
Comment=Password manager and secure wallet
MimeType=x-scheme-handler/onepassword;
Categories=Office;
EOF
chmod +x ~/.config/autostart/1password.desktop
echo "1Password autostart configured"
# Install Tailscale for secure networking
curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up
# Install and configure Starship prompt
brew install starship
echo 'eval "$(starship init zsh)"' >> ~/.zshrc
# Install Fira Code monospace font
sudo dnf install fira-code-fonts -y
# Install essential fonts including CJK support
sudo dnf install google-noto-fonts-all google-noto-color-emoji-fonts google-noto-sans-cjk-fonts --allowerasing -y
# Install regine-specific glyph variants for CJK fonts
sudo dnf install \
adobe-source-han-sans-cn-fonts \
adobe-source-han-sans-tw-fonts \
adobe-source-han-serif-cn-fonts \
adobe-source-han-serif-tw-fonts -y
sudo dnf install wqy-zenhei-fonts wqy-microhei-fonts -y
fc-cache -fv
# Update system with latest kernel packages
sudo dnf upgrade -y
# Update firmware using fwupd
sudo fwupdmgr refresh
sudo fwupdmgr update
echo "Driver updates completed for kernel $(uname -r)"
# # Install rEFInd boot manager with secure boot support
# sudo dnf install rEFInd -y
# sudo dnf install shim-signed sbsign -y
# sudo refind-install --shim /boot/efi/EFI/fedora/shimx64.efi --localkeys
# # Configure rEFInd boot timeout
# echo "Configuring rEFInd timeout to 5 seconds..."
# if sudo [ -f /boot/efi/EFI/refind/refind.conf ]; then
# CURRENT_TIMEOUT=$(sudo grep -oP 'timeout \K[0-9]+' /boot/efi/EFI/refind/refind.conf)
# sudo sed -i 's/timeout [0-9]\+/timeout 5/' /boot/efi/EFI/refind/refind.conf
# if [ -n "$CURRENT_TIMEOUT" ]; then
# echo "rEFInd timeout changed from $CURRENT_TIMEOUT to 5 seconds"
# else
# echo "rEFInd timeout set to 5 seconds"
# fi
# else
# echo "Warning: rEFInd config not found at /boot/efi/EFI/refind/refind.conf"
# fi
# Configure GRUB boot timeout
echo "Configuring GRUB timeout to 1 second..."
if [ -f /etc/default/grub ]; then
sudo sed -i 's/GRUB_TIMEOUT=[0-9]*/GRUB_TIMEOUT=1/' /etc/default/grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
echo "GRUB timeout set to 1 second"
else
echo "Warning: /etc/default/grub not found"
fi
# Enable Emacs keybindings across GTK applications
gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"
# Enable Emacs daemon for better performance for current user (no sudo required)
systemctl --user enable --now emacs
# Install Spacemacs for Emacs
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
# Configure Caps Lock as Ctrl key
echo "Setting Caps Lock to function as Ctrl..."
current_options=$(gsettings get org.gnome.desktop.input-sources xkb-options)
if [[ $current_options == "@as []" ]]; then
# No existing options
gsettings set org.gnome.desktop.input-sources xkb-options "['ctrl:nocaps']"
else
# Append to existing options, removing surrounding brackets first
current_options=${current_options:5:-1}
gsettings set org.gnome.desktop.input-sources xkb-options "[$current_options, 'ctrl:nocaps']"
fi
# Install Refine for GNOME customization
sudo flatpak install page.tesk.Refine -y
# Install GNOME Tweaks for additional system settings
sudo dnf install gnome-tweaks -y
# Install pipx for isolated Python application installation
sudo dnf install pipx -y
pipx ensurepath
source ~/.zshrc
# Install GNOME Extensions CLI tool
pipx install gnome-extensions-cli --system-site-packages
# Install useful GNOME Shell extensions
gext install [email protected]
gext install [email protected]
gext install [email protected]
gext install customreboot@nova1545
# Disable GNOME Shell hot corners feature
gsettings set org.gnome.desktop.interface enable-hot-corners false
# Disable tap-to-click for touchpad
gsettings set org.gnome.desktop.peripherals.touchpad tap-to-click false
# Install Qt-to-GNOME style bridge
sudo dnf install adwaita-qt5 qgnomeplatform-qt5 adwaita-qt6 qgnomeplatform-qt6 -y
# Install fcitx5 input method framework for better CJK input support
# fcitx5-table-extra provides 倉頡、鄭碼、行列、輕鬆、嘸蝦米輸入法、速成、五筆、筆順五碼、粵語拼音、廣東拼音、港式廣東話、吳語注音
# Reference: https://chakra-zh.blogspot.com/2015/10/fcitx-chinese-input-on-chakra-linux.html
sudo dnf install fcitx5 fcitx5-chewing fcitx5-mozc fcitx5-table-extra -y
# Configure fcitx5 to start automatically
sudo dnf install fcitx5-autostart -y
# Install KDE Input Method Panel extension
gext install [email protected]
# Install GJS On-Screen Keyboard
gext install [email protected]
# Configure automatic LUKS disk decryption using TPM2
sudo systemd-cryptenroll /dev/nvme0n1p3 \
--wipe-slot=tpm2 \
--tpm2-device=auto
# Update crypttab for TPM2 auto-decryption at boot
echo "Updating /etc/crypttab for TPM2 automatic decryption..."
if [ -f /etc/crypttab ]; then
# Create a backup of the original file
sudo cp /etc/crypttab /etc/crypttab.backup
# Use sed to replace existing options with TPM2 settings for LUKS entries
sudo sed -i -E '/^luks-/s/none[[:space:]]+[^[:space:]]*$/none luks,tpm2-device=auto,tries=1,timeout=0s/' /etc/crypttab
echo "Updated /etc/crypttab successfully. Original backed up to /etc/crypttab.backup"
echo "Current crypttab configuration:"
sudo cat /etc/crypttab
# Regenerate initramfs to apply changes
echo "Regenerating initramfs to apply crypttab settings..."
sudo dracut -fv --regenerate-all
else
echo "Warning: /etc/crypttab not found. LUKS configuration may not be present on this system."
fi
# Update GRUB configuration to reflect changes
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
# Shrink /dev/nvme0n1p3 partition to 70% with LUKS and btrfs filesystem using live environment
# Ensure the btrfs filesystem usses smaller size than the size you want to shrink to
sudo btrfs filesystem resize 100G /run/media/liveuser/fedora
sudo parted /dev/nvme0n1 --script resizepart 3 70%
sudo cryptsetup luksOpen /dev/nvme0n1p3 luksroot
sudo cryptsetup resize luksroot
# Resize the btrfs filesystem to take up the new partition size
sudo btrfs filesystem resize max /run/media/liveuser/fedora
# Install Visual Studio Code
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo tee /etc/yum.repos.d/vscode.repo > /dev/null << 'EOF'
[code]
name=Visual Studio Code
baseurl=https://packages.microsoft.com/yumrepos/vscode
enabled=1
autorefresh=1
type=rpm-md
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc
EOF
sudo dnf check-update
sudo dnf install code # or code-insiders
# Set Visual Studio Code as the default editor for text files
xdg-mime default code.desktop text/plain
# Install JetBrains Toolbox
sudo dnf install -y jq fuse fuse-libs
# Create target directory if it doesn't exist
mkdir -p "${HOME}/.local/bin"
# Ensure .local/bin is in PATH
if [[ ":$PATH:" != *":$HOME/.local/bin:"* ]]; then
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
export PATH="$HOME/.local/bin:$PATH"
echo "Added ~/.local/bin to PATH"
fi
# Store download URL in a variable
TOOLBOX_URL=$(curl -s 'https://data.services.jetbrains.com/products/releases?code=TBA&latest=true&type=release' | jq -r '.TBA[0].downloads.linux.link')
# Download with progress bar and extract with quoted wildcard pattern
curl -L# "$TOOLBOX_URL" | tar xzvf - -C "${HOME}/.local/bin" --strip-components=1 --wildcards '*/jetbrains-toolbox'
# Make the binary executable
chmod +x "${HOME}/.local/bin/jetbrains-toolbox"
echo "JetBrains Toolbox installed to ${HOME}/.local/bin/jetbrains-toolbox"
# Install Waydroid to run Android apps on Wayland
sudo dnf install waydroid -y
sudo systemctl enable --now waydroid-container
# Initialize Waydroid
sudo waydroid init
# Install Xournal++ for note-taking
sudo flatpak install com.github.xournalpp.xournalpp
# Install Wacom drivers for drawing tablets
sudo dnf install xorg-x11-drv-wacom -y
# Install Docker Engine
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager addrepo --from-repofile=https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
# Start and enable Docker service
sudo systemctl enable --now docker
# Add current user to docker group
sudo usermod -aG docker "$USER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment