From 69f5dd0ca65043457619bd71bc8a740f7b51c497 Mon Sep 17 00:00:00 2001 From: Jessie Hildebrandt Date: Fri, 2 Jun 2023 12:14:32 -0400 Subject: [PATCH] Add automatic feature detection to personalizer --- opensuse-personalizer.sh | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/opensuse-personalizer.sh b/opensuse-personalizer.sh index d3c7059..405593f 100755 --- a/opensuse-personalizer.sh +++ b/opensuse-personalizer.sh @@ -221,11 +221,8 @@ function prompt_optional_additions () --checklist "Select any additional configuration changes that you would like applied to the system:" 0 0 0 \ "Xournal++" "Install Xournal++ for taking handwritten notes" OFF \ "EasyEffects" "Install EasyEffects for applying effects (e.g. equalizers) to system audio devices" OFF \ - "Media Control Key Shortcuts" "Set up media control keyboard shortcuts (for keyboards without dedicated media control keys)" OFF \ - "Touchpad Lock Toggle Shortcut" "Set up a touchpad lock toggle keyboard shortcut (for systems with touchpads)" OFF \ - "Power Button Screen Lock Override" "Override the power button's default behavior with a screen lock shortcut (for tablets or convertibles)" OFF \ - '"Reboot to Windows" Launcher' "Install a desktop entry that reboots the system to Microsoft Windows (for systems that multi-boot with Windows)" OFF ) - + "Media Control Key Shortcuts" "Set up media control keyboard shortcuts (for systems without dedicated media control keys)" OFF \ + "Power Button Screen Lock Override" "Override the power button's default behavior with a screen lock shortcut (for tablets and some convertibles)" OFF ) case "${ENTRY}" in "") @@ -254,6 +251,28 @@ function prompt_optional_additions () # Repeatedly show the prompt until we receive valid input until prompt_optional_additions; do : ; done +################################################################################ +# +# Feature detection +# +################################################################################ + +detected_features=() + +# Touchpad detection +if + cat /proc/bus/input/devices | grep -i Touchpad +then + detected_features+=('Touchpad') +fi + +# Windows multi-boot detection +if + sudo grep menuentry /boot/grub2/grub.cfg | grep -Po ".*Windows.*" +then + detected_features+=('Windows') +fi + ################################################################################ # # Package setup @@ -395,7 +414,7 @@ add_custom_gnome_keybinding "Launch Terminal" "gnome-terminal" "Return" add_custom_gnome_keybinding "Toggle Night Light" "gnome-toggle-night-light" "n" # (OPTIONAL) Add custom shortcuts -if [[ "${optional_additions}" == *"Touchpad Lock Toggle Shortcut"* ]]; then +if [[ "${detected_features[@]}" == *"Touchpad"* ]]; then add_custom_gnome_keybinding "Toggle Touchpad Lock" "gnome-toggle-touchpad-lock" "t" fi if [[ "${optional_additions}" == *"Power Button Screen Lock Override"* ]]; then @@ -506,11 +525,11 @@ echo "Installing scripts..." # Clone personalizer repo containing scripts, desktop entries, etc. to temporary folder git clone "${PERSONALIZER_REPO_URL}" "${PERSONALIZER_REPO_DIR}" -if [[ "${optional_additions}" != *'Touchpad Lock Toggle Shortcut'* ]]; then +if [[ "${detected_features[@]}" != *'Touchpad'* ]]; then rm ${PERSONALIZER_REPO_DIR}/scripts/gnome-toggle-touchpad-lock fi -if [[ "${optional_additions}" != *'"Reboot to Windows" Launcher'* ]]; then +if [[ "${detected_features[@]}" != *'Windows'* ]]; then rm ${PERSONALIZER_REPO_DIR}/scripts/reboot-windows fi @@ -522,7 +541,7 @@ sudo cp ${PERSONALIZER_REPO_DIR}/scripts/* /usr/bin echo "Installing desktop entries..." -if [[ "${optional_additions}" != *'"Reboot to Windows" Launcher'* ]]; then +if [[ "${detected_features[@]}" != *'Windows'* ]]; then rm ${PERSONALIZER_REPO_DIR}/desktop_entries/windows.desktop fi