Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Espanso doesn't facilitate repositioning of its Search or Choice etc. windows.
- # If the following script is running in the background, it will await the opening
- # of the window, and move it to the top left of the screen.
- # Adjust the middle two coordinates (,0,0,) for a different position, and reduce
- # the lower sleep value (included to reduce CPU load) if it's too slow
- # Exact window title to match
- WINDOW_TITLE="espanso"
- # Function to get the window ID based on the window title
- get_window_id() {
- local title="$1"
- wmctrl -l | awk -v title="$title" '$NF == title {print $1}'
- }
- while true; do
- # Get the window ID using the function
- WINDOW_ID=$(get_window_id "$WINDOW_TITLE")
- # If the window is found
- if [ ! -z "$WINDOW_ID" ]; then
- wmctrl -i -r "$WINDOW_ID" -e 0,0,0,-1,-1
- echo "Window '$WINDOW_TITLE' moved to the top-left corner."
- # Loop until the window is no longer found
- while [ ! -z "$(get_window_id "$WINDOW_TITLE")" ]; do
- sleep 1 # Keep checking every second if the window is still open
- done
- echo "Window '$WINDOW_TITLE' closed or minimized. Waiting for it to reappear."
- fi
- sleep 0.5 # Check for the window's existence every 0.5 seconds
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement