From 57e583debfd4f1f47b5c1e55c1e12857e58905df Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Mon, 29 Jan 2024 16:17:30 -0800 Subject: [PATCH] chore: Clean up hardware & user setup scripts --- .../desktop/shared/usr/bin/bazzite-hardware-setup | 10 +++++----- .../desktop/shared/usr/bin/bazzite-user-setup | 12 +++++++----- .../usr/libexec/hardware/handycon-supported-hardware | 7 +++++++ .../usr/libexec/hardware/hhd-supported-hardware | 7 +++++++ .../usr/libexec/hardware/rotation-fix-hardware | 7 +++++++ .../shared/usr/libexec/hardware/valve-hardware | 7 +++++++ 6 files changed, 40 insertions(+), 10 deletions(-) create mode 100755 system_files/desktop/shared/usr/libexec/hardware/handycon-supported-hardware create mode 100755 system_files/desktop/shared/usr/libexec/hardware/hhd-supported-hardware create mode 100755 system_files/desktop/shared/usr/libexec/hardware/rotation-fix-hardware create mode 100755 system_files/desktop/shared/usr/libexec/hardware/valve-hardware diff --git a/system_files/desktop/shared/usr/bin/bazzite-hardware-setup b/system_files/desktop/shared/usr/bin/bazzite-hardware-setup index ad465adbd5..289706def3 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-hardware-setup +++ b/system_files/desktop/shared/usr/bin/bazzite-hardware-setup @@ -42,7 +42,7 @@ if [[ ! -f $INITRAMFS_REBUILD_TRIGGER ]]; then if [[ -f $KNOWN_IMAGE_NAME_FILE && -f $KNOWN_IMAGE_FLAVOR_FILE && -f $KNOWN_FEDORA_VERSION_FILE && -f $KNOWN_IMAGE_BRANCH_FILE ]]; then # Run script if image has been rebased if [[ $IMAGE_NAME = "$KNOWN_IMAGE_NAME" && $IMAGE_FLAVOR = "$KNOWN_IMAGE_FLAVOR" && $FEDORA_VERSION = "$KNOWN_FEDORA_VERSION" && $IMAGE_BRANCH = "$KNOWN_IMAGE_BRANCH" ]]; then - echo "Hardware setup has already run. Exiting..." + echo "Hardware setup v$HWS_VER has already run. Exiting..." exit 0 fi fi @@ -108,7 +108,7 @@ fi # KERNEL ARGUMENTS echo "Current kargs: $KARGS" -if [[ ":Jupiter:" =~ ":$SYS_ID:" || ":Galileo:" =~ ":$SYS_ID:" ]]; then +if /usr/libexec/hardware/valve-hardware; then echo "Checking for needed karg changes (Jupiter/Galileo)" if [[ ! $KARGS =~ "amd_iommu" ]]; then @@ -139,7 +139,7 @@ if [[ ":83E1:" =~ ":$SYS_ID:" ]]; then fi fi -if [[ ":ROG Ally RC71L_RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:" =~ ":$SYS_ID:" ]]; then +if /usr/libexec/hardware/hhd-supported-hardware; then if [[ ! $KARGS =~ "iomem" ]]; then echo "Adding needed kargs for ryzenadj" NEEDED_KARGS+=("--append-if-missing=iomem=relaxed") @@ -176,11 +176,11 @@ if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegam systemctl enable --now vpower.service else echo "Generic device detected. Performing setup..." - if [[ ":ROG Ally RC71L_RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:" =~ ":$SYS_ID:" ]]; then + if /usr/libexec/hardware/hhd-supported-hardware; then echo "HHD supported handheld detected, disabling handycon & ds-inhibit..." systemctl disable --now handycon.service systemctl disable --now ds-inhibit.service - elif [[ ":AYANEO GEEK:AYANEO 2:AYANEO 2S:AOKZOE A1 AR07:G1619-04:Win600:" =~ ":$SYS_ID:" ]]; then + elif /usr/libexec/hardware/handycon-supported-hardware; then echo "HandyGCCS supported handheld detected, enabling handycon & ds-inhibit..." systemctl enable --now handycon.service systemctl enable --now ds-inhbit.service diff --git a/system_files/desktop/shared/usr/bin/bazzite-user-setup b/system_files/desktop/shared/usr/bin/bazzite-user-setup index 209f100c27..5e83b744ce 100755 --- a/system_files/desktop/shared/usr/bin/bazzite-user-setup +++ b/system_files/desktop/shared/usr/bin/bazzite-user-setup @@ -4,7 +4,6 @@ IMAGE_INFO="/usr/share/ublue-os/image-info.json" IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO) BASE_IMAGE_NAME=$(jq -r '."base-image-name"' < $IMAGE_INFO) FEDORA_VERSION=$(jq -r '."fedora-version"' < $IMAGE_INFO) -SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" # INIT BAZZITE_CONFIG_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/bazzite" @@ -14,6 +13,7 @@ mkdir -p "$BAZZITE_CONFIG_DIR" USER_SETUP_VER=25 USER_SETUP_VER_FILE="$BAZZITE_CONFIG_DIR/version" USER_SETUP_FEDORA_VER_FILE="$BAZZITE_CONFIG_DIR/fedora_version" +USER_SETUP_IMAGE_VER_FILE=$BAZZITE_CONFIG_DIR/image_name"" if [[ -f "$HOME/.bazzite-configured" ]]; then mv -f "$HOME/.bazzite-configured" "$USER_SETUP_VER_FILE" @@ -25,10 +25,11 @@ fi USER_SETUP_VER_RAN=$(cat $USER_SETUP_VER_FILE) USER_SETUP_FEDORA_VER_RAN=$(cat $USER_SETUP_FEDORA_VER_FILE) +USER_SETUP_IMAGE_VER_RAN=$(cat $USER_SETUP_IMAGE_VER_FILE) # Run script if updated if [[ -f $USER_SETUP_VER_FILE && $USER_SETUP_VER = $USER_SETUP_VER_RAN ]]; then - if [[ -f $USER_SETUP_FEDORA_VER_FILE && $FEDORA_VERSION = $USER_SETUP_FEDORA_VER_RAN ]]; then + if [[ -f $USER_SETUP_FEDORA_VER_FILE && $FEDORA_VERSION = $USER_SETUP_FEDORA_VER_RAN && $BASE_IMAGE_NAME == USER_SETUP_IMAGE_VER_RAN ]]; then echo "User setup v$USER_SETUP_VER has already run. Exiting..." exit 0 fi @@ -115,13 +116,13 @@ fi # Deck Build Setup if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegame" ]]; then # HHD Setup - if [[ "ROG Ally RC71L_RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:" =~ ":$SYS_ID:" ]]; then + if /usr/libexec/hardware/hhd-supported-hardware; then echo 'Enabling HHD' pkexec /usr/libexec/bazzite-enable-hhd "$USER" fi # SDGyroDSU Setup - if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then + if /usr/libexec/hardware/valve-hardware; then systemctl --user enable --now sdgyrodsu.service else systemctl --user disable --now sdgyrodsu.service @@ -135,7 +136,7 @@ if [[ $IMAGE_NAME =~ "deck" || $IMAGE_NAME =~ "ally" || $IMAGE_NAME =~ "framegam rm -f "$AUTOSTART_FOLDER/autostart/bazzite-handle-legion-go-rotation.desktop" fi - if [[ ":ROG Ally RC71L_RC71L:83E1:Loki Max:G1618-04:" =~ ":$SYS_ID:" ]] && [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then + if /usr/libexec/rotation-fix-hardware && [[ $BASE_IMAGE_NAME =~ "kinoite" ]]; then if [[ ! -f "$AUTOSTART_FOLDER/autostart/bazzite-rotation-fix.desktop" ]]; then echo 'Adding rotation fix' mkdir -p "$AUTOSTART_FOLDER/autostart" @@ -151,3 +152,4 @@ fi echo "Writing state file" echo $USER_SETUP_VER > $USER_SETUP_VER_FILE echo $FEDORA_VERSION > $USER_SETUP_FEDORA_VER_FILE +echo $BASE_IMAGE_NAME > $USER_SETUP_IMAGE_VER_FILE diff --git a/system_files/desktop/shared/usr/libexec/hardware/handycon-supported-hardware b/system_files/desktop/shared/usr/libexec/hardware/handycon-supported-hardware new file mode 100755 index 0000000000..4bcae442cb --- /dev/null +++ b/system_files/desktop/shared/usr/libexec/hardware/handycon-supported-hardware @@ -0,0 +1,7 @@ +#!/usr/bin/bash +SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" +if [[ ":AYANEO GEEK:AYANEO 2:AYANEO 2S:AOKZOE A1 AR07:G1619-04:Win600:" =~ ":$SYS_ID:" ]]; then + exit 0 +else + exit 1 +fi diff --git a/system_files/desktop/shared/usr/libexec/hardware/hhd-supported-hardware b/system_files/desktop/shared/usr/libexec/hardware/hhd-supported-hardware new file mode 100755 index 0000000000..e4e31731ed --- /dev/null +++ b/system_files/desktop/shared/usr/libexec/hardware/hhd-supported-hardware @@ -0,0 +1,7 @@ +#!/usr/bin/bash +SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" +if [[ ":ROG Ally RC71L_RC71L:83E1:G1618-04:G1617-01:G1619-05:AIR Plus:" =~ ":$SYS_ID:" ]]; then + exit 0 +else + exit 1 +fi diff --git a/system_files/desktop/shared/usr/libexec/hardware/rotation-fix-hardware b/system_files/desktop/shared/usr/libexec/hardware/rotation-fix-hardware new file mode 100755 index 0000000000..15aad21765 --- /dev/null +++ b/system_files/desktop/shared/usr/libexec/hardware/rotation-fix-hardware @@ -0,0 +1,7 @@ +#!/usr/bin/bash +SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" +if [[ ":ROG Ally RC71L_RC71L:83E1:Loki Max:G1618-04:" =~ ":$SYS_ID:" ]]; then + exit 0 +else + exit 1 +fi diff --git a/system_files/desktop/shared/usr/libexec/hardware/valve-hardware b/system_files/desktop/shared/usr/libexec/hardware/valve-hardware new file mode 100755 index 0000000000..6e8878ec8f --- /dev/null +++ b/system_files/desktop/shared/usr/libexec/hardware/valve-hardware @@ -0,0 +1,7 @@ +#!/usr/bin/bash +SYS_ID="$(cat /sys/devices/virtual/dmi/id/product_name)" +if [[ ":Jupiter:Galileo:" =~ ":$SYS_ID:" ]]; then + exit 0 +else + exit 1 +fi