chamesle-desktop (4765B)
1 #!/bin/sh 2 # chamesle-desktop NAME: puts one of chamesle's desktops on this system, the same one its iso used to have 3 # chamesle-desktop the list 4 # sudo chamesle-desktop kde 5 # jiggity runs it in the new system while it installs. CHAMESLE_PROGRESS=FD gets apk's progress, 6 # CHAMESLE_EXTRA=PKGS goes in with the rest 7 set -eu 8 D=/usr/share/chamesle/editions 9 10 if [ $# = 0 ]; then 11 for e in "$D"/*/edition; do 12 e=${e%/edition}; e=${e##*/} 13 [ "$e" = netinst ] || printf '%-10s %s\n' "$e" "$(sed -n 's/^name=//p' "$D/$e/edition")" 14 done 15 exit 0 16 fi 17 ED=$1 18 [ -f "$D/$ED/packages" ] && [ "$ED" != netinst ] || { echo "chamesle-desktop: no desktop '$ED' (chamesle-desktop lists them)" >&2; exit 1; } 19 [ "$(id -u)" = 0 ] || { echo "chamesle-desktop: needs root: sudo chamesle-desktop $ED" >&2; exit 1; } 20 BASE=$(sed -n 's/^base=//p' "$D/$ED/edition") 21 EDS="$BASE $ED" 22 val() { for e in $ED $BASE; do v=$(sed -n "s/^$1=//p" "$D/$e/edition"); [ -n "$v" ] && { echo "$v"; return; }; done; return 0; } 23 NAME=$(sed -n 's/^name=//p' "$D/$ED/edition") 24 25 BASEPKGS=$D/base.packages; [ "$(val desktop-packages)" = no ] && BASEPKGS= 26 pkgs=$(sed 's/#.*//' $BASEPKGS $(for e in $EDS; do echo "$D/$e/packages"; done) | tr ' \t' '\n\n' | grep -v '^$' | sort -u) 27 echo "chamesle-desktop: $NAME, $(echo "$pkgs" | wc -l) packages and what they need" 28 # the netinst came without most of the firmware. now: what this computer's graphics and processor need. 29 # the rest (wi-fi chips it doesn't have, phones...) comes later in the background, chamesle-refresh does that 30 now= 31 if [ -s /etc/chamesle/trimmed ]; then 32 v=$(cat /sys/bus/pci/devices/*/vendor 2>/dev/null; grep -m1 vendor_id /proc/cpuinfo) 33 for f in $(cat /etc/chamesle/trimmed); do 34 case $f in 35 linux-firmware) now="$now $f";; 36 linux-firmware-amd) echo "$v" | grep -qiE '0x1002|AuthenticAMD' && now="$now $f";; 37 linux-firmware-intel) echo "$v" | grep -qiE '0x8086|GenuineIntel' && now="$now $f";; 38 intel-ucode) echo "$v" | grep -qi GenuineIntel && now="$now $f";; 39 linux-firmware-nvidia) echo "$v" | grep -qi '0x10de' && now="$now $f";; 40 esac 41 done 42 for f in $now; do sed -i "/^$f\$/d" /etc/chamesle/trimmed; done 43 [ -s /etc/chamesle/trimmed ] || rm /etc/chamesle/trimmed 44 fi 45 # what came from an older iso: as new as the repo, kernel and all. curl does the downloading, with one 46 # percentage for all of it (chamesle-get) 47 fix=; [ -n "$now" ] && fix="fix --reinstall$now" 48 /usr/libexec/chamesle-get ${fix:+"$fix"} "upgrade" "add !runit !runit-void $(echo $pkgs) ${CHAMESLE_EXTRA:-}" 49 50 fp=$(val flatpaks) 51 if [ -n "$fp" ]; then 52 echo "chamesle-desktop: $fp from flathub" 53 flatpak remote-add --system --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo 54 flatpak install --system -y --noninteractive flathub $fp 55 fi 56 57 for e in $EDS; do [ -d "$D/$e/overlay" ] && cp -a "$D/$e/overlay/." /; done 58 # services: on for what's installed now, off for what isn't (the server has no bluetooth or printing) 59 for s in $(cat "$D/services"); do 60 [ -f /etc/dinit.d/$s ] || continue 61 ok=1 62 for c in $(sed -n 's/^command *= *//p' /etc/dinit.d/$s); do 63 case $c in /*) [ -e "$c" ] || ok=;; esac 64 done 65 if [ -n "$ok" ]; then ln -sfn ../$s /etc/dinit.d/boot.d/$s; else rm -f /etc/dinit.d/boot.d/$s; fi 66 done 67 # xfce's stock wallpapers -> ours, for monitors xfce4-desktop.xml doesn't name 68 if [ -d /usr/share/backgrounds/xfce ]; then 69 for f in xfce-x.svg xfce-shapes.svg xfce-stripes.png xfce-teal.png xfce-verticals.png; do 70 ln -sf ../chamesle/default.png /usr/share/backgrounds/xfce/$f 71 done 72 fi 73 # the windows key opens the start menu 74 KS=/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml 75 if [ -f "$KS" ] && ! grep -q xfce4-popup-whiskermenu "$KS"; then 76 sed -i 's|^\( *\)<property name="<Super>e" type="string" value="thunar"/>|&\n\1<property name="Super_L" type="string" value="xfce4-popup-whiskermenu"/>|' "$KS" 77 fi 78 79 # what starts: a sign-in screen and the edition's session, or the console 80 SESSION=$(val installed-session); [ -n "$SESSION" ] || SESSION=$(val session); SESSION=${SESSION:-${BASE:-$ED}} 81 LOGIN=$(val login); LOGIN=${LOGIN:-sddm} 82 mkdir -p /etc/chamesle 83 echo "$SESSION" > /etc/chamesle/session 84 echo "$LOGIN" > /etc/chamesle/login 85 [ "$LOGIN" = console ] && rm -f /etc/dinit.d/boot.d/display-manager 86 echo "$ED" > /usr/share/chamesle/edition 87 sed -i "s/^PRETTY_NAME=\"\(Chamesle Linux [^(]*\)(.*)\"/PRETTY_NAME=\"\1($NAME)\"/; s/^VARIANT=.*/VARIANT=\"$NAME\"/; s/^VARIANT_ID=.*/VARIANT_ID=$ED/" /etc/os-release 88 fc-cache -f >/dev/null 2>&1 || true 89 gtk-update-icon-cache -q -f /usr/share/icons/hicolor 2>/dev/null || true 90 echo "chamesle-desktop: $NAME is on, it starts after a restart"