diff --git a/i38.sh b/i38.sh index 7203a58..87c4af1 100755 --- a/i38.sh +++ b/i38.sh @@ -21,7 +21,7 @@ configFile="${PWD}/I38_preferences.conf" export DIALOGOPTS='--no-lines --visit-items' # Check to make sure minimum requirements are installed. -for i in dialog jq yad ; do +for i in dialog jq yad xdotool ; do if ! command -v "$i" &> /dev/null ; then missing+=("$i") fi diff --git a/scripts/i3_watchdog.sh b/scripts/i3_watchdog.sh index e5f94c4..41f7b75 100755 --- a/scripts/i3_watchdog.sh +++ b/scripts/i3_watchdog.sh @@ -47,8 +47,8 @@ while true; do ipcWorks=1 fi - # Also check if X focus is working - if DISPLAY=:0 timeout 1 xdotool getwindowfocus > /dev/null 2>&1; then + # Also check if X focus is working (use current DISPLAY, not hardcoded) + if timeout 1 xdotool getwindowfocus > /dev/null 2>&1; then focusWorks=1 fi @@ -102,34 +102,34 @@ while true; do fi # Check if this is a focus issue (Wine keyboard grab bug) - focusCheck=$(DISPLAY=:0 xdotool getwindowfocus 2>&1) + focusCheck=$(xdotool getwindowfocus 2>&1) log_message "Focus check result: $focusCheck" # Try to reset focus to i3 log_message "Attempting to reset X focus..." - DISPLAY=:0 xdotool key --clearmodifiers Super_L 2>/dev/null + xdotool key --clearmodifiers Super_L 2>/dev/null sleep 0.5 # Try to focus on i3's root window - i3RootWindow=$(DISPLAY=:0 xdotool search --class "i3" | head -1) + i3RootWindow=$(xdotool search --class "i3" | head -1) if [[ -n "$i3RootWindow" ]]; then log_message "Focusing i3 root window: $i3RootWindow" - DISPLAY=:0 xdotool windowfocus "$i3RootWindow" 2>/dev/null + xdotool windowfocus "$i3RootWindow" 2>/dev/null fi # Try i3-msg to focus something log_message "Using i3-msg to focus workspace..." - DISPLAY=:0 i3-msg workspace number 1 >/dev/null 2>&1 + i3-msg workspace number 1 >/dev/null 2>&1 sleep 0.5 - DISPLAY=:0 i3-msg focus output primary >/dev/null 2>&1 + i3-msg focus output primary >/dev/null 2>&1 sleep 1 # Check if focus is actually fixed now - if DISPLAY=:0 timeout 1 xdotool getwindowfocus >/dev/null 2>&1; then + if timeout 1 xdotool getwindowfocus >/dev/null 2>&1; then log_message "Focus recovery successful!" else log_message "Focus still broken - restarting i3..." - DISPLAY=:0 i3-msg -t run_command restart + i3-msg -t run_command restart log_message "Restart command sent" fi