Skip to content

Instantly share code, notes, and snippets.

@piyoki
Last active July 14, 2023 04:02
Show Gist options
  • Save piyoki/0e3c2de13e7d4ef8450e56fc7077b58f to your computer and use it in GitHub Desktop.
Save piyoki/0e3c2de13e7d4ef8450e56fc7077b58f to your computer and use it in GitHub Desktop.
Some hacks around Fedora

Fedora BSPWM Setup

Softwares

  • bspwm (window manager)
  • alacritty (terminal emulator)
  • picom (graphical compositor)
  • xorg (graphic server)
  • lightdm (display manager)
  • arandr (display config management)
  • lxapperance (theme manager)
  • nitrogen (background manager)
  • polybar (status bar)
  • rofi (application launcher)
  • sxhkd (hotkey manager)
  • thunar (file manager)
  • brave (web browser)
  • microsoft-edge (web browser)
  • dunst (notification manager)
  • spectacle (screenshot tool)
  • ark (archive manager)
  • xcfe4-power-manager (power manager)
  • solaar (device manager)
  • copyq (clipboard manager)

Bootstrap

Start from Fedora Server, available at https://getfedora.org/en/server/download/

Configure Fedora source

https://mirrors.ustc.edu.cn/help/fedora.html

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo
Bootstrap dnf
# /etc/dnf/dnf.conf
max_parallel_downloads=10
fastestmirror=True
defaultyes=True
keepcache=True

sudo dnf update
Install rpmfusion

https://rpmfusion.org/Configuration

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf config-manager --set-enabled rpmfusion-free
sudo dnf config-manager --set-enabled rpmfusion-nonfree

sudo dnf groupupdate core
Install essential packages
sudo dnf install bspwm lightdm git alacritty vim dconf-editor rofi thunar thunar-archive-plugin sxhkd arandr lxappearance picom nitrogen neofetch firefox polybar dunst xclip screenshot spectacle ark xcfe4-power-manager copyq

sudo systemctl enable lightdm
sudo systemctl set-default graphical.target
Install fonts

https://github.com/ryanoasis/nerd-fonts/releases

sudo dnf install fonttosfnt fontawesome5-brands-fonts fontawesome5-free-fonts ipa-gothic-fonts material-icons-fonts
mkdir -p $HOME/.fonts && cd $HOME/.fonts
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/FiraCode.zip
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/Hack.zip
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.3.3/CascadiaCode.zip
unzip FiraCode.zip
unzip CascadiaCode.zip
unzip Hack.zip
rm -rf *.zip
fc-cache -vf

Chinese fonts

https://wiki.archlinux.org/title/Localization/Simplified_Chinese#Install_fonts

sudo dnf install adobe-source-han-sans-tw-fonts adobe-source-han-sans-cn-fonts adobe-source-han-serif-cn-fonts

Configuration

Copy default config
mkdir -p ~/.config/bspwm
mkdir -p ~/.config/sxhkd
cp /usr/share/doc/bspwm/examples/bspwmrc ~/.config/bspwm/
cp /usr/share/doc/bspwm/examples/sxhkdrc  ~/.config/sxhkd/
sudo systemctl restart lightdm
Setup autologin

https://wiki.archlinux.org/title/SDDM

# /etc/sddm.conf
# Name of session file for autologin session
Session=bspwm

# Username for autologin session
User=kev

---
# /etc/sddm.conf.d/autologin.conf
[Autologin]
User=kev
Session=bspwm

[X11]
EnableHiDPI=true
Setup screenlayouts
mkdir -p $HOME/.screenlayouts
arandr
# after arandr, save profile to $HOME/.screenlayout/default.sh, then add the following to shell
bash $HOME/.screenlayout/default.sh

Install dev-toolkit

Install compilation tools
sudo dnf install perl
sudo dnf install libdrm-devel systemd-devel pam-devel
sudo dnf install cmake ncurses-devel gcc-c++ git-delta
Install nodejs
sudo dnf install nodejs npm
# resolve root permission issue
mkdir $HOME/.npm-global
npm config set prefix '$HOME/.npm-global'
# add $HOME/.npm-global/bin to path
Install nvtop (gpu monitor)

Source: https://github.com/Syllo/nvtop#nvtop-build

sudo dnf install nvtop radeontop
Install homebrew
git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
mkdir ~/.linuxbrew/bin
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
eval $(~/.linuxbrew/bin/brew shellenv)
brew update

Post installation

Power management

Reference: https://wiki.archlinux.org/title/Display_Power_Management_Signaling

sudo dnf install xfce4-power-manager
xfce4-power-manager-settings
# verify settings
xset q
Remap copy&paste

install copyq - https://github.com/hluk/CopyQ

sudo dnf install copyq

configure sxhkdrc

# $HOME/.sxhkd/sxhkdrc
# copy paste
super + c
	echo -n | copyq copy
super + v
	copyq paste
Configure lightdm

configure gtk-greeter

# /etc/lightdm/lightdm-gtk-greeter.conf

[greeter]
background=/usr/share/backgrounds/bg.jpg
font-name=FiraCode Nerd Font Mono 14
theme-name=Material-Black-Blueberry
icon-theme-name=Papirus-Dark
cursor-theme-name=Bibata-Modern-Ice
cursor-theme-size=48
xft-dpi=168
Configure fish shell
# install fish shell
sudo dnf install fish

# install oh-my-fish
curl https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install | fish

# install fisher
curl -sL https://raw.githubusercontent.com/jorgebucaran/fisher/main/functions/fisher.fish | source && fisher install jorgebucaran/fisher

# set fish shell as default user shell
sudo usermod kev -s /usr/bin/fish

# set fish colorscheme
fisher install dracula/fish

# show custom user paths (optional)
echo $fish_user_paths
# add custom user paths
# add the following to $HOME/.config/fish/config.fish (put at the very top)
fish_add_path $HOME/local/bin
# remove custom user paths
set -e fish_user_paths[index]
Install docker
sudo dnf update
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install docker
pip3 install docker-compose
sudo systemctl enable docker --now
sudo usermod -aG docker $USER
Install media codec

https://rpmfusion.org/Howto/Multimedia

# install hardware accelerated codec
# amd
sudo dnf swap mesa-va-drivers mesa-va-drivers-freeworld
sudo dnf swap mesa-vdpau-drivers mesa-vdpau-drivers-freeworld
# intel
sudo dnf install intel-media-driver
# nvidia
sudo dnf install nvidia-vaapi-driver

# install additional codec
sudo dnf groupupdate multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
sudo dnf install gstreamer1-vaapi libva libva-v4l2-request libva-vdpau-driver
sudo dnf groupupdate sound-and-video

verify hardware status: chrome://gpu/

Basic firewall setup
sudo systemctl disable firewalld --now
sudo dnf install ufw
sudo systemctl enable ufw --now

sudo ufw limit 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw enable
sudo ufw status
Install Network Manager
sudo dnf install NetworkManager NetworkManager-tui
nmtui
Enable flathub repo
sudo dnf install flatpak
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
Install softwares from flathub

https://flathub.org/home

Note The flatpak configuratio is stored under $HOME/.local/share/flatpak. The configuration for individual apps is stored under $HOME/.var/app.

# anydesk
flatpak install flathub com.anydesk.Anydesk
# telegram
flatpak install flathub org.telegram.desktop
# spotify
flatpak install flathub com.spotify.Client
# vlc
flatpak install flathub org.videolan.VLC
# vscode
flatpak install flathub com.visualstudio.code
# obs
flatpak install flathub com.obsproject.Studio
# lens
flatpak install flathub dev.k8slens.OpenLens
# monitorets
flatpak install flathub io.github.jorchube.monitorets
# fluent-reader
flatpak install flathub me.hyliu.fluentreader
# video-downloader
flatpak install flathub com.github.unrud.VideoDownloader
# free-downloader-manager
flatpak install flathub org.freedownloadmanager.Manager
# yubikey-authenticator
flatpak install flathub com.yubico.yubioath
# boatswain (elgato stream deck controller)
flatpak install flathub com.feaneron.Boatswain
Install browser

Microsoft Edge

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo dnf config-manager --add-repo https://packages.microsoft.com/yumrepos/edge
sudo dnf install microsoft-edge-stable
microsoft-edge -version

Brave

sudo rpm --import https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
sudo dnf config-manager --add-repo https://brave-browser-rpm-release.s3.brave.com/x86_64/
sudo dnf install brave-browser

set default browser

xdg-settings set default-web-browser brave.desktop
Install ranger
sudo dnf install ranger
# install ueberzug (image preview)
sudo dnf install libx11-dev libXext-devel libXres-devel
sudo dnf install python3-pip python3-devel
pip3 install ueberzug-bak
Install Chinese inputs

https://wiki.archlinux.org/title/Fcitx5#top-page

purge ibus

sudo dnf remove ibus

install fcitx5

sudo dnf install -y fcitx5 fcitx5-qt fcitx-gtk kcm-fcitx5 fcitx5-chinese-addons fcitx5-table-extra fcitx5-zhuyin
sudo alternatives --config xinputrc # choose fcitx5.

# $HOME/.xprofile
INPUT_METHOD=fcitx
XMODIFIERS=@im=fcitx5
QT_IM_MODULE=fcitx
SDL_IM_MODULE=fcitx
IMSETTINGS_MODULE=fcitx5
GTK_IM_MODULE=fcitx

mkdir -p ~/.config/autostart/
ln -s /usr/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart/
sudo reboot

if using wm, add the following

# $HOME/.config/bspwm/bspwmrc
fcitx5 &

verify envs

env | grep -i fcitx

Note To see if Fcitx5 is working correctly, open an application and press Ctrl+Space to switch between input methods (when configured), and input some words.

HiDPI setup

https://arimasou16.com/blog/2021/11/08/00434/ https://www.youtube.com/watch?v=zz5qrUVAHX8

Global scale setup

# $HOME/.Xresources
Xft.dpi: 168
Xft.autohint: 0
Xft.lcdfilter: lcddefault
Xft.hintstyle: hintfull
Xft.hinting: 1
Xft.antialias: 1
Xft.rgba: rgb

# $HOME/.config/polybar/config
[bar/main]
width            = 100%
- height         = 30
+ height         = 60

# $HOME/.config/sxhkd/sxhkdrc
# program launcher
super + r
        rofi -show drun -show combi -dpi 144

Alternatively, export the followings to ~/.profile. It will enable factorial scaling at the application level.

# HiDPI
export QT_AUTO_SCREEN_SCALE_FACTOR=1.5
export QT_SCALE_FACTOR=1.5
export GDK_SCALE=1.5
export GDK_DPI_SCALE=1.5
Thunar plugins and addons
  • tumbler (external program to generate thumnails)
  • ffmpegthumbnailer (external program to generate video thumnails)
  • thunar-archive-plugin (create and extract archive files)
  • gnome-vfs2 (gnome virtual file system, show trashcan, removable media, and remote file systems)

Reference: https://wiki.archlinux.org/title/thunar

sudo dnf install tumbler ffmpegthumbnailer thunar-archive-plugin gnome-vfs2
Install betterlockscreen

Source: https://github.com/betterlockscreen/betterlockscreen

install depedencies

sudo dnf remove i3lock
sudo dnf install -y autoconf automake cairo-devel fontconfig gcc libev-devel libjpeg-turbo-devel libXinerama libxkbcommon-devel libxkbcommon-x11-devel libXrandr pam-devel pkgconf xcb-util-image-devel xcb-util-xrm-devel
git clone https://github.com/Raymo111/i3lock-color && cd i3lock-color
sudo sh install-i3lock-color.sh

install betterlockscreen

wget https://raw.githubusercontent.com/betterlockscreen/betterlockscreen/main/install.sh -O - -q | sudo bash -s system

usage

# generate lockscreen wallpaper
betterlockscreen -u ~/Pictures/wallpaper/bg.jpg --fx blur
# lock screen
betterlockscreen -l

enable systemd service

wget https://github.com/betterlockscreen/betterlockscreen/archive/refs/heads/main.zip
unzip main.zip
cd betterlockscreen-main
cp system/[email protected] /usr/lib/systemd/system/
sudo systemctl enable betterlockscreen@$USER --now
rm -rf betterlockscreen-main main.zip

Device Management

Install device manager
sudo dnf install solaar
Audio control

install dependencies

sudo dnf install pipewire pipewire-media-session pipewire-pulseaudio

control audio devices

# get current audio output
pactl list sinks short | awk -F '\t' '{print $1,$2,$5}'
# set audio output
pactl set-default-sink <sink #>

know issue: https://bbs.archlinux.org/viewtopic.php?pid=2023940#p2023940

if video playback stops working after resuming from suspend state, then try killing the process

killall -9 pipewire
Adjust monitor brightness

https://man.archlinux.org/man/extra/ddcutil/ddcutil.1.en#setvcp

# install
sudo dnf install ddcutil

# identify all attached monitors.
sudo ddcutil detect

# query the luminosity value of the second monitor.
sudo ddctpp getvcp 10 --display 2

# set the luminosity value for the first display
sudo ddcutil setvcp 10 30 --display 1
Mouse adjustment

Reference: https://wiki.archlinux.org/title/Mouse_acceleration

# get list of devices pluggined in
xinput list
# get properties of a given device id
xinput list-props 10
# set specific property
xinput --set-prop "Logitech USB Receiver" "libinput Natural Scrolling Enabled" 1
Adjust keyboard repeat rate
sudo dnf install xset
xset r rate 200 25

Theme Customization

Adjust cursor theme

https://wiki.archlinux.org/title/Cursor_themes

# prerequisites
sudo dnf install xsetroot

# $HOME/.config/gtk-3.0/settings.ini
gtk-cursor-theme-name=Bibata-Modern-Ice
gtk-cursor-theme-size=48

# $HOME/.icons/default/index.theme
[Icon Theme]
Name=Default
Comment=Default Cursor Theme
Inherits=Bibata-Modern-Ice

# $HOME/.Xresources
Xcursor.size: 48
Xcursor.theme: Bibata-Modern-Ice

# $HOME/.profile# cursor
export XCURSOR_THEME="Bibata-Modern-Ice"
export XCURSOR_SIZE=48

# $HOME/.config/bspwm/bspwmrc
xsetroot -cursor_name left_ptr
Custom theme

get current theme

gsettings get org.gnome.desktop.interface gtk-theme
gsettings get org.gnome.desktop.interface icon-theme

set custom theme

# $HOME/.config/gtk-3.0/settings.ini
[Settings]
gtk-application-prefer-dark-theme = true

# $HOME/.profile
export GTK_THEME=Material-Black-Blueberry
export GTK_ICON_THEME=Papirus-Dark
export QT_STYLE_OVERRIDE=adwaita-dark
export QT_QPA_PLATFORMTHEME=gtk2

set theme manually

# overwrite current session variables
gsettings set org.gnome.desktop.interface gtk-theme Material-Black-Blueberry
gsettings set org.gnome.desktop.interface icon-theme Papirus-Dark

# alternatively apply ONLY to specific app
GTK_THEME=Material-Black-Blueberry thunar
Feh blur wallpaper

Source: https://github.com/rstacruz/feh-blur-wallpaper

# install depedencies
sudo dnf install GraphicsMagick wmctrl feh

# install feh-blur
wget https://github.com/rstacruz/feh-blur-wallpaper/raw/master/feh-blur
chmod +x ./feh-blur
install feh-blur $HOME/.local/bin
rm -f ./feh-blur

# usage
feh-blur --help

# save blur image
feh --bg-fill "$HOME/Pictures/wallpaper/bg.jpg"
feh-blur --no-animate --blur 24 --darken 0 --save-image ~/Pictures/wallpaper/bg-blur.jpg

Further reading

Fedora Hacks

DNF related

Configure Fedora source

https://mirrors.ustc.edu.cn/help/fedora.html

sudo sed -e 's|^metalink=|#metalink=|g' \
         -e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.ustc.edu.cn/fedora|g' \
         -i.bak \
         /etc/yum.repos.d/fedora.repo \
         /etc/yum.repos.d/fedora-modular.repo \
         /etc/yum.repos.d/fedora-updates.repo \
         /etc/yum.repos.d/fedora-updates-modular.repo
Bootstrap DNF
# /etc/dnf/dnf.conf
max_parallel_downloads=10
fastestmirror=True
defaultyes=True
keepcache=True

sudo dnf update
Clean up cache
sudo dnf clean all

Install rpmfusion

https://rpmfusion.org/Configuration

sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
sudo dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
sudo dnf config-manager --set-enabled rpmfusion-free
sudo dnf config-manager --set-enabled rpmfusion-nonfree

sudo dnf groupupdate core

Install media codec

https://rpmfusion.org/Howto/Multimedia

# install hardware accelerated codec
# amd
sudo dnf swap mesa-va-drivers mesa-va-drivers-freeworld
sudo dnf swap mesa-vdpau-drivers mesa-vdpau-drivers-freeworld
# intel
sudo dnf install intel-media-driver
# nvidia
sudo dnf install nvidia-vaapi-driver

# install additional codec
sudo dnf groupupdate multimedia --setop="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
sudo dnf groupupdate sound-and-video

Remove local rpm pakcages

sudo rpm -e <package-name>

Install dev environment

Alacrity config: https://github.com/alacritty/alacritty/blob/master/alacritty.yml

sudo dnf install perl
sudo dnf install libdrm-devel systemd-devel
sudo dnf install cmake ncurses-devel gcc-c++ git-delta git
sudo dnf install alacritty

Install GPU monitor

sudo dnf install nvtop radeontop

Install homebrew

git clone https://github.com/Homebrew/brew ~/.linuxbrew/Homebrew
mkdir ~/.linuxbrew/bin
ln -s ~/.linuxbrew/Homebrew/bin/brew ~/.linuxbrew/bin
eval $(~/.linuxbrew/bin/brew shellenv)

KDE tweaks

HiDPI - https://wiki.archlinux.org/title/HiDPI

KDE plasma shortcuts - https://defkey.com/kde-plasma-shortcuts

Disable Meta (Win) key
kwriteconfig5 --file kwinrc --group ModifierOnlyShortcuts --key Meta ""

Upgrade release

# upgrade
sudo dnf install dnf-plugin-system-upgrade
sudo dnf system-upgrade download --releasever=38 --allowerasing
sudo dnf distro-sync
sudo dnf system-upgrade reboot

# cleanup
sudo dnf system-upgrade clean
sudo dnf install remove-retired-packages
remove-retired-packages
sudo dnf repoquery --unsatisfied
sudo dnf repoquery --duplicates
sudo dnf autoremove

Remove old kernels

#!/usr/bin/env bash

old_kernels=($(dnf repoquery --installonly --latest-limit=-1 -q))
if [ "${#old_kernels[@]}" -eq 0 ]; then
    echo "No old kernels found"
    exit 0
fi

if ! dnf remove "${old_kernels[@]}"; then
    echo "Failed to remove old kernels"
    exit 1
fi

echo "Removed old kernels"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment