Advertisement
smeech

espanso_move2.sh

Aug 18th, 2024 (edited)
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.80 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # A slightly more efficient version of espanso_move.sh which utilises xwininfo.
  4.  
  5. WINDOW_TITLE="espanso"
  6.  
  7. # Function to check if the window exists and return window information
  8. get_window_info() { xwininfo -name "$WINDOW_TITLE" 2> /dev/null; }
  9.  
  10. while true; do
  11.   # Get window information using the function
  12.   WINDOW_INFO=$(get_window_info)
  13.   if [ -n "$WINDOW_INFO" ]; then
  14.     WINDOW_ID=$(echo "$WINDOW_INFO" | awk '/Window id:/ {print $4}')
  15.     wmctrl -i -r "$WINDOW_ID" -e 0,0,0,-1,-1 # gravity, coordinates, resize
  16.     echo "Window '$WINDOW_TITLE' moved."
  17.     # Wait until the window closes
  18.     while [ -n "$(get_window_info)" ]; do sleep 1; done
  19.     echo "Window '$WINDOW_TITLE' closed or minimized. Waiting for it to reappear."
  20.   fi
  21.   sleep 0.5  # Control polling frequency
  22. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement