53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
nano #!/bin/bash
|
|
|
|
LOGFILE="/tmp/launch_app_debug.log"
|
|
echo "------ $(date) ------" >> "$LOGFILE"
|
|
|
|
# Get cursor position
|
|
read -r CURSOR_X CURSOR_Y <<< $(hyprctl cursorpos | awk '{gsub(/[^0-9 ]/, "", $0); print $1, $2}')
|
|
echo "Cursor Position: X=$CURSOR_X, Y=$CURSOR_Y" >> "$LOGFILE"
|
|
|
|
# Detect monitor under cursor
|
|
monitor=$(hyprctl monitors -j | jq -r \
|
|
--arg x "$CURSOR_X" --arg y "$CURSOR_Y" '
|
|
.[] | select(
|
|
(.x <= ($x|tonumber) and ($x|tonumber) < (.x + .width)) and
|
|
(.y <= ($y|tonumber) and ($y|tonumber) < (.y + .height))
|
|
) | .name')
|
|
|
|
if [ -z "$monitor" ]; then
|
|
echo "Could not detect monitor. Defaulting." >> "$LOGFILE"
|
|
monitor="unknown"
|
|
fi
|
|
|
|
echo "Detected Monitor: $monitor" >> "$LOGFILE"
|
|
|
|
# Assign DPI scaling based on monitor
|
|
case "$monitor" in
|
|
"HDMI-A-1" | "DP-2")
|
|
GDK_SCALE=2
|
|
GDK_DPI_SCALE=0.5
|
|
QT_SCALE_FACTOR=2
|
|
;;
|
|
"DP-3" | "DP-1")
|
|
GDK_SCALE=1
|
|
GDK_DPI_SCALE=1
|
|
QT_SCALE_FACTOR=1
|
|
;;
|
|
*)
|
|
echo "Monitor $monitor not matched to known profiles." >> "$LOGFILE"
|
|
GDK_SCALE=1
|
|
GDK_DPI_SCALE=1
|
|
QT_SCALE_FACTOR=1
|
|
;;
|
|
esac
|
|
|
|
echo "ENV: GDK_SCALE=$GDK_SCALE, GDK_DPI_SCALE=$GDK_DPI_SCALE, QT_SCALE_FACTOR=$QT_SCALE_FACTOR" >> "$LOGFILE"
|
|
|
|
export GDK_SCALE
|
|
export GDK_DPI_SCALE
|
|
export QT_SCALE_FACTOR
|
|
|
|
echo "Executing: $@" >> "$LOGFILE"
|
|
exec "$@"
|