Guest User

Untitled

a guest
Nov 23rd, 2026
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.95 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Run as root inside openSUSE: bash opensuse-noctilia.sh --user USERNAME
  3. # Add --no-autologin to require authentication at the graphical greeter.
  4. # Re-running repairs the installation; existing managed files are backed up.
  5. # Host-side VM autostart is separate: virsh -c qemu:///system autostart 'opensuse noctalia'
  6. # In virt-manager enable Virtio video 3D acceleration and SPICE OpenGL,
  7. # using "Listen type: None". Niri requires an accelerated rendering device.
  8.  
  9. set -Eeuo pipefail
  10. trap 'printf "ERROR at line %s: %s\n" "$LINENO" "$BASH_COMMAND" >&2' ERR
  11.  
  12. die() { printf 'ERROR: %s\n' "$*" >&2; exit 1; }
  13.  
  14. DESKTOP_USER="${SUDO_USER:-}"
  15. AUTOLOGIN=true
  16. while (($#)); do
  17. case "$1" in
  18. --user)
  19. (($# >= 2)) || die "--user needs a username"
  20. DESKTOP_USER="$2"
  21. shift 2
  22. ;;
  23. --no-autologin) AUTOLOGIN=false; shift ;;
  24. *) die "Unknown argument: $1" ;;
  25. esac
  26. done
  27.  
  28. ((EUID == 0)) || die "Run this installer as root inside the openSUSE guest."
  29. [[ -n "$DESKTOP_USER" && "$DESKTOP_USER" != root ]] || die "Specify --user with a normal desktop account."
  30. [[ "$DESKTOP_USER" =~ ^[a-zA-Z_][a-zA-Z0-9_-]*$ ]] || die "Unsupported username."
  31. source /etc/os-release
  32. case "$ID" in
  33. opensuse-slowroll|opensuse-tumbleweed) ;;
  34. *) die "This installer supports openSUSE Slowroll and Tumbleweed, not $ID." ;;
  35. esac
  36.  
  37. entry="$(getent passwd "$DESKTOP_USER")" || die "Account does not exist: $DESKTOP_USER"
  38. IFS=: read -r _ _ USER_ID GROUP_ID _ USER_HOME _ <<< "$entry"
  39. ((USER_ID >= 1000 && USER_ID < 65534)) || die "Choose a normal desktop account."
  40. [[ -d "$USER_HOME" ]] || die "Home directory does not exist: $USER_HOME"
  41. CONFIG="$USER_HOME/.config"
  42. STATE="$USER_HOME/.local/state/noctalia-installer"
  43. BACKUP="$STATE/backups/$(date +%Y%m%d-%H%M%S)-$$"
  44. install -d -m 700 -o "$USER_ID" -g "$GROUP_ID" "$STATE" "$BACKUP"
  45. touch "$STATE/install.log"
  46. chown "$USER_ID:$GROUP_ID" "$STATE/install.log"
  47. exec > >(tee -a "$STATE/install.log") 2>&1
  48.  
  49. backup() {
  50. if [[ -e "$1" || -L "$1" ]]; then
  51. cp -a --parents -- "$1" "$BACKUP"
  52. fi
  53. }
  54.  
  55. as_user() {
  56. runuser -u "$DESKTOP_USER" -- env \
  57. HOME="$USER_HOME" \
  58. XDG_RUNTIME_DIR="/run/user/$USER_ID" \
  59. DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$USER_ID/bus" "$@"
  60. }
  61.  
  62. printf 'Installing Niri + Noctalia for %s. Backups: %s\n' "$DESKTOP_USER" "$BACKUP"
  63. # Use signed distribution packages only. Never record success after a failed install.
  64. zypper --non-interactive refresh
  65. zypper --non-interactive install --no-recommends \
  66. niri noctalia noctalia-greeter greetd xwayland-satellite \
  67. foot MozillaFirefox thunar thunar-volman gvfs gvfs-backends \
  68. udisks2 udiskie file-roller \
  69. pipewire pipewire-pulseaudio wireplumber pavucontrol \
  70. xdg-desktop-portal xdg-desktop-portal-gnome xdg-desktop-portal-gtk \
  71. polkit gnome-keyring \
  72. wl-clipboard playerctl brightnessctl grim slurp \
  73. inter-fonts jetbrains-mono-fonts papirus-icon-theme adwaita-icon-theme \
  74. xdg-user-dirs qemu-guest-agent spice-vdagent
  75.  
  76. command -v niri-session >/dev/null || die "The niri package did not provide niri-session."
  77. command -v noctalia-greeter-session >/dev/null || die "Noctalia greeter session is missing."
  78. noctalia --version
  79. getent passwd greeter >/dev/null || die "The greetd greeter account is missing."
  80.  
  81. for dir in niri noctalia foot gtk-3.0 gtk-4.0 xdg-desktop-portal; do
  82. install -d -o "$USER_ID" -g "$GROUP_ID" "$CONFIG/$dir"
  83. done
  84. install -d -o "$USER_ID" -g "$GROUP_ID" "$CONFIG/systemd/user" \
  85. "$USER_HOME/Pictures/Screenshots"
  86. for file in \
  87. "$CONFIG/niri/config.kdl" "$CONFIG/noctalia/config.toml" \
  88. "$CONFIG/foot/foot.ini" "$CONFIG/gtk-3.0/settings.ini" \
  89. "$CONFIG/gtk-4.0/settings.ini" "$CONFIG/xdg-desktop-portal/niri-portals.conf" \
  90. "$CONFIG/systemd/user/noctalia.service"; do
  91. backup "$file"
  92. done
  93.  
  94. cat > "$CONFIG/niri/config.kdl" <<'KDL'
  95. input {
  96. keyboard {
  97. xkb {}
  98. numlock
  99. }
  100. touchpad {
  101. tap
  102. natural-scroll
  103. }
  104. }
  105. cursor {
  106. xcursor-theme "Adwaita"
  107. xcursor-size 24
  108. }
  109. layout {
  110. gaps 12
  111. center-focused-column "on-overflow"
  112. preset-column-widths {
  113. proportion 0.33333
  114. proportion 0.5
  115. proportion 0.66667
  116. }
  117. default-column-width { proportion 0.5; }
  118. focus-ring {
  119. width 2
  120. active-gradient from="#cba6f7" to="#89b4fa" angle=45
  121. inactive-color "#45475a"
  122. }
  123. border { off; }
  124. shadow {
  125. on
  126. softness 24
  127. spread 2
  128. offset x=0 y=5
  129. color "#0007"
  130. }
  131. }
  132. prefer-no-csd
  133. window-rule {
  134. geometry-corner-radius 14
  135. clip-to-geometry true
  136. background-effect {
  137. blur true
  138. xray false
  139. }
  140. }
  141. window-rule {
  142. match app-id="dev.noctalia.Noctalia"
  143. open-floating true
  144. default-column-width { fixed 1000; }
  145. default-window-height { fixed 700; }
  146. }
  147. layer-rule {
  148. match namespace="^noctalia-"
  149. background-effect { xray false; }
  150. }
  151. blur {
  152. passes 2
  153. offset 3.0
  154. noise 0.02
  155. }
  156. overview { backdrop-color "#11111b"; }
  157. hotkey-overlay { skip-at-startup; }
  158. screenshot-path "~/Pictures/Screenshots/%Y-%m-%d-%H%M%S.png"
  159. spawn-at-startup "systemctl" "--user" "start" "noctalia.service"
  160. spawn-at-startup "udiskie" "--tray"
  161. debug { honor-xdg-activation-with-invalid-serial; }
  162. binds {
  163. Mod+Return hotkey-overlay-title="Terminal" { spawn "foot"; }
  164. Mod+E hotkey-overlay-title="Files" { spawn "thunar"; }
  165. Mod+B hotkey-overlay-title="Browser" { spawn "firefox"; }
  166. Mod+Space hotkey-overlay-title="Launcher" { spawn "noctalia" "msg" "panel-toggle" "launcher"; }
  167. Mod+S hotkey-overlay-title="Control center" { spawn "noctalia" "msg" "panel-toggle" "control-center"; }
  168. Mod+Comma hotkey-overlay-title="Settings" { spawn "noctalia" "msg" "settings-toggle"; }
  169. Mod+L hotkey-overlay-title="Lock screen" { spawn "noctalia" "msg" "session" "lock"; }
  170. Mod+Shift+Slash { show-hotkey-overlay; }
  171. Mod+Tab { toggle-overview; }
  172. Mod+Q { close-window; }
  173. Alt+F4 { close-window; }
  174. Mod+Left { focus-column-left; }
  175. Mod+Right { focus-column-right; }
  176. Mod+Up { focus-window-up; }
  177. Mod+Down { focus-window-down; }
  178. Mod+Shift+Left { move-column-left; }
  179. Mod+Shift+Right { move-column-right; }
  180. Mod+Shift+Up { move-window-up; }
  181. Mod+Shift+Down { move-window-down; }
  182. Mod+Page_Up { focus-workspace-up; }
  183. Mod+Page_Down { focus-workspace-down; }
  184. Mod+Shift+Page_Up { move-column-to-workspace-up; }
  185. Mod+Shift+Page_Down { move-column-to-workspace-down; }
  186. Mod+1 { focus-workspace 1; }
  187. Mod+2 { focus-workspace 2; }
  188. Mod+3 { focus-workspace 3; }
  189. Mod+4 { focus-workspace 4; }
  190. Mod+Shift+1 { move-column-to-workspace 1; }
  191. Mod+Shift+2 { move-column-to-workspace 2; }
  192. Mod+Shift+3 { move-column-to-workspace 3; }
  193. Mod+Shift+4 { move-column-to-workspace 4; }
  194. Mod+F { maximize-column; }
  195. Mod+Shift+F { fullscreen-window; }
  196. Mod+V { toggle-window-floating; }
  197. Mod+R { switch-preset-column-width; }
  198. Mod+Minus { set-column-width "-10%"; }
  199. Mod+Equal { set-column-width "+10%"; }
  200. Mod+Shift+E { quit; }
  201. Print { screenshot; }
  202. XF86AudioRaiseVolume allow-when-locked=true { spawn "noctalia" "msg" "volume-up"; }
  203. XF86AudioLowerVolume allow-when-locked=true { spawn "noctalia" "msg" "volume-down"; }
  204. XF86AudioMute allow-when-locked=true { spawn "noctalia" "msg" "volume-mute"; }
  205. XF86AudioPlay allow-when-locked=true { spawn "playerctl" "play-pause"; }
  206. XF86AudioNext allow-when-locked=true { spawn "playerctl" "next"; }
  207. XF86AudioPrev allow-when-locked=true { spawn "playerctl" "previous"; }
  208. XF86MonBrightnessUp { spawn "noctalia" "msg" "brightness-up"; }
  209. XF86MonBrightnessDown { spawn "noctalia" "msg" "brightness-down"; }
  210. }
  211. KDL
  212.  
  213. # These are Noctalia v5 TOML settings, not the incompatible v4 JSON format.
  214. # Use the bundled wallpaper/palettes instead of unreviewed dotfile scripts.
  215. cat > "$CONFIG/noctalia/config.toml" <<'TOML'
  216. [theme]
  217. mode = "dark"
  218. source = "builtin"
  219. builtin = "Catppuccin"
  220.  
  221. [bar.default]
  222. position = "top"
  223. thickness = 38
  224. margin_ends = 12
  225. margin_edge = 10
  226. radius = 14
  227. background_opacity = 0.95
  228. font_family = "Inter"
  229. start = ["launcher", "workspaces"]
  230. center = ["clock"]
  231. end = ["media", "tray", "notifications", "clipboard", "network", "volume", "control-center", "session"]
  232.  
  233. [wallpaper]
  234. enabled = true
  235. transition = ["fade"]
  236. TOML
  237.  
  238. cat > "$CONFIG/foot/foot.ini" <<'INI'
  239. [main]
  240. font=JetBrains Mono:size=11
  241. pad=14x14
  242.  
  243. [colors]
  244. alpha=0.96
  245. background=1e1e2e
  246. foreground=cdd6f4
  247. regular0=45475a
  248. regular1=f38ba8
  249. regular2=a6e3a1
  250. regular3=f9e2af
  251. regular4=89b4fa
  252. regular5=f5c2e7
  253. regular6=94e2d5
  254. regular7=bac2de
  255. bright0=585b70
  256. bright1=f38ba8
  257. bright2=a6e3a1
  258. bright3=f9e2af
  259. bright4=89b4fa
  260. bright5=f5c2e7
  261. bright6=94e2d5
  262. bright7=a6adc8
  263. INI
  264. for toolkit in gtk-3.0 gtk-4.0; do
  265. cat > "$CONFIG/$toolkit/settings.ini" <<'INI'
  266. [Settings]
  267. gtk-application-prefer-dark-theme=true
  268. gtk-icon-theme-name=Papirus-Dark
  269. gtk-font-name=Inter 11
  270. INI
  271. done
  272.  
  273. # Niri uses GNOME's screencast backend; wlr's backend is for Sway, not Niri.
  274. cat > "$CONFIG/xdg-desktop-portal/niri-portals.conf" <<'INI'
  275. [preferred]
  276. default=gnome;gtk;
  277. org.freedesktop.impl.portal.FileChooser=gtk;
  278. org.freedesktop.impl.portal.ScreenCast=gnome;
  279. org.freedesktop.impl.portal.Screenshot=gnome;
  280. org.freedesktop.impl.portal.Secret=gnome-keyring;
  281. INI
  282. cat > "$CONFIG/systemd/user/noctalia.service" <<'UNIT'
  283. [Unit]
  284. Description=Noctalia desktop shell
  285. PartOf=graphical-session.target
  286. After=graphical-session.target
  287.  
  288. [Service]
  289. ExecStart=/usr/bin/noctalia
  290. Restart=on-failure
  291. RestartSec=3
  292. UNIT
  293.  
  294. for file in \
  295. "$CONFIG/niri/config.kdl" "$CONFIG/noctalia/config.toml" \
  296. "$CONFIG/foot/foot.ini" "$CONFIG/gtk-3.0/settings.ini" \
  297. "$CONFIG/gtk-4.0/settings.ini" "$CONFIG/xdg-desktop-portal/niri-portals.conf" \
  298. "$CONFIG/systemd/user/noctalia.service"; do
  299. chown "$USER_ID:$GROUP_ID" "$file"
  300. done
  301. as_user niri validate --config "$CONFIG/niri/config.kdl"
  302. as_user noctalia config validate
  303.  
  304. install -d /etc/greetd /usr/local/share/wayland-sessions /usr/local/bin
  305. backup /usr/local/bin/noctalia-niri-session
  306. backup /usr/local/share/wayland-sessions/noctalia-niri.desktop
  307. cat > /usr/local/bin/noctalia-niri-session <<'SH'
  308. #!/usr/bin/env bash
  309. set -euo pipefail
  310. export XDG_CURRENT_DESKTOP=niri
  311. export XDG_SESSION_DESKTOP=niri
  312. export XDG_SESSION_TYPE=wayland
  313. exec /usr/bin/niri-session
  314. SH
  315. chmod 755 /usr/local/bin/noctalia-niri-session
  316. cat > /usr/local/share/wayland-sessions/noctalia-niri.desktop <<'DESKTOP'
  317. [Desktop Entry]
  318. Name=Noctalia (Niri)
  319. Comment=Noctalia desktop with Niri
  320. Exec=/usr/local/bin/noctalia-niri-session
  321. Type=Application
  322. DesktopNames=niri
  323. DESKTOP
  324. backup /etc/greetd/config.toml
  325. cat > /etc/greetd/config.toml <<'TOML'
  326. [terminal]
  327. vt = 1
  328.  
  329. [default_session]
  330. command = "/usr/bin/noctalia-greeter-session"
  331. user = "greeter"
  332. TOML
  333. if "$AUTOLOGIN"; then
  334. cat >> /etc/greetd/config.toml <<TOML
  335.  
  336. [initial_session]
  337. command = "/usr/local/bin/noctalia-niri-session"
  338. user = "$DESKTOP_USER"
  339. TOML
  340. fi
  341.  
  342. systemctl enable qemu-guest-agent.service
  343. systemctl start qemu-guest-agent.service
  344. systemctl enable greetd.service
  345. systemctl set-default graphical.target
  346. if [[ -S "/run/user/$USER_ID/bus" ]]; then
  347. as_user systemctl --user daemon-reload
  348. as_user systemctl --user enable --now pipewire.socket pipewire-pulse.socket wireplumber.service
  349. as_user xdg-user-dirs-update
  350. else
  351. printf 'No user bus is available; audio will start with the next desktop login.\n'
  352. fi
  353. chown -R "$USER_ID:$GROUP_ID" "$BACKUP"
  354.  
  355. printf '\nInstallation validated. Reboot to start Noctalia; the active session was not interrupted.\n'
  356. printf 'Autologin: %s (physical/console access grants access to this account).\n' "$AUTOLOGIN"
  357. printf 'Super+Enter: terminal | Super+Space: launcher | Super+S: controls | Super+Tab: overview\n'
  358. printf 'Log: %s/install.log\nBackups: %s\n' "$STATE" "$BACKUP"
  359.  
Add Comment
Please, Sign In to add comment