Skip to content

Commit

Permalink
feat(framework): Add full/automatic support for Framework hardware (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleGospo authored May 2, 2024
1 parent 5ab89b1 commit 7765bd6
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 13 deletions.
44 changes: 35 additions & 9 deletions build_files/base/copr-repos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -ouex pipefail
# Add Staging repo
curl -Lo /etc/yum.repos.d/ublue-os-staging-fedora-"${FEDORA_MAJOR_VERSION}".repo https://copr.fedorainfracloud.org/coprs/ublue-os/staging/repo/fedora-"${FEDORA_MAJOR_VERSION}"/ublue-os-staging-fedora-"${FEDORA_MAJOR_VERSION}".repo

# 39 gets VRR and Ptyxis
# 39 Ptyxis
if [ "${FEDORA_MAJOR_VERSION}" -eq "39" ]; then
curl -Lo /etc/yum.repos.d/_copr_kylegospo-gnome-vrr.repo https://copr.fedorainfracloud.org/coprs/kylegospo/gnome-vrr/repo/fedora-"${FEDORA_MAJOR_VERSION}"/kylegospo-gnome-vrr-fedora-"${FEDORA_MAJOR_VERSION}".repo
rpm-ostree override replace --experimental --from repo=copr:copr.fedorainfracloud.org:kylegospo:gnome-vrr mutter mutter-common gnome-control-center gnome-control-center-filesystem
Expand All @@ -20,21 +20,47 @@ if [ "${FEDORA_MAJOR_VERSION}" -eq "39" ]; then
rpm-ostree install ptyxis
fi

# 40 gets Ptyxis and patched Mutter
# 40 Ptyxis
if [ "${FEDORA_MAJOR_VERSION}" -eq "40" ]; then
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:ublue-os:staging \
vte291 \
vte-profile
rpm-ostree install ptyxis
# This has been quite broken
# if [[ "${BASE_IMAGE_NAME}" =~ "silverblue" ]]; then
# rpm-ostree override replace \
# --experimental \
# --from repo=copr:copr.fedorainfracloud.org:ublue-os:staging \
# mutter
# fi
fi

# Patched switcheroo
if [[ "${FEDORA_MAJOR_VERSION}" -eq "40" ]]; then
# Add repo
curl -Lo /etc/yum.repos.d/_copr_sentry-switcheroo-control_discrete.repo https://copr.fedorainfracloud.org/coprs/sentry/switcheroo-control_discrete/repo/fedora-"${FEDORA_MAJOR_VERSION}"/sentry-switcheroo-control_discrete-fedora-"${FEDORA_MAJOR_VERSION}".repo

# Patched shells
if [[ "${BASE_IMAGE_NAME}" = "silverblue" ]]; then
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:ublue-os:staging \
gnome-shell
elif [[ "${BASE_IMAGE_NAME}" = "kinoite" ]]; then
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:ublue-os:staging \
kf6-kio-doc \
kf6-kio-widgets-libs \
kf6-kio-core-libs \
kf6-kio-widgets \
kf6-kio-file-widgets \
kf6-kio-core \
kf6-kio-gui
fi

# Switcheroo patch
rpm-ostree override replace \
--experimental \
--from repo=copr:copr.fedorainfracloud.org:sentry:switcheroo-control_discrete \
switcheroo-control

rm /etc/yum.repos.d/_copr_sentry-switcheroo-control_discrete.repo
fi

# Add Nerd Fonts
Expand Down
1 change: 1 addition & 0 deletions packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"gnome-shell-extension-gsconnect",
"gnome-shell-extension-logo-menu",
"gnome-shell-extension-search-light",
"gnome-shell-extension-power-profile-switcher",
"libgda-sqlite",
"libgda",
"libratbag-ratbagd",
Expand Down
14 changes: 11 additions & 3 deletions system_files/shared/usr/libexec/ublue-system-setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ IMAGE_INFO="/usr/share/ublue-os/image-info.json"
IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
IMAGE_FLAVOR=$(jq -r '."image-flavor"' < $IMAGE_INFO)

VEN_ID="$(cat /sys/devices/virtual/dmi/id/chassis_vendor)"
CPU_VENDOR=$(grep "vendor_id" "/proc/cpuinfo" | uniq | awk -F": " '{ print $2 }')

# SCRIPT VERSION
HWS_VER=2
HWS_VER=3
HWS_VER_FILE="/etc/ublue/hws_version"
[[ -f "$HWS_VER_FILE" ]] && HWS_VER_RAN=$(cat $HWS_VER_FILE)

Expand Down Expand Up @@ -42,8 +45,13 @@ if [[ $KARGS =~ "nomodeset" ]]; then
NEEDED_KARGS+=("--delete-if-present=nomodeset")
fi

if [[ ! $KARGS =~ "rd.luks.options" && $KARGS =~ "rd.luks.uuid" ]]; then
NEEDED_KARGS+=("--append-if-missing=rd.luks.options=discard")
if [[ ":Framework:" =~ ":$VEN_ID:" ]]; then
if [[ "GenuineIntel" == "$CPU_VENDOR" ]]; then
if [[ ! $KARGS =~ "hid_sensor_hub" ]]; then
echo "Intel Framework Laptop detected, applying needed keyboard fix"
NEEDED_KARGS+=("--append-if-missing=module_blacklist=hid_sensor_hub");
fi
fi
fi

#shellcheck disable=SC2128
Expand Down
18 changes: 17 additions & 1 deletion system_files/shared/usr/libexec/ublue-user-setup
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
#!/usr/bin/bash

# SCRIPT VERSION
USER_SETUP_VER=5
USER_SETUP_VER=6
USER_SETUP_VER_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/ublue/user-setup"
USER_SETUP_VER_RAN=$(cat "$USER_SETUP_VER_FILE")
VEN_ID="$(cat /sys/devices/virtual/dmi/id/chassis_vendor)"

mkdir -p "$(dirname "$USER_SETUP_VER_FILE")" || exit 1

dirname "$USER_SETUP_VER_FILE"

# INIT
UBLUE_CONFIG_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/ublue"
mkdir -p "$UBLUE_CONFIG_DIR"

# Upgrade from v1 to v2 changes only the location of the USER_SETUP_VER.
# Exit if v1 file is present.
USER_SETUP_VER_FILE_V1="$HOME/.ublue-configured"
Expand Down Expand Up @@ -37,6 +42,17 @@ if [[ ! -f "$PTYXIS_DIR/catppuccin-dynamic.palette" ]]; then
cp "$PTYXIS_THEME_DIR/catppuccin-dynamic.palette" "$PTYXIS_DIR/catppuccin-dynamic.palette"
fi

if [[ ":Framework:" =~ ":$VEN_ID:" ]]; then
if [[ ! -f "$UBLUE_CONFIG_DIR/framework-initialized" ]]; then
echo 'Enabling automatic power profile extension'
gnome-extensions enable [email protected]
echo 'Setting Framework logo menu'
dconf write /org/gnome/shell/extensions/Logo-menu/symbolic-icon true
dconf write /org/gnome/shell/extensions/Logo-menu/menu-button-icon-image 31
touch "$UBLUE_CONFIG_DIR/framework-initialized"
fi
fi

# Handle privileged tasks
pkexec /usr/libexec/ublue-privileged-user-setup

Expand Down
4 changes: 4 additions & 0 deletions system_files/silverblue/usr/etc/dconf/db/local.d/01-ublue
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,7 @@ default-profile-uuid='2871e8027773ae74d6c87a5f659bbc74'

[org/gnome/Ptyxis/Profiles/2871e8027773ae74d6c87a5f659bbc74]
palette='catppuccin-dynamic'

[org/gnome/shell/extensions/power-profile-switcher]
ac='balanced'
bat='power-saver'

0 comments on commit 7765bd6

Please sign in to comment.