Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Run as root inside openSUSE: bash opensuse-noctilia.sh --user USERNAME
- # Add --no-autologin to require authentication at the graphical greeter.
- # Re-running repairs the installation; existing managed files are backed up.
- # Host-side VM autostart is separate: virsh -c qemu:///system autostart 'opensuse noctalia'
- # In virt-manager enable Virtio video 3D acceleration and SPICE OpenGL,
- # using "Listen type: None". Niri requires an accelerated rendering device.
- set -Eeuo pipefail
- trap 'printf "ERROR at line %s: %s\n" "$LINENO" "$BASH_COMMAND" >&2' ERR
- die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }
- DESKTOP_USER="${SUDO_USER:-}"
- AUTOLOGIN=true
- while (($#)); do
- case "$1" in
- --user)
- (($# >= 2)) || die "--user needs a username"
- DESKTOP_USER="$2"
- shift 2
- ;;
- --no-autologin) AUTOLOGIN=false; shift ;;
- *) die "Unknown argument: $1" ;;
- esac
- done
- ((EUID == 0)) || die "Run this installer as root inside the openSUSE guest."
- [[ -n "$DESKTOP_USER" && "$DESKTOP_USER" != root ]] || die "Specify --user with a normal desktop account."
- [[ "$DESKTOP_USER" =~ ^[a-zA-Z_][a-zA-Z0-9_-]*$ ]] || die "Unsupported username."
- source /etc/os-release
- case "$ID" in
- opensuse-slowroll|opensuse-tumbleweed) ;;
- *) die "This installer supports openSUSE Slowroll and Tumbleweed, not $ID." ;;
- esac
- entry="$(getent passwd "$DESKTOP_USER")" || die "Account does not exist: $DESKTOP_USER"
- IFS=: read -r _ _ USER_ID GROUP_ID _ USER_HOME _ <<< "$entry"
- ((USER_ID >= 1000 && USER_ID < 65534)) || die "Choose a normal desktop account."
- [[ -d "$USER_HOME" ]] || die "Home directory does not exist: $USER_HOME"
- CONFIG="$USER_HOME/.config"
- STATE="$USER_HOME/.local/state/noctalia-installer"
- BACKUP="$STATE/backups/$(date +%Y%m%d-%H%M%S)-$$"
- install -d -m 700 -o "$USER_ID" -g "$GROUP_ID" "$STATE" "$BACKUP"
- touch "$STATE/install.log"
- chown "$USER_ID:$GROUP_ID" "$STATE/install.log"
- exec > >(tee -a "$STATE/install.log") 2>&1
- backup() {
- if [[ -e "$1" || -L "$1" ]]; then
- cp -a --parents -- "$1" "$BACKUP"
- fi
- }
- as_user() {
- runuser -u "$DESKTOP_USER" -- env \
- HOME="$USER_HOME" \
- XDG_RUNTIME_DIR="/run/user/$USER_ID" \
- DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$USER_ID/bus" "$@"
- }
- printf 'Installing Niri + Noctalia for %s. Backups: %s\n' "$DESKTOP_USER" "$BACKUP"
- # Use signed distribution packages only. Never record success after a failed install.
- zypper --non-interactive refresh
- zypper --non-interactive install --no-recommends \
- niri noctalia noctalia-greeter greetd xwayland-satellite \
- foot MozillaFirefox thunar thunar-volman gvfs gvfs-backends \
- udisks2 udiskie file-roller \
- pipewire pipewire-pulseaudio wireplumber pavucontrol \
- xdg-desktop-portal xdg-desktop-portal-gnome xdg-desktop-portal-gtk \
- polkit gnome-keyring \
- wl-clipboard playerctl brightnessctl grim slurp \
- inter-fonts jetbrains-mono-fonts papirus-icon-theme adwaita-icon-theme \
- xdg-user-dirs qemu-guest-agent spice-vdagent
- command -v niri-session >/dev/null || die "The niri package did not provide niri-session."
- command -v noctalia-greeter-session >/dev/null || die "Noctalia greeter session is missing."
- noctalia --version
- getent passwd greeter >/dev/null || die "The greetd greeter account is missing."
- for dir in niri noctalia foot gtk-3.0 gtk-4.0 xdg-desktop-portal; do
- install -d -o "$USER_ID" -g "$GROUP_ID" "$CONFIG/$dir"
- done
- install -d -o "$USER_ID" -g "$GROUP_ID" "$CONFIG/systemd/user" \
- "$USER_HOME/Pictures/Screenshots"
- for file in \
- "$CONFIG/niri/config.kdl" "$CONFIG/noctalia/config.toml" \
- "$CONFIG/foot/foot.ini" "$CONFIG/gtk-3.0/settings.ini" \
- "$CONFIG/gtk-4.0/settings.ini" "$CONFIG/xdg-desktop-portal/niri-portals.conf" \
- "$CONFIG/systemd/user/noctalia.service"; do
- backup "$file"
- done
- cat > "$CONFIG/niri/config.kdl" <<'KDL'
- input {
- keyboard {
- xkb {}
- numlock
- }
- touchpad {
- tap
- natural-scroll
- }
- }
- cursor {
- xcursor-theme "Adwaita"
- xcursor-size 24
- }
- layout {
- gaps 12
- center-focused-column "on-overflow"
- preset-column-widths {
- proportion 0.33333
- proportion 0.5
- proportion 0.66667
- }
- default-column-width { proportion 0.5; }
- focus-ring {
- width 2
- active-gradient from="#cba6f7" to="#89b4fa" angle=45
- inactive-color "#45475a"
- }
- border { off; }
- shadow {
- on
- softness 24
- spread 2
- offset x=0 y=5
- color "#0007"
- }
- }
- prefer-no-csd
- window-rule {
- geometry-corner-radius 14
- clip-to-geometry true
- background-effect {
- blur true
- xray false
- }
- }
- window-rule {
- match app-id="dev.noctalia.Noctalia"
- open-floating true
- default-column-width { fixed 1000; }
- default-window-height { fixed 700; }
- }
- layer-rule {
- match namespace="^noctalia-"
- background-effect { xray false; }
- }
- blur {
- passes 2
- offset 3.0
- noise 0.02
- }
- overview { backdrop-color "#11111b"; }
- hotkey-overlay { skip-at-startup; }
- screenshot-path "~/Pictures/Screenshots/%Y-%m-%d-%H%M%S.png"
- spawn-at-startup "systemctl" "--user" "start" "noctalia.service"
- spawn-at-startup "udiskie" "--tray"
- debug { honor-xdg-activation-with-invalid-serial; }
- binds {
- Mod+Return hotkey-overlay-title="Terminal" { spawn "foot"; }
- Mod+E hotkey-overlay-title="Files" { spawn "thunar"; }
- Mod+B hotkey-overlay-title="Browser" { spawn "firefox"; }
- Mod+Space hotkey-overlay-title="Launcher" { spawn "noctalia" "msg" "panel-toggle" "launcher"; }
- Mod+S hotkey-overlay-title="Control center" { spawn "noctalia" "msg" "panel-toggle" "control-center"; }
- Mod+Comma hotkey-overlay-title="Settings" { spawn "noctalia" "msg" "settings-toggle"; }
- Mod+L hotkey-overlay-title="Lock screen" { spawn "noctalia" "msg" "session" "lock"; }
- Mod+Shift+Slash { show-hotkey-overlay; }
- Mod+Tab { toggle-overview; }
- Mod+Q { close-window; }
- Alt+F4 { close-window; }
- Mod+Left { focus-column-left; }
- Mod+Right { focus-column-right; }
- Mod+Up { focus-window-up; }
- Mod+Down { focus-window-down; }
- Mod+Shift+Left { move-column-left; }
- Mod+Shift+Right { move-column-right; }
- Mod+Shift+Up { move-window-up; }
- Mod+Shift+Down { move-window-down; }
- Mod+Page_Up { focus-workspace-up; }
- Mod+Page_Down { focus-workspace-down; }
- Mod+Shift+Page_Up { move-column-to-workspace-up; }
- Mod+Shift+Page_Down { move-column-to-workspace-down; }
- Mod+1 { focus-workspace 1; }
- Mod+2 { focus-workspace 2; }
- Mod+3 { focus-workspace 3; }
- Mod+4 { focus-workspace 4; }
- Mod+Shift+1 { move-column-to-workspace 1; }
- Mod+Shift+2 { move-column-to-workspace 2; }
- Mod+Shift+3 { move-column-to-workspace 3; }
- Mod+Shift+4 { move-column-to-workspace 4; }
- Mod+F { maximize-column; }
- Mod+Shift+F { fullscreen-window; }
- Mod+V { toggle-window-floating; }
- Mod+R { switch-preset-column-width; }
- Mod+Minus { set-column-width "-10%"; }
- Mod+Equal { set-column-width "+10%"; }
- Mod+Shift+E { quit; }
- Print { screenshot; }
- XF86AudioRaiseVolume allow-when-locked=true { spawn "noctalia" "msg" "volume-up"; }
- XF86AudioLowerVolume allow-when-locked=true { spawn "noctalia" "msg" "volume-down"; }
- XF86AudioMute allow-when-locked=true { spawn "noctalia" "msg" "volume-mute"; }
- XF86AudioPlay allow-when-locked=true { spawn "playerctl" "play-pause"; }
- XF86AudioNext allow-when-locked=true { spawn "playerctl" "next"; }
- XF86AudioPrev allow-when-locked=true { spawn "playerctl" "previous"; }
- XF86MonBrightnessUp { spawn "noctalia" "msg" "brightness-up"; }
- XF86MonBrightnessDown { spawn "noctalia" "msg" "brightness-down"; }
- }
- KDL
- # These are Noctalia v5 TOML settings, not the incompatible v4 JSON format.
- # Use the bundled wallpaper/palettes instead of unreviewed dotfile scripts.
- cat > "$CONFIG/noctalia/config.toml" <<'TOML'
- [theme]
- mode = "dark"
- source = "builtin"
- builtin = "Catppuccin"
- [bar.default]
- position = "top"
- thickness = 38
- margin_ends = 12
- margin_edge = 10
- radius = 14
- background_opacity = 0.95
- font_family = "Inter"
- start = ["launcher", "workspaces"]
- center = ["clock"]
- end = ["media", "tray", "notifications", "clipboard", "network", "volume", "control-center", "session"]
- [wallpaper]
- enabled = true
- transition = ["fade"]
- TOML
- cat > "$CONFIG/foot/foot.ini" <<'INI'
- [main]
- font=JetBrains Mono:size=11
- pad=14x14
- [colors]
- alpha=0.96
- background=1e1e2e
- foreground=cdd6f4
- regular0=45475a
- regular1=f38ba8
- regular2=a6e3a1
- regular3=f9e2af
- regular4=89b4fa
- regular5=f5c2e7
- regular6=94e2d5
- regular7=bac2de
- bright0=585b70
- bright1=f38ba8
- bright2=a6e3a1
- bright3=f9e2af
- bright4=89b4fa
- bright5=f5c2e7
- bright6=94e2d5
- bright7=a6adc8
- INI
- for toolkit in gtk-3.0 gtk-4.0; do
- cat > "$CONFIG/$toolkit/settings.ini" <<'INI'
- [Settings]
- gtk-application-prefer-dark-theme=true
- gtk-icon-theme-name=Papirus-Dark
- gtk-font-name=Inter 11
- INI
- done
- # Niri uses GNOME's screencast backend; wlr's backend is for Sway, not Niri.
- cat > "$CONFIG/xdg-desktop-portal/niri-portals.conf" <<'INI'
- [preferred]
- default=gnome;gtk;
- org.freedesktop.impl.portal.FileChooser=gtk;
- org.freedesktop.impl.portal.ScreenCast=gnome;
- org.freedesktop.impl.portal.Screenshot=gnome;
- org.freedesktop.impl.portal.Secret=gnome-keyring;
- INI
- cat > "$CONFIG/systemd/user/noctalia.service" <<'UNIT'
- [Unit]
- Description=Noctalia desktop shell
- PartOf=graphical-session.target
- After=graphical-session.target
- [Service]
- ExecStart=/usr/bin/noctalia
- Restart=on-failure
- RestartSec=3
- UNIT
- for file in \
- "$CONFIG/niri/config.kdl" "$CONFIG/noctalia/config.toml" \
- "$CONFIG/foot/foot.ini" "$CONFIG/gtk-3.0/settings.ini" \
- "$CONFIG/gtk-4.0/settings.ini" "$CONFIG/xdg-desktop-portal/niri-portals.conf" \
- "$CONFIG/systemd/user/noctalia.service"; do
- chown "$USER_ID:$GROUP_ID" "$file"
- done
- as_user niri validate --config "$CONFIG/niri/config.kdl"
- as_user noctalia config validate
- install -d /etc/greetd /usr/local/share/wayland-sessions /usr/local/bin
- backup /usr/local/bin/noctalia-niri-session
- backup /usr/local/share/wayland-sessions/noctalia-niri.desktop
- cat > /usr/local/bin/noctalia-niri-session <<'SH'
- #!/usr/bin/env bash
- set -euo pipefail
- export XDG_CURRENT_DESKTOP=niri
- export XDG_SESSION_DESKTOP=niri
- export XDG_SESSION_TYPE=wayland
- exec /usr/bin/niri-session
- SH
- chmod 755 /usr/local/bin/noctalia-niri-session
- cat > /usr/local/share/wayland-sessions/noctalia-niri.desktop <<'DESKTOP'
- [Desktop Entry]
- Name=Noctalia (Niri)
- Comment=Noctalia desktop with Niri
- Exec=/usr/local/bin/noctalia-niri-session
- Type=Application
- DesktopNames=niri
- DESKTOP
- backup /etc/greetd/config.toml
- cat > /etc/greetd/config.toml <<'TOML'
- [terminal]
- vt = 1
- [default_session]
- command = "/usr/bin/noctalia-greeter-session"
- user = "greeter"
- TOML
- if "$AUTOLOGIN"; then
- cat >> /etc/greetd/config.toml <<TOML
- [initial_session]
- command = "/usr/local/bin/noctalia-niri-session"
- user = "$DESKTOP_USER"
- TOML
- fi
- systemctl enable qemu-guest-agent.service
- systemctl start qemu-guest-agent.service
- systemctl enable greetd.service
- systemctl set-default graphical.target
- if [[ -S "/run/user/$USER_ID/bus" ]]; then
- as_user systemctl --user daemon-reload
- as_user systemctl --user enable --now pipewire.socket pipewire-pulse.socket wireplumber.service
- as_user xdg-user-dirs-update
- else
- printf 'No user bus is available; audio will start with the next desktop login.\n'
- fi
- chown -R "$USER_ID:$GROUP_ID" "$BACKUP"
- printf '\nInstallation validated. Reboot to start Noctalia; the active session was not interrupted.\n'
- printf 'Autologin: %s (physical/console access grants access to this account).\n' "$AUTOLOGIN"
- printf 'Super+Enter: terminal | Super+Space: launcher | Super+S: controls | Super+Tab: overview\n'
- printf 'Log: %s/install.log\nBackups: %s\n' "$STATE" "$BACKUP"
Add Comment
Please, Sign In to add comment