From a9e5ace0805fbb602f5d824c23ea68a7ef0c51e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20B=C3=BCchler?= Date: Fri, 8 Aug 2025 11:26:13 +0200 Subject: [PATCH] feat: unify host detection and profile mapping - Add host-profiles.conf for hostname-to-profile mapping - Update symlinks script to use mapping and error early if unmapped MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated with opencode Co-Authored-By: opencode --- host-profiles.conf | 3 +++ modules/02-symlinks.sh | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 16 deletions(-) create mode 100644 host-profiles.conf diff --git a/host-profiles.conf b/host-profiles.conf new file mode 100644 index 0000000..38ddbdc --- /dev/null +++ b/host-profiles.conf @@ -0,0 +1,3 @@ +# Map hostnames to device profiles +lousy-arch=desktop +archlaptop=laptop diff --git a/modules/02-symlinks.sh b/modules/02-symlinks.sh index 4455589..d0d827d 100755 --- a/modules/02-symlinks.sh +++ b/modules/02-symlinks.sh @@ -37,22 +37,32 @@ if [ -d "$CONFIG_DIR" ]; then echo "Linked .config/$baseitem" done - # Device-specific symlinks for Hyprland and Waybar - if [ -n "$DOTFILES_DEVICE" ]; then - # Hyprland monitors (hostname-based) - HOSTNAME=$(hostname) - if [ -f "$CONFIG_DIR/hypr/includes/monitors-$HOSTNAME.conf" ]; then - ln -sf "$CONFIG_DIR/hypr/includes/monitors-$HOSTNAME.conf" "$CONFIG_DIR/hypr/includes/monitors.conf" - echo "Linked monitors-$HOSTNAME.conf as monitors.conf" - else - echo "Warning: No monitors config for hostname $HOSTNAME" - fi - # Hyprland hypridle - ln -sf "$CONFIG_DIR/hypr/includes/hypridle-$DOTFILES_DEVICE.conf" "$CONFIG_DIR/hypr/hypridle.conf" - echo "Linked hypridle-$DOTFILES_DEVICE.conf as hypridle.conf" - # Waybar config - ln -sf "$CONFIG_DIR/waybar/config-$DOTFILES_DEVICE" "$CONFIG_DIR/waybar/config" - echo "Linked config-$DOTFILES_DEVICE as waybar config" + # Device-specific symlinks for Hyprland and Waybar using host-profiles.conf + HOSTNAME=$(hostname) + PROFILE="" + if [ -f "$DOTFILES_DIR/host-profiles.conf" ]; then + PROFILE=$(awk -F= -v h="$HOSTNAME" '$1==h{print $2}' "$DOTFILES_DIR/host-profiles.conf") + fi + if [ -z "$PROFILE" ]; then + echo "ERROR: No profile mapping found for hostname '$HOSTNAME' in $DOTFILES_DIR/host-profiles.conf" + exit 1 + fi + # Hyprland monitors + if [ -f "$CONFIG_DIR/hypr/includes/monitors-$HOSTNAME.conf" ]; then + ln -sf "$CONFIG_DIR/hypr/includes/monitors-$HOSTNAME.conf" "$CONFIG_DIR/hypr/includes/monitors.conf" + echo "Linked monitors-$HOSTNAME.conf as monitors.conf" + else + echo "Warning: No monitors config for hostname $HOSTNAME" + fi + # Hyprland hypridle + if [ -f "$CONFIG_DIR/hypr/includes/hypridle-$PROFILE.conf" ]; then + ln -sf "$CONFIG_DIR/hypr/includes/hypridle-$PROFILE.conf" "$CONFIG_DIR/hypr/hypridle.conf" + echo "Linked hypridle-$PROFILE.conf as hypridle.conf" + fi + # Waybar config + if [ -f "$CONFIG_DIR/waybar/config-$PROFILE" ]; then + ln -sf "$CONFIG_DIR/waybar/config-$PROFILE" "$CONFIG_DIR/waybar/config" + echo "Linked config-$PROFILE as waybar config" fi fi