Update fedora-niri-dms-setup.sh
This commit is contained in:
1 parent
554cedd0cc
commit
333c86fadc
1 file changed
+139
-3
+139
-3
@@ -132,16 +132,152 @@ sudo systemctl enable --now tuned tuned-ppd
|
||||
|
||||
step "Installing niri and DankMaterialShell"
|
||||
sudo dnf copr enable -y avengemedia/dms
|
||||
dnf_install niri dms xwayland-satellite
|
||||
|
||||
# niri "recommends" these, but DMS replaces all of them. Waybar in particular
|
||||
# gives you a second bar on top of the DMS one, and mako fights DMS over
|
||||
# notifications. Keep them out (and remove them on a re-run).
|
||||
DMS_REPLACES=(waybar mako fuzzel swaybg swayidle swaylock alacritty)
|
||||
EXCLUDE=$(IFS=,; echo "${DMS_REPLACES[*]}")
|
||||
|
||||
if ! dnf_install niri dms xwayland-satellite --exclude="$EXCLUDE"; then
|
||||
warn "Install with exclusions failed; retrying without them"
|
||||
dnf_install niri dms xwayland-satellite
|
||||
fi
|
||||
|
||||
REMOVE=()
|
||||
for pkg in "${DMS_REPLACES[@]}"; do
|
||||
rpm -q "$pkg" >/dev/null 2>&1 || continue
|
||||
# only remove it if nothing hard-depends on it
|
||||
if rpm -q --whatrequires "$pkg" >/dev/null 2>&1; then
|
||||
warn "Keeping $pkg (another package requires it)"
|
||||
else
|
||||
REMOVE+=("$pkg")
|
||||
fi
|
||||
done
|
||||
if (( ${#REMOVE[@]} )); then
|
||||
info "Removing tools DMS replaces: ${REMOVE[*]}"
|
||||
sudo dnf remove -y "${REMOVE[@]}"
|
||||
fi
|
||||
|
||||
info "Starting DMS with niri"
|
||||
systemctl --user add-wants niri.service dms
|
||||
|
||||
# ---------- 6a. xwayland-satellite menu fix -----------------------------------
|
||||
# xwayland-satellite <= 0.8.2 makes X11 popup menus (e.g. Steam's) flicker and
|
||||
# vanish under niri. The fix is upstream commit add2795 but not yet in a Fedora
|
||||
# release. Build that commit into /usr/local/bin (which comes before /usr/bin in
|
||||
# PATH), and install a boot-time check that deletes it once Fedora ships a newer
|
||||
# version, so Fedora's package takes over again automatically.
|
||||
|
||||
XWLS_BROKEN_MAX=0.8.2
|
||||
XWLS_FIX_REV=add2795134593faafce60e404a0a75df68e9ee0c
|
||||
XWLS_FEDORA=$(rpm -q --qf '%{VERSION}' xwayland-satellite 2>/dev/null || echo 0)
|
||||
|
||||
# true if $1 <= $2 (version compare)
|
||||
ver_le() { [[ "$(printf '%s\n%s\n' "$1" "$2" | sort -V | head -1)" == "$1" ]]; }
|
||||
|
||||
if ver_le "$XWLS_FEDORA" "$XWLS_BROKEN_MAX"; then
|
||||
step "Building fixed xwayland-satellite (Fedora has $XWLS_FEDORA, menus are broken up to $XWLS_BROKEN_MAX)"
|
||||
if [[ -x /usr/local/bin/xwayland-satellite ]]; then
|
||||
info "Already built, skipping"
|
||||
else
|
||||
dnf_install cargo clang git pkgconf libxcb-devel xcb-util-cursor-devel
|
||||
XWLS_BUILD=$(mktemp -d)
|
||||
if cargo install --git https://github.com/Supreeeme/xwayland-satellite \
|
||||
--rev "$XWLS_FIX_REV" --locked --root "$XWLS_BUILD"; then
|
||||
sudo install -m 755 "$XWLS_BUILD/bin/xwayland-satellite" /usr/local/bin/xwayland-satellite
|
||||
info "Installed to /usr/local/bin/xwayland-satellite"
|
||||
else
|
||||
warn "Build failed; keeping Fedora's xwayland-satellite (Steam menus may misbehave)"
|
||||
fi
|
||||
rm -rf "$XWLS_BUILD"
|
||||
fi
|
||||
|
||||
if [[ -x /usr/local/bin/xwayland-satellite ]]; then
|
||||
info "Installing the auto-cleanup check"
|
||||
sudo mkdir -p /usr/local/libexec
|
||||
sudo tee /usr/local/libexec/xwls-git-check >/dev/null <<EOF
|
||||
#!/bin/bash
|
||||
# Removes the custom xwayland-satellite build once Fedora ships a version
|
||||
# newer than $XWLS_BROKEN_MAX, then removes itself.
|
||||
cur=\$(rpm -q --qf '%{VERSION}' xwayland-satellite 2>/dev/null) || exit 0
|
||||
newest=\$(printf '%s\n%s\n' "$XWLS_BROKEN_MAX" "\$cur" | sort -V | tail -1)
|
||||
if [[ "\$newest" != "$XWLS_BROKEN_MAX" ]]; then
|
||||
rm -f /usr/local/bin/xwayland-satellite
|
||||
systemctl disable xwls-git-check.service
|
||||
rm -f /etc/systemd/system/xwls-git-check.service /usr/local/libexec/xwls-git-check
|
||||
systemctl daemon-reload
|
||||
echo "Fedora xwayland-satellite \$cur installed; removed custom build"
|
||||
fi
|
||||
EOF
|
||||
sudo chmod 755 /usr/local/libexec/xwls-git-check
|
||||
sudo tee /etc/systemd/system/xwls-git-check.service >/dev/null <<'EOF'
|
||||
[Unit]
|
||||
Description=Remove custom xwayland-satellite build once Fedora's is newer
|
||||
Before=display-manager.service greetd.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/libexec/xwls-git-check
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable xwls-git-check.service
|
||||
fi
|
||||
else
|
||||
info "Fedora's xwayland-satellite $XWLS_FEDORA already includes the menu fix"
|
||||
fi
|
||||
|
||||
# ---------- 6b. niri config ---------------------------------------------------
|
||||
|
||||
step "Configuring niri for DMS and Ptyxis"
|
||||
NIRI_CFG="$HOME/.config/niri/config.kdl"
|
||||
mkdir -p "$(dirname "$NIRI_CFG")"
|
||||
|
||||
if [[ ! -f "$NIRI_CFG" ]]; then
|
||||
# niri writes its default config on first launch; create it now instead so
|
||||
# it can be adjusted before you ever log in.
|
||||
DEFAULT_CFG=$(rpm -ql niri 2>/dev/null | grep -m1 'default-config.kdl' || true)
|
||||
if [[ -n "$DEFAULT_CFG" && -f "$DEFAULT_CFG" ]]; then
|
||||
cp "$DEFAULT_CFG" "$NIRI_CFG"
|
||||
info "Copied niri's default config from $DEFAULT_CFG"
|
||||
else
|
||||
NIRI_VER=$(rpm -q --qf '%{VERSION}' niri)
|
||||
if curl -fsSL "https://raw.githubusercontent.com/niri-wm/niri/v${NIRI_VER}/resources/default-config.kdl" -o "$NIRI_CFG"; then
|
||||
info "Downloaded niri ${NIRI_VER} default config"
|
||||
else
|
||||
rm -f "$NIRI_CFG"
|
||||
warn "Couldn't get niri's default config. Log into niri once, then re-run this script to apply the tweaks."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -f "$NIRI_CFG" ]]; then
|
||||
[[ -f "$NIRI_CFG.orig" ]] || cp "$NIRI_CFG" "$NIRI_CFG.orig"
|
||||
sed -i -E \
|
||||
-e 's|^([[:space:]]*)spawn-at-startup "waybar"|\1// spawn-at-startup "waybar" // DMS provides the bar|' \
|
||||
-e 's|spawn "alacritty"|spawn "ptyxis"|g' \
|
||||
-e 's|spawn "fuzzel"|spawn "dms" "ipc" "call" "spotlight" "toggle"|g' \
|
||||
-e 's|spawn "swaylock"|spawn "dms" "ipc" "call" "lock" "lock"|g' \
|
||||
-e 's|Open a Terminal: alacritty|Open a Terminal: Ptyxis|' \
|
||||
-e 's|Run an Application: fuzzel|Run an Application: DMS launcher|' \
|
||||
-e 's|Lock the Screen: swaylock|Lock the Screen: DMS|' \
|
||||
"$NIRI_CFG"
|
||||
info "Waybar disabled, Super+T opens Ptyxis, launcher and lock keys use DMS"
|
||||
info "Original config saved as $NIRI_CFG.orig"
|
||||
if command -v niri >/dev/null && ! niri validate -c "$NIRI_CFG" >/dev/null 2>&1; then
|
||||
warn "niri reports a config problem; restoring the original"
|
||||
cp "$NIRI_CFG.orig" "$NIRI_CFG"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ---------- 7. Desktop essentials --------------------------------------------
|
||||
|
||||
step "Installing desktop essentials"
|
||||
dnf_install \
|
||||
alacritty nautilus firefox \
|
||||
ptyxis nautilus firefox \
|
||||
xdg-desktop-portal-gnome xdg-desktop-portal-gtk \
|
||||
gnome-keyring gnome-keyring-pam \
|
||||
google-noto-sans-fonts google-noto-color-emoji-fonts \
|
||||
@@ -211,4 +347,4 @@ info "If the screen stays black: Ctrl+Alt+F2, log in, and run 'niri-session' or
|
||||
echo
|
||||
if ask "Reboot now?"; then
|
||||
sudo reboot
|
||||
fi
|
||||
fi
|
||||
Reference in new issue
Block a user