#!/usr/bin/bash

# Define the base command with common options
command="pkexec btrfs-assistant --xdg-runtime=\"${XDG_RUNTIME_DIR}\""

# Add platform and display options when using Sway or Hyprland
if [[ -n ${SWAYSOCK} || -n ${HYPRLAND_CMD} ]]; then
    command="${command} --platform=\"${QT_QPA_PLATFORM}\" --display=\"${WAYLAND_DISPLAY}\""
fi

# Add platformtheme option if QT_QPA_PLATFORMTHEME is set
if [[ -n ${QT_QPA_PLATFORMTHEME} ]]; then
    command="${command} --platformtheme=\"${QT_QPA_PLATFORMTHEME}\""
fi

# Add style-override option if QT_STYLE_OVERRIDE is set
if [[ -n ${QT_STYLE_OVERRIDE} ]]; then
    command="${command} --style-override=\"${QT_STYLE_OVERRIDE}\""
fi

# Execute the constructed command
eval "$command"
